Icosahedral-hexagonal GME grid - how can I get the corresponding longitude-latitude values for each cell?
Added by Julia Kaltenborn over 1 year ago
Hi there,
I have a bunch of sea-level pressure netcdf files on a longitude/latitude grid that I am remapping to an icosahedral-hexagonal grid with cdo.
The relevant command I use is this one here:
cdo remapcon,gme24 "slp_longlat.grib" "slp_icosahedral.grib"
See here for the full shell code I am using: https://github.com/liellnima/icosahedral/blob/main/remap2icosahedral.sh
I am now having files with gme grid coordinates (points=6250, nd=10, ni=24), but I do not understand how these cells are ordered. I would like to be able to assign to each icosahedral-hexagonal cell the corresponding longitude/latitude coordinates (e.g. lon/lat at the middle of each cell). Could you help me to figure out how I could get the lon/lat value for each cell?
I looked into grid_gme.cc code to figure it out on my own but I was a bit lost there because I am still new to cdo
Thank you for your help!
Replies (4)
RE: Icosahedral-hexagonal GME grid - how can I get the corresponding longitude-latitude values for each cell? - Added by Ralf Mueller over 1 year ago
Hi Julia!
the gme grid was developed by DWD I think (https://journals.ametsoc.org/view/journals/mwre/130/2/1520-0493_2002_130_0319_togihg_2.0.co_2.xml) and is part of the GRIB standard becaus GRIB is what all weather services are supposed to use for data exchange.
Thats why the coordinates are not part of the grib file and a simple linking of values and locations is not part of it.
If you want to have that link I recommend switching to netcdf format, where the coordinates are part of the data file (if you stick to the CF-convention). CDO can do this conversion by using a corner-case of the reducegrid
operator. see here for more examples on this.
- create a mask file with your target grid, which is 1 everywhere
cdo const,1,gme24 mask1.grb
- _fake_reduce the input data on this grid with
cdo -f nc reducegrid,mask1.grb data_gme24.grb data_gme24.nc
This will create a CF-conform version of your input data. As a consequence the data is on an unstructured grid, which means tools likenvciew
will not be able to plot it. unfortunately there not many tools to plot data like this
The result should look like this:
netcdf t_gme24 { dimensions: ncells = 6250 ; vertices = 6 ; variables: double lon(ncells) ; lon:standard_name = "longitude" ; lon:long_name = "longitude" ; lon:units = "degrees_east" ; lon:bounds = "lon_bnds" ; double lon_bnds(ncells, vertices) ; double lat(ncells) ; lat:standard_name = "latitude" ; lat:long_name = "latitude" ; lat:units = "degrees_north" ; lat:bounds = "lat_bnds" ; double lat_bnds(ncells, vertices) ; float var1(ncells) ; var1:table = 255 ; var1:CDI_grid_type = "unstructured" ; var1:coordinates = "lat lon" ;
Variable
var1
has coordinates lon
and lat
which are given in the respective coordinate variables in the file. their bounds (cell corners) are saved in lat_bnds
and lon_bnds
.
Another way of getting data values and their coordinates is to use the outputkey
operator:
cdo -outputkey,lon,lat,value data_gme24.grbWill print 3 columns of the corresponding values. So if you prefer working with text rather than netcdf, this might the better choice.
The problem gets a bit worse in case you have an additional time dimension in your input, but let's save this for later ;-)
cheers
ralf
RE: Icosahedral-hexagonal GME grid - how can I get the corresponding longitude-latitude values for each cell? - Added by Ralf Mueller over 1 year ago
Julia Kaltenborn wrote:
Hi there,
I have a bunch of sea-level pressure netcdf files on a longitude/latitude grid that I am remapping to an icosahedral-hexagonal grid with cdo.
The relevant command I use is this one here:
[...]
See here for the full shell code I am using: https://github.com/liellnima/icosahedral/blob/main/remap2icosahedral.sh
WOW - shell scripts with comments, default values and consistent spacing. I really wish more ppl would pay attention to things like u
RE: Icosahedral-hexagonal GME grid - how can I get the corresponding longitude-latitude values for each cell? - Added by Julia Kaltenborn over 1 year ago
Hi Ralf,
Thank you so much for your super helpful response!
The outputkey solution worked perfectly, I used
cdo -outputkey,xind,lon,lat data_gme24.grib
and got exactly the mapping I was looking for.
Your first approach is a bit more elegant though and I think I'd prefer using it like that for the future. I didn't get that running though, I get a "No match for shortName=const" error. Do you know what is going on there?
And thanks for the compliment regarding the shell scripts, glad someone appreciates it
Thank you for your great help!
Julia
RE: Icosahedral-hexagonal GME grid - how can I get the corresponding longitude-latitude values for each cell? - Added by Ralf Mueller over 1 year ago
Hi again!
Glad you have a solution now. For debugging the remaining error, I'd need the real data and the CDO version.
On the other hand we can do this any time you decide to switch from text to netcdf - as you like
Have a nice Monday!
ralf