cdo: map from regular Gaussian to curvilinear grid
Added by Jia Wang 8 months ago
I try to map data from a regular Gaussian to a curvilinear grid.
This is my command:
cdo remapbil,target.grb aa.grb bb.grb
This is the warning message:
cdi warning (cgribexDefGrid): CGRIBEX library doesn't support generic grids, grid information will be lost!
But the source file "aa.grb" is on a regular Gaussian grid. This is the output from cdo grids:
gridtype = gaussian
gridsize = 13107200
xsize = 5120
ysize = 2560
xname = lon
xlongname = "longitude"
xunits = "degrees_east"
yname = lat
ylongname = "latitude"
yunits = "degrees_north"
numLPE = 1280
xfirst = 0
xinc = 0.0703125
yvals =
The target grid file "target.grb" is on a curvilinear grid:
gridtype = projection
gridsize = 987601
xsize = 1121
ysize = 881
xname = x
xunits = "m"
yname = y
yunits = "m"
xfirst = 0
xinc = 4762.5
yfirst = 0
yinc = 4762.5
grid_mapping = Polar_Stereographic
grid_mapping_name = polar_stereographic
standard_parallel = 60.
straight_vertical_longitude_from_pole = 255.
latitude_of_projection_origin = 90.
earth_radius = 6371200.
false_easting = 1902531.67435698
false_northing = 7617604.93005048
longitudeOfFirstGridPointInDegrees = 240.976992
latitudeOfFirstGridPointInDegrees = 23.117
The output file "bb.grb" does not have the correct grid information. This is the output from cdo griddes bb.grb
gridtype = generic
gridsize = 987601
Replies (12)
RE: cdo: map from regular Gaussian to curvilinear grid - Added by Karin Meier-Fleischer 7 months ago
Hi Jia,
without the data file its not really possible to help.
I made a simple test with the topo data on a regular gaussian grid and it works as expected. The file target.txt contains your target grid description from above.
cdo -f nc -remapbil,F180 -topo topo_gaussianF180.nc cdo remapbil,target.txt topo_gaussianF180.nc outfile.nc
RE: cdo: map from regular Gaussian to curvilinear grid - Added by Jia Wang 7 months ago
Hi, Karin,
I have attached the data files.
These are the steps I did:
cdo griddes target_grid.grb > target.txt
cdo remapbil,target.txt -setgridtype,regular org.grb out.grb
This is the output from the last command:
cdo(1) setgridtype: Process started
cdo remapbil: Bilinear weights from gaussian (1616x800) to projection (1121x881) grid
cdi warning (cgribexDefGrid): CGRIBEX library doesn't support generic grids, grid information will be lost!
cdo remapbil: Processed 24563200 values from 1 variable over 19 timesteps [2.06s 293MB]
The output has no grid information, using the command "cdo griddes out.grb ":
gridtype = generic
gridsize = 987601
cdo griddes: Processed 1 variable [0.05s 27MB]
target_grid.grb (199 KB) target_grid.grb | |||
target.txt (563 Bytes) target.txt | |||
org.grb (35.6 MB) org.grb | |||
out.grb (53.7 MB) out.grb |
RE: cdo: map from regular Gaussian to curvilinear grid - Added by Karin Meier-Fleischer 7 months ago
Try
cdo -f nc -remapbil,target.txt -setgridtype,regular org.grb outfile.nc
RE: cdo: map from regular Gaussian to curvilinear grid - Added by Jia Wang 7 months ago
It works now. Thanks a lot.
But why it is not working when the output is in the grib format?
RE: cdo: map from regular Gaussian to curvilinear grid - Added by Karin Meier-Fleischer 7 months ago
I don't know why it is not working for GRIB1 output format, but for GRIB2 output format it works
cdo -f grb2 -remapbil,target.txt -setgridtype,regular org.grb outfile.grb2
RE: cdo: map from regular Gaussian to curvilinear grid - Added by Karin Meier-Fleischer 7 months ago
I guess that the grid type projection is only available for GRIB2 files.
RE: cdo: map from regular Gaussian to curvilinear grid - Added by Jia Wang 7 months ago
I have tried these two ways:
1st:
cdo -f nc -remapcon,target.txt -setgridtype,regular org.grb aa.nc
2nd:
cdo -f grb2 -remapbil,target.txt -setgridtype,regular org.grb outfile.grb
cdo -f nc copy outfile.grb bb.nc
Then I found out that there are differences in aa.nc and bb.nc.
Which way could better preserve the precision?
RE: cdo: map from regular Gaussian to curvilinear grid - Added by Karin Meier-Fleischer 7 months ago
They are different because you use different interpolation methods. See remapbil https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf#subsection.2.12.1, https://en.wikipedia.org/wiki/Bilinear_interpolation, and for remapcon https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf#subsection.2.12.5, https://journals.ametsoc.org/view/journals/mwre/127/9/1520-0493_1999_127_2204_fasocr_2.0.co_2.xml.
RE: cdo: map from regular Gaussian to curvilinear grid - Added by Jia Wang 7 months ago
My mistake.
But even if I use the same interpolation method, there are still some differences:
Date Time Level Gridsize Miss Diff : S Z Max_Absdiff Max_Reldiff : Parameter ID
1 : 2024-01-29 12:00:00 0 987601 0 505282 : F T 3.7253e-09 0.49929 : 228.128
2 : 2024-01-30 00:00:00 0 987601 0 432881 : F T 3.7253e-09 0.49927 : 228.128
3 : 2024-01-30 12:00:00 0 987601 0 967290 : T T 3.7253e-09 0.99988 : 228.128
RE: cdo: map from regular Gaussian to curvilinear grid - Added by Karin Meier-Fleischer 7 months ago
This may be due to the different precision when writing the data to the corresponding format.
RE: cdo: map from regular Gaussian to curvilinear grid - Added by Jia Wang 7 months ago
Which way would better preserve the precision?
RE: cdo: map from regular Gaussian to curvilinear grid - Added by Karin Meier-Fleischer 7 months ago
I recommend to use the direct way to generate the output file format without copy.