Project

General

Profile

Unsupported generic grid

Added by Miles Sowden over 5 years ago

I think my problem is similar to https://code.mpimet.mpg.de/boards/1/topics/6491 (and others). I took satellite data and cropped it to a region but both the original file and my cropped version are simply listed as generic grid types, despite ncks returning grid projection (see note below)

I want to smooth the data (and other functions) but I get an unsupported generic grid error warning and smooth9 runs but doesn't change anything.
In my example file, smooth9 should return 0 over the sea, 1 over land, and somewhere in between along the coastline (within 9 points of the land/sea)
Running cdo griddes infile returns a generic grid type and 451 x 351 points on the grid.
I tried editing the text file to change generic to regular and then cdo setgrid,desc.txt in.nc out.nc and even cdo setgridtype,regular in.nc out.nc but it failed.

What do I need to do to change the generic grid type to a supported grid type?

Thanks

Side note ncdump on original file returned.
geostationary ;
geostationary:proj4 = "+proj=geos +lon_0=140.7 +h=35785863 +x_0=0 +y_0=0 +a=6378137 +b=6356752.3 +units=m +no_defs " ;
geostationary:proj_name = "GEOS141" ;
geostationary:grid_mapping_name = "geostationary" ;
geostationary:longitude_of_projection_origin = 140.7 ;
geostationary:perspective_point_height = 35785863. ;
geostationary:satellite_height = 35785863. ;
geostationary:semi_major_axis = 6378137. ;
geostationary:semi_minor_axis = 6356752.3 ;
geostationary:sweep_angle_axis = "y" ;
geostationary:GeoTransform = -5500000., 2000., 0., 5500000., 0., -2000. ;
geostationary:spatial_ref = "PROJCS[\"unnamed\",GEOGCS[\"unnamed ellipse\",DATUM[\"unknown\",SPHEROID[\"unnamed\",6378137,298.2570248822722]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Geostationary_Satellite\"],PARAMETER[\"central_meridian\",140.7],PARAMETER[\"satellite_height\",35785863],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0]]" ;

and it was cropped with ncks '-d x,1400,1850 -d y,3700,4050' orig.nc crop.nc

land.nc (632 KB) land.nc land/sea mask

Replies (6)

RE: Unsupported generic grid - Added by Ralf Mueller over 5 years ago

I can confirm the behavior with cdo-1.9.5. In your uploaded file there is information about the projection only in the global attributes. I don't think this is CF-compliant. So I doubt that CDO can help you with that.

You could woth with numpy and implement a smoothing by something like a 2d-convolution. Or you keep the pixels as real image pixels and try to smooth it with an image processing toolkit like ImageMagick or GMIC

hth
ralf

RE: Unsupported generic grid - Added by Miles Sowden over 5 years ago

Thanks Ralf,
Unfortunately smoothing the land sea file is only a first step and I have multiple files to process.
I'm surprised with the restriction as it is a regular grid so smoothing based on the index positions should be possible.

RE: Unsupported generic grid - Added by Ralf Mueller over 5 years ago

I see it the same way - I expect at least smooth9 to work.

sorry that I cannot help you at the moment.

RE: Unsupported generic grid - Added by Miles Sowden over 5 years ago

Marking the answer as closed for now. The problem is in the code. A generic grid is not supported. If anyone knows a workaround please shout.

in Setgrid.c it needs the added line (line 50 in yesterday's build)

if      ( strcmp(gridname, "curvilinear") == 0 )   gridtype = GRID_CURVILINEAR;
else if ( strcmp(gridname, "cell") == 0 ) gridtype = GRID_UNSTRUCTURED;
else if ( strcmp(gridname, "unstructured") == 0 ) gridtype = GRID_UNSTRUCTURED;
else if ( strcmp(gridname, "dereference") == 0 ) ldereference = 1;
else if ( strcmp(gridname, "lonlat") == 0 ) gridtype = GRID_LONLAT;
else if ( strcmp(gridname, "gaussian") == 0 ) gridtype = GRID_GAUSSIAN;
else if ( strcmp(gridname, "regular") == 0 ) {gridtype = GRID_GAUSSIAN; lregular = 1;}
else if ( strcmp(gridname, "generic") == 0 ) {gridtype = GRID_GENERIC; lregular = 1;}
else cdoAbort("Unsupported grid name: %s", gridname);

Line 250 indicates that GRID_GENERIC is at least defined in some part of the code so I suspect the indented code just needs to be added
then in Smooth9.nc add or gridtype = generic to line 79

for ( varID = 0; varID < nvars; ++varID )
  {
gridID = vlistInqVarGrid(vlistID1, varID);
gridtype = gridInqType(gridID);
if ( gridtype GRID_GAUSSIAN ||
gridtype GRID_LONLAT ||
gridtype GRID_CURVILINEAR ||
gridtype GRID_GENERIC )

Unfortunately, it's not compiling so I can't verify that this fixes the problems.

RE: Unsupported generic grid - Added by Miles Sowden over 5 years ago

I fixed it in my code (cdo-1.9.5), and tested that it's working.

need to add the "or grid_generic"

if (gridtype  GRID_GAUSSIAN || gridtype  GRID_LONLAT || gridtype  GRID_CURVILINEAR || gridtype  GRID_GENERIC )

and if this fails, warn not crash out, with the gridtype and set varIDs as true not false and take your chances with the unsupported grid

else
  {
char varname[CDI_MAX_NAME];
vlistInqVarName(vlistID1, varID, varname);
varIDs[varID] = true;
cdoWarning("Unsupported grid for variable %s", varname, "grid type is ",gridtype );
}

Ran my test file and I now have a coastline from the land/sea mask

cdo sub -smooth9 land.nc land.nc delta.nc

RE: Unsupported generic grid - Added by Uwe Schulzweida over 5 years ago

Thanks for your patch, it will be available in the next CDO release!

Cheers,
Uwe

    (1-6/6)