unstructured netcdf file not compatible with CDO
Added by Paolo Davini almost 3 years ago
Hi all,
I have a python-based tool that via xarray creates a NetCDF file which then need must be processed by CDO. I can easily play with attributes and properties of the file since I am creating it via python, and in most of the situation I can get it through. However, the following file - a 3D oceanic mask - does not seems to be compatible with CDO (I tried version 2.2.0 through mamba). I guess there is something in CF-compliant file structure which I am missing.
The netcdf look like this:
netcdf bounds {
dimensions:
cell = 120184 ;
bnds = 4 ;
lev = 75 ;
variables:
double lon(cell) ;
lon:standard_name = "longitude" ;
lon:units = "degrees East" ;
lon:bounds = "lon_bnds" ;
double lat(cell) ;
lat:standard_name = "latitude" ;
lat:units = "degrees North" ;
lat:bounds = "lat_bnds" ;
double lat_bnds(cell, bnds) ;
double lon_bnds(cell, bnds) ;
double lev(lev) ;
lev:standard_name = "Depth" ;
lev:units = "m" ;
double tmask(lev, cell) ;
tmask:_FillValue = NaN ;
tmask:coordinates = "lev lat lon" ;
Indeed, every CDO operations ends with:
cdi warning (cdfInqContents): Coordinates variable lev can't be assigned!
cdi warning (cdf_read_ycoord): Unsupported array structure, skipped variable tmask!
cdi warning (cdfInqContents): No data arrays found!
cdo sinfo: Open failed on >Desktop/bounds.nc<
Unsupported file structure
The file is quite big, but if it is not something trivial I can try to produce a subsample of it...
many thanks!
Paolo
Replies (5)
RE: unstructured netcdf file not compatible with CDO - Added by Karin Meier-Fleischer almost 3 years ago
Hi Paolo,
the warning says that something is wrong assigning lev at some point. I guess you have to change the tmask coordinates attribute to
coordinates = "lat lon"
RE: unstructured netcdf file not compatible with CDO - Added by Paolo Davini almost 3 years ago
Thanks Karin,
if I remove the lev from the coordinate, you are right, the warning disappear. However, the `unsupported array structure` remains :-(
cdi warning (cdf_read_ycoord): Unsupported array structure, skipped variable tmask!
cdi warning (cdfInqContents): No data arrays found!
cdo sinfo: Open failed on >bounds.nc<
Unsupported file structure
I suspect the issue is somewhere else... I created a sample file, you can find here attached in case you want to check yourself! Thanks again
RE: unstructured netcdf file not compatible with CDO - Added by Karin Meier-Fleischer almost 3 years ago
The attribute grid_type has to be set to unstructured:
ncatted -a grid_type,tmask,c,c,"unstructured" bounds.nc
RE: unstructured netcdf file not compatible with CDO - Added by Uwe Schulzweida almost 3 years ago
The problem here is that the content of the attribute lev:standard_name is not recognized by CDO. If you change this to lowercase it works without problems:
ncatted -a standard_name,lev,m,c,"depth" bounds.nc
RE: unstructured netcdf file not compatible with CDO - Added by Paolo Davini almost 3 years ago
Many thanks! Both the suggestions are great, in this way CDO can deal with the data.