Project

General

Profile

cdo gencon fails due to target grid description

Added by Alexander Robinson about 3 years ago

Hi,

I am trying to generate conservative mapping weights to map from a latlon grid to a polar stereographic projection. I am using the following commands:

# Generate the source grid description file
cdo griddes grid_CMN-5x5.nc > grid_CMN-5x5.txt

# Generate the target grid description file
cdo griddes grid_NH-40KM.nc > grid_NH-40KM.txt

# Generate the map weights
cdo gencon,grid_NH-40KM.txt -setgrid,grid_CMN-5x5.txt grid_CMN-5x5.nc scrip_CMN-5x5_NH-40KM.nc

I get the error:

cdo    gencon (Abort): Target grid cell corner coordinates missing!

Since the source and target grid description files were generated by cdo, I am surprised it isn't working. Is there something wrong with my grid(s) as defined in the netcdf files?

I would be very grateful for any help you could provide. I have attached all relevant files.

Best regards and many thanks!
Alex

grid_CMN-5x5.txt (346 Bytes) grid_CMN-5x5.txt Source grid description file
grid_CMN-5x5.nc (32.2 KB) grid_CMN-5x5.nc Source grid file
grid_NH-40KM.txt (3.7 MB) grid_NH-40KM.txt Target grid description file
grid_NH-40KM.nc (4.12 MB) grid_NH-40KM.nc Target grid file
runcdo.sh (306 Bytes) runcdo.sh Script to perform cdo calls

Replies (4)

RE: cdo gencon fails due to target grid description - Added by Ralf Mueller about 3 years ago

hi Alexander!

your target grid file does not provide cell corners, hence CDO cannot

  • compute the area of each cell (I know this is given as an extra variable)
  • compute overlaps with the input cells to calculate the area fractions of all input cells for the specific target grid cell

CF-conformant files provide additional coordinate variables and attach those to the coordinated with the bounds attribute

CDO has problems with your grid descriptions:

cdo verifygrid grid_CMN-5x5.nc
Warning (cdfInqContents): Coordinates variable lat can't be assigned!
Warning (cdfInqContents): Coordinates variable lon can't be assigned!
Warning (cdfInqContents): Coordinates variable lat can't be assigned!
Warning (cdfInqContents): Coordinates variable lon can't be assigned!

cdo    verifygrid (Abort): Projection type >latitude_longitude< unsupported!
cdo verifygrid grid_NH-40KM.nc
Warning (cdf_set_var): Inconsistent variable definition for lon2D!
Warning (cdf_set_var): Inconsistent variable definition for lat2D!
cdo    verifygrid: Grid consists of 97969 (313x313) cells (type: curvilinear), of which
cdo    verifygrid (Warning): Grid cell corner coordinates missing!
cdo    verifygrid:      lon2D : -179.9981 to 179.9949 degrees
cdo    verifygrid:      lat2D : 18.93623 to 90 degrees
cdo    verifygrid: Processed 4 variables [0.01s 46MB].

Additionally:

  • the projection in the input file does not seem to be needed
  • the coordinates do not have useful units ("degrees" must be ether degrees_east or degrees_north)

some helpful commands to clean up the input

  ncatted -a coordinates,border,d,, grid_CMN-5x5.nc
  ncatted -a coordinates,area,d,, grid_CMN-5x5.nc
  ncatted -a units,lon,m,c,'degrees_east' grid_CMN-5x5.nc
  ncatted -a units,lat,m,c,'degrees_north' grid_CMN-5x5.nc

but still: without target cell corners conservative remapping will not be possible. other methods do work, e.g. bilinear (genbil).

RE: cdo gencon fails due to target grid description - Added by Ralf Mueller about 3 years ago

you don't need to generat text files with the griddes operator. Instead use the plain netcdf files - CDO takes the first grid from those files as input

cdo genbil,grid_NH-40KM.nc grid_CMN-5x5.nc scrip_CMN-5x5_NH-40KM.nc

RE: cdo gencon fails due to target grid description - Added by Alexander Robinson about 3 years ago

Dear Ralf,

Thanks for the clear response, that has helped me improve my process substantially. I still have a remaining doubt however. Following your suggestions, I have cleaned grid attributes and I can successfully generate eg bilinear weights with the more straightforward command:

cdo genbil,grid_NH-40KM.nc grid_CMN-5x5.nc scrip-con_CMN-5x5_NH-40KM.nc

And I can successfully reproduce the conservative mapping error as expected:

cdo gencon,grid_NH-40KM.nc grid_CMN-5x5.nc scrip-con_CMN-5x5_NH-40KM.nc

>>> cdo    gencon (Abort): Target grid cell corner coordinates missing!

The remaining doubt is that when I generate a simple grid description file on my own (not using cdo) as attached in .txt files, then conservative mapping is completely successful:

cdo gencon,grid_NH-40KM.txt -setgrid,grid_CMN-5x5.txt grid_CMN-5x5.nc scrip_CMN-5x5_NH-40KM.nc

It only fails when I use the simple gencon command you proposed, or when I specify grid description files generated by cdo. I wonder, what is happening here?

Thanks again!
Alex

grid_CMN-5x5.txt (408 Bytes) grid_CMN-5x5.txt Source grid description file (made by hand)
grid_CMN-5x5.nc (31.9 KB) grid_CMN-5x5.nc Source grid file
grid_NH-40KM.txt (580 Bytes) grid_NH-40KM.txt Target grid description file (made by hand)
runcdo.sh (614 Bytes) runcdo.sh Script to perform cdo calls
grid_NH-40KM.nc (4.12 MB) grid_NH-40KM.nc Target grid file

RE: cdo gencon fails due to target grid description - Added by Alexander Robinson about 3 years ago

Of course, that is to say I am happy that it succeeded, as it is convenient not to have to define the grid borders when they are already clear from the grid definition. But it is surprising...

    (1-4/4)