Project

General

Profile

Creating weights for ICON-CH1 regridding

Added by Moritz Wurfbaum 2 months ago

First of all a disclaimer: This is the first time for me working with CDO. Its an amazing tool but cant figure out how to create weights for regridding.

I am trying to regrid grib2 files from the new ICON-CH1 model (Alpine Region). They provide unstructured grid locations in a grib2 file. Right now I'm failing at creating the weights.

My approach:

# Convert the horizontal constants from grib2 to nc
cdo -f nc copy horizontal_constants_ICON-CH1-EPS.grib2 horizontal_constants.nc

# Rename the parameters
ncrename -v param1.191.0,clon -v param2.191.0,clat horizontal_constants.nc

# Create the weights
cdo gennn,grid_definition.txt horizontal_constants.nc weights_horizontal_to_latlon.nc

Warning: Reference to horizontal grid not available!
cdo    gennn (Abort): Reference to source grid not found!

# Dump debug info from nc file
ncdump -h horizontal_constants.nc

netcdf horizontal_constants {
dimensions:
    time = UNLIMITED ; // (1 currently)
    ncells = 1147980 ;
variables:
    double time(time) ;
        time:standard_name = "time" ;
        time:units = "minutes since 2025-3-16 03:00:00" ;
        time:calendar = "proleptic_gregorian" ;
        time:axis = "T" ;
    float clat(time, ncells) ;
        clat:CDI_grid_type = "unstructured" ;
        clat:number_of_grid_in_reference = 1 ;
        clat:institution = "MCH" ;
    float clon(time, ncells) ;
        clon:CDI_grid_type = "unstructured" ;
        clon:number_of_grid_in_reference = 1 ;
        clon:institution = "MCH" ;
[...]
}

Attached all referenced files.

Thank you so much for your help!

grid_definition.txt (121 Bytes) grid_definition.txt Grid definition CH1
horizontal_constants.nc (8.76 MB) horizontal_constants.nc Horizontal constants after conversion and renaming
horizontal_constants_ICON-CH1-EPS.grib2 (4.38 MB) horizontal_constants_ICON-CH1-EPS.grib2 Horizontal constants as provided for CH1

Replies (1)

RE: Creating weights for ICON-CH1 regridding - Added by Guido Cioni 10 days ago

I've been playing around with ICON-CH1 today, and I thin the problem you're facing is due to the way the grid is stored.
In fact, unstructured grids do not play well with GRIB files, and this is the reason why most of the grid files for ICON (e.g. http://icon-downloads.mpimet.mpg.de/mpim_grids.xml, https://opendata.dwd.de/weather/lib/cdo/) are stored in netcdf.
Even when converting the file to netcdf (as you did) tlon and tlat are not recognized as coordinates.

> cdo griddes horizontal_constants_icon-ch1-eps.nc
#
# gridID 1
#
gridtype  = unstructured
gridsize  = 1147980
number    = 1
position  = 1
uuid      = 17643da2-5749-59b6-44d2-54a3cd6e2bc0

which means you'll never be able to use this file directly to remap.

I tried to set them as coordinates in xarray and then write the file again but somehow there is some metadata missing that is preventing CDO from interpreting this as coordinates of the main grid.

This is the closest that I got with ncdump

dimensions:
        ncells = 1147980 ;
variables:
        float tlon(ncells) ;
                tlon:standard_name = "longitude" ;
                tlon:long_name = "Longitude on T grid" ;
                tlon:units = "Degree E" ;
                tlon:CDI_grid_type = "unstructured" ;
                tlon:_FillValue = NaNf ;
                tlon:missing_value = NaNf ;
                tlon:GRIB_paramId = 250004 ;
                tlon:GRIB_dataType = "cp" ;
                tlon:GRIB_numberOfPoints = 1147980 ;
                tlon:GRIB_typeOfLevel = "surface" ;
                tlon:GRIB_stepUnits = 1 ;
                tlon:GRIB_stepType = "instant" ;
                tlon:GRIB_gridType = "unstructured_grid" ;
                tlon:GRIB_NV = 0 ;
                tlon:GRIB_cfName = "unknown" ;
                tlon:GRIB_cfVarName = "tlon" ;
                tlon:GRIB_gridDefinitionDescription = "General unstructured grid" ;
                tlon:GRIB_missingValue = 3.40282346638529e+38 ;
                tlon:GRIB_name = "Longitude on T grid" ;
                tlon:GRIB_shortName = "tlon" ;
                tlon:GRIB_totalNumber = 11 ;
                tlon:GRIB_units = "Degree E" ;
        float tlat(ncells) ;
                tlat:standard_name = "latitude" ;
                tlat:long_name = "Latitude on T grid" ;
                tlat:units = "Degree N" ;
                tlat:CDI_grid_type = "unstructured" ;
                tlat:_FillValue = NaNf ;
                tlat:missing_value = NaNf ;
                tlat:GRIB_paramId = 250003 ;
                tlat:GRIB_dataType = "cp" ;
                tlat:GRIB_numberOfPoints = 1147980 ;
                tlat:GRIB_typeOfLevel = "surface" ;
                tlat:GRIB_stepUnits = 1 ;
                tlat:GRIB_stepType = "instant" ;
                tlat:GRIB_gridType = "unstructured_grid" ;
                tlat:GRIB_NV = 0 ;
                tlat:GRIB_cfName = "unknown" ;
                tlat:GRIB_cfVarName = "tlat" ;
                tlat:GRIB_gridDefinitionDescription = "General unstructured grid" ;
                tlat:GRIB_missingValue = 3.40282346638529e+38 ;
                tlat:GRIB_name = "Latitude on T grid" ;
                tlat:GRIB_shortName = "tlat" ;
                tlat:GRIB_totalNumber = 11 ;
                tlat:GRIB_units = "Degree N" ;

// global attributes:
                :CDI = "Climate Data Interface version 2.4.2 (https://mpimet.mpg.de/cdi)" ;
                :Conventions = "CF-1.7" ;
                :institution = "Zurich" ;
                :GRIB_centre = "lssw" ;
                :GRIB_centreDescription = "Zurich" ;
                :history = "Sun May 18 11:10:10 2025: cdo setgrid,icon_unstructred.griod horizontal_constants_icon-ch1-eps.nc horizontal_constants_icon-ch1-eps_fixed.nc\n2025-05-18T11:07 GRIB to CDM+CF via cfgrib-0.9.15.0/ecCodes-2.41.0 with {\"source\": \"Users/guidocioni/Downloads/horizontal_constants_icon-ch1-eps.grib2\", \"filter_by_keys\": {}, \"encode_cf\": [\"parameter\", \"time\", \"geography\", \"vertical\"]}" ;
                :coordinates = "tlat tlon" ;
                :CDO = "Climate Data Operators version 2.4.2 (https://mpimet.mpg.de/cdo)" ;
}

but CDO still does not recognize this is a proper grid.
It would be good if someone from the CDO team could chime in and explain which metadata are needed to make CDO recognize tlon and tlat as coordinates for the main grid in the file so that it can be used for remapping or anything else.

    (1-1/1)