Opened 10 days ago

Closed 5 days ago

#2724 closed help (fixed)

nav_lon and nav_lat

Reported by: charlie Owned by: um_support
Priority: normal Component: Metadata
Keywords: Cc:
Platform: JASMIN UM Version: 10.7



Sorry to bother you with another question, but please could somebody advise on how to interpret the longitude and latitude coordinates (nav_lon and nav_lat, respectively) used to describe the curvilinear NEMO grid? I have struggled with this in the past (for other purposes) but now really need to understand how these locations are described and, in particular, how to convert the 2D latitude coordinates array into a more normal 1D list of latitudes.

As an example, see my temperature file on JASMIN at /gws/nopw/j04/ncas_climate_vol2/users/cwilliams2011/data1_for_use.d/sweet.d/gc31.d/ocean_init.d/

As you can see, the temperature array is 362,332 but, because the grid is curvilinear, the latitudes and longitudes are not listed as individual 1D arrays e.g. longitude = 362 values and latitude = 332 values. Instead, both are listed as coordinates in 2D arrays i.e. nav_lon = 362,332 and nav_lat = 362,332. I have taken a look in detail at both, and don't understand how these make sense.

For example, to get the latitudes, I thought I could just do print,nav_lat(0,*) i.e. just the columns of this array. But this can't be right because it gives me values ranging from -84.2107 to 50.01 - surely the latitudes should be balanced around 0 e.g. something like -89 to 89 or something similar?

The most important question is: how can I convert my 2D latitude coordinates array into a simple list of latitudes (similar to how standard grids work)?

Very many thanks,


Attachments (1)

nav_lon.png (35.3 KB) - added by grenville 6 days ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 7 days ago by grenville


Will this help - (see Regridding from a tripolar grid)


comment:2 Changed 6 days ago by charlie

Hi Grenville,

Thanks. That does help a little, inasmuch as it confirms the latitudes and longitudes. I have now looked at my file using both python (following the example above) and IDL, and according to python the latitudes do indeed start at -84 and end at 50. So at least I was reading it correctly in IDL. But how can this be? As I said in my previous message, how can the latitudes not be equal around zero?


comment:3 Changed 6 days ago by grenville


The lat-long coordinates of temperature(x,y) are lat(x,y) and lon(x,y)


comment:4 Changed 6 days ago by charlie

Many thanks, and yes I understand that. What I don't understand is why the latitudes aren't equal around zero?

comment:5 Changed 6 days ago by grenville

Please put the file somewhere visible to us

comment:6 Changed 6 days ago by charlie

Sorry, I thought I had. The file is:


And it should be visible to you, is it not?

comment:7 Changed 6 days ago by grenville

I don't have access to that gws - can you put it in your home and set read permissions?

comment:8 Changed 6 days ago by charlie

Sure thing, done.

It might be that I am reading the latitudes correctly and they do indeed only go from -84 to 50, and that this is correct, given that the curvilinear grid?

Although I don't entirely understand Grenville's comment above, that the lat-long coordinates of temperature(x,y) are lat(x,y) and lon(x,y) because surely this means that each grid point e.g. temp(0,0) would have 4 coordinates, not 2?

Changed 6 days ago by grenville

comment:9 Changed 6 days ago by grenville


temp(100,100) represents the temperature at NEMO grid point (100,100) (in NEMO units whatever they are.)

NEMO grid point (100,100) has real latitude value nav_lat(100,100) — that is one number, similarly for nav_lon

If you xconv and display the nav_lon field, you'll see values from -180 to 179.99, similarly for nav_lat (values -85.789 to 89.742) - see attached


comment:10 Changed 6 days ago by charlie

Okay, I think I'm beginning to understand - so each temperature grid point has its coordinates made up from the equivalent grid point in nav_lat and nav_lon.

It's the latitudes that I'm really interested in. I have just printed out these latitudes, i.e. the entire array nav_lat, and the reason I thought they only went up to 50 is because they are not in order i.e. they don't start at -89 and end at 89, but rather appear all jumbled up. So don't really understand how I can convert the 2D field into a 1D list of values, which are in order?

The reason I want to do this is because I need to apply an equation to my temperatures which uses the cosine of latitude i.e. something * cos(lats(y)). I have done this many times, but always within a loop using a single list of latitudes e.g. locations 0-143 corresponding to -90 to 90 whatever.


comment:11 Changed 6 days ago by charlie

My goodness this is tricky! I thought I had solved my previous question, with some probably inelegant and inefficient code, by simply going through the array and taking the minimum value, saving that in a list, making that minimum value some other number out of range (e.g. 1000) then repeating and so on. I would then end up 332 values corresponding to the 332 latitudes, in order.

However that doesn't work, because there are more than 332 latitudes. If I just loop round 332 times, I get 332 values beginning at -85.7887 and ending at -84.5183. So nowhere near all of them. Plus surely this implies the grid points are much higher resolution than 1°, which is what I thought Nemo was? I realised then that there are, in fact, 332*362 latitudes. I thought about reading through all of them, i.e. doing the above 332*362 times, but that doesn't work either because many of these are repeated more than once. So I'm really struggling to know how to do this.

Unless I am massively over complicating this, and there's an easier way?


comment:12 Changed 5 days ago by charlie

Hi again,

Just to let you know that I have now fixed this problem - not very elegantly, perhaps, but it works. In the end I just created my own list of 332 latitudes going from -90 to 90 (or as close to as possible), and use this in my equation. Obviously my latitudes won't match the original ones exactly, but that doesn't matter because I am simply using them to make the data array. I can then insert my new data array back into the original file, using python, so it maintains all of its original attributes, including latitude.

Thanks very much for your help with this, I'll close the ticket.


comment:13 Changed 5 days ago by charlie

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.