Project

General

Profile

ROMS roms_grd.nc netcdf grids not recognised by CDO, labelled "generic"

Added by Scott Rowe over 12 years ago

Hello,

I am trying to use a grid defined in a roms_grd.nc file to regrid some data to this grid. The problem is I cannot for the life of me work out why CDO refuses to recognise the grids in the file. They appear to conform to the CF convention - Panoply can succesfully display the data on these grids and it is usually quite picky about the convention.

Clues: The output of cdo sinfo roms_grd.nc is:

Horizontal grids :
1 : generic > size : dim = 30351 nx = 201 ny = 151
2 : generic > size : dim = 30200 nx = 200 ny = 151
3 : generic > size : dim = 30150 nx = 201 ny = 150
4 : generic > size : dim = 30000 nx = 200 ny = 150

The ncdump -h of roms_grd.nc is:

@netcdf roms_grd {
dimensions:
xi_u = 200 ;
eta_u = 151 ;
xi_v = 201 ;
eta_v = 150 ;
xi_rho = 201 ;
eta_rho = 151 ;
xi_psi = 200 ;
eta_psi = 150 ;
one = 1 ;
two = 2 ;
four = 4 ;
bath = 1 ;

variables:
double xl(one) ;
xl:long_name = "domain length in the XI-direction" ;
xl:units = "meter" ;
double el(one) ;
el:long_name = "domain length in the ETA-direction" ;
el:units = "meter" ;
double depthmin(one) ;
depthmin:long_name = "Shallow bathymetry clipping depth" ;
depthmin:units = "meter" ;
double depthmax(one) ;
depthmax:long_name = "Deep bathymetry clipping depth" ;
depthmax:units = "meter" ;
char spherical(one) ;
spherical:long_name = "Grid type logical switch" ;
spherical:option_T = "spherical" ;
double angle(eta_rho, xi_rho) ;
angle:long_name = "angle between xi axis and east" ;
angle:units = "degree" ;
double h(eta_rho, xi_rho) ;
h:long_name = "Final bathymetry at RHO-points" ;
h:coordinates = "lon_rho lat_rho" ;
h:units = "meter" ;
double hraw(bath, eta_rho, xi_rho) ;
hraw:long_name = "Working bathymetry at RHO-points" ;
hraw:units = "meter" ;
double alpha(eta_rho, xi_rho) ;
alpha:long_name = "Weights between coarse and fine grids at RHO-points" ;
double f(eta_rho, xi_rho) ;
f:long_name = "Coriolis parameter at RHO-points" ;
f:units = "second-1" ;
double pm(eta_rho, xi_rho) ;
pm:long_name = "curvilinear coordinate metric in XI" ;
pm:units = "meter-1" ;
double pn(eta_rho, xi_rho) ;
pn:long_name = "curvilinear coordinate metric in ETA" ;
pn:units = "meter-1" ;
double dndx(eta_rho, xi_rho) ;
dndx:long_name = "xi derivative of inverse metric factor pn" ;
dndx:units = "meter" ;
double dmde(eta_rho, xi_rho) ;
dmde:long_name = "eta derivative of inverse metric factor pm" ;
dmde:units = "meter" ;
double x_rho(eta_rho, xi_rho) ;
x_rho:long_name = "x location of RHO-points" ;
x_rho:units = "meter" ;
double x_u(eta_u, xi_u) ;
x_u:long_name = "x location of U-points" ;
x_u:units = "meter" ;
double x_v(eta_v, xi_v) ;
x_v:long_name = "x location of V-points" ;
x_v:units = "meter" ;
double x_psi(eta_psi, xi_psi) ;
x_psi:long_name = "x location of PSI-points" ;
x_psi:units = "meter" ;
double y_rho(eta_rho, xi_rho) ;
y_rho:long_name = "y location of RHO-points" ;
y_rho:units = "meter" ;
double y_u(eta_u, xi_u) ;
y_u:long_name = "y location of U-points" ;
y_u:units = "meter" ;
double y_v(eta_v, xi_v) ;
y_v:long_name = "y location of V-points" ;
y_v:units = "meter" ;
double y_psi(eta_psi, xi_psi) ;
y_psi:long_name = "y location of PSI-points" ;
y_psi:units = "meter" ;
double lon_rho(eta_rho, xi_rho) ;
lon_rho:long_name = "longitude of RHO-points" ;
lon_rho:units = "degree_east" ;
double lon_u(eta_u, xi_u) ;
lon_u:long_name = "longitude of U-points" ;
lon_u:units = "degree_east" ;
double lon_v(eta_v, xi_v) ;
lon_v:long_name = "longitude of V-points" ;
lon_v:units = "degree_east" ;
double lon_psi(eta_psi, xi_psi) ;
lon_psi:long_name = "longitude of PSI-points" ;
lon_psi:units = "degree_east" ;
double lat_rho(eta_rho, xi_rho) ;
lat_rho:long_name = "latitude of RHO-points" ;
lat_rho:units = "degree_north" ;
double lat_u(eta_u, xi_u) ;
lat_u:long_name = "latitude of U-points" ;
lat_u:units = "degree_north" ;
double lat_v(eta_v, xi_v) ;
lat_v:long_name = "latitude of V-points" ;
lat_v:units = "degree_north" ;
double lat_psi(eta_psi, xi_psi) ;
lat_psi:long_name = "latitude of PSI-points" ;
lat_psi:units = "degree_north" ;
double mask_rho(eta_rho, xi_rho) ;
mask_rho:long_name = "mask on RHO-points" ;
mask_rho:option_0 = "land" ;
mask_rho:option_1 = "water" ;
double mask_u(eta_u, xi_u) ;
mask_u:long_name = "mask on U-points" ;
mask_u:option_0 = "land" ;
mask_u:option_1 = "water" ;
double mask_v(eta_v, xi_v) ;
mask_v:long_name = "mask on V-points" ;
mask_v:option_0 = "land" ;
mask_v:option_1 = "water" ;
double mask_psi(eta_psi, xi_psi) ;
mask_psi:long_name = "mask on PSI-points" ;
mask_psi:option_0 = "land" ;
mask_psi:option_1 = "water" ;

// global attributes:
:title = "BOSTON" ;
:date = "29-Mar-2012" ;
:type = "ROMS grid file" ;
}@

Final clue:

Running ncdump roms_grd.nc > roms_grd.cdl; ncgen -o test.nc roms_grd.cdl

produces a test.nc that cannot be read by cdo:

cdo sinfo: Open failed on >test.nc<
Unsupported file type

The roms_grd.nc file is attached.


Replies (2)

RE: ROMS roms_grd.nc netcdf grids not recognised by CDO, labelled "generic" - Added by Scott Rowe over 12 years ago

To reply to myself in case anyone else needs to know, cdo seems to be become confused with all the other variables and grids. The workaround is to extract just one variable, in this case h, that uses the grid you would like to be recognised. I do this with ncks, eg

ncks -v h,lon_rho,lat_rho -o rho_grid.nc roms_grd.nc

cdo then sees the grid correctly:

cdo sinfo rho_grid.nc

File format: netCDF
-1 : Institut Source Param Time Typ Grid Size Num Levels Num
1 : unknown unknown -1 con F64 30351 1 1 1
Horizontal grids :
1 : curvilinear > size : dim = 30351 nx = 201 ny = 151
lon_rho : min = -80 max = -30 degree_east
lat_rho : min = 20 max = 50.0376852 degree_north
available : xvals yvals
Vertical grids :
1 : surface : 0

RE: ROMS roms_grd.nc netcdf grids not recognised by CDO, labelled "generic" - Added by Johannes Röhrs over 12 years ago

Hi Scott!

I could solve the problem of the cdo not recognizing my grid by setting an attribute to a variables which tells the cdo which the grid is:

ncatted -a coordinates,h,c,c,"lon_rho lat_rho" ROMSGrid.nc

this seems to tell the cdo that the variable h has coordinates lon_rho and lat_rho

ncdump -h then gives:

dimensions:
    x = 1106 ;
    y = 501 ;
variables:
    double lon_rho(y, x) ;
        lon_rho:long_name = "longitude of RHO-points" ;
        lon_rho:units = "degree_east" ;
    double lat_rho(y, x) ;
        lat_rho:long_name = "latitude of RHO-points" ;
        lat_rho:units = "degree_north" ;
    double h(y, x) ;
        h:long_name = "Final bathymetry at RHO-points" ;
        h:units = "meter" ;
        h:field = "bath, scalar" ;
        h:coordinates = "lon_rho lat_rho" ;

    (1-2/2)