Project

General

Profile

Remap files with curvlinear projection

Added by Trond Kristiansen about 10 years ago

Hi. I have to remap a number of my files (ROMS ocean model output files) from their curvlinear projection to a rectangular one. The problem is that the geographical information is stored as variables and not as dimensions so CDO does not understand how to interpret the grid information. My dimensions looks like this:

dimensions:
x = 250 ;
y = 200 ;
depth = 26 ;
time = UNLIMITED ; // (1 currently)

My variables with the grid projection information is stored as variables:

variables:
float lat(y, x) ;
lat:units = "degrees_north" ;
lat:standard_name = "latitude" ;
lat:long_name = "latitude" ;
lat:axis = "Y" ;
float lon(y, x) ;
lon:units = "degrees_east" ;
lon:standard_name = "longitude" ;
lon:long_name = "longitude" ;
lon:axis = "X" ;

Is there any way I can make CDO read my variables to define the grid projection? Currently I get the following error message:

cdo genbil,r360x180 test.nc test_wgts.nc
cdo genbil (Abort): Unsupported grid type: generic

Any suggestions for how to solve this problem is greatly appreciated. Cheers, Trond

Replies (12)

RE: Remap files with curvlinear projection - Added by Jaison-Thomas Ambadan about 10 years ago

you may use the NCO operators to rename the attributes/dimension and then use CDO. Here are some examples using NCO operators: http://www.unidata.ucar.edu/software/netcdf/workshops/2008/utilities/Nco.html

RE: Remap files with curvlinear projection - Added by Jaison-Thomas Ambadan about 10 years ago

I just realized that the above link doesn't provide an example for your purpose; use ncrename to rename dimension/variables http://jisao.washington.edu/data/nco/#example7

RE: Remap files with curvlinear projection - Added by Trond Kristiansen about 10 years ago

Hi.

Thanks for your reply. I did as you suggested and I converted the dimensions to :

dimensions:
longitude = 250 ;
latitude = 200 ;
depth = 26 ;
time = UNLIMITED ; // (1 currently)

And my variables:

float latitude(latitude, longitude) ;
latitude:units = "degrees_north" ;
latitude:standard_name = "latitude" ;
latitude:long_name = "latitude" ;
latitude:axis = "Y" ;
float longitude(latitude, longitude) ;
longitude:units = "degrees_east" ;
longitude:standard_name = "longitude" ;
longitude:long_name = "longitude" ;
longitude:axis = "X" ;

However, I still get the error message.

cdo genbil,r4320x2160 test.nc test_wgts.nc
cdo genbil (Abort): Unsupported grid type: generic

Is there a variable or dimension that I need to add to get this to work? Thanks! Cheers, Trond

RE: Remap files with curvlinear projection - Added by Jaison-Thomas Ambadan about 10 years ago

Currently, CDO doesn't support generic dimension names such as depth. CDO only suport classic NetCDF (time, lev, lat, lon). If you replace depth with lev (level), it should work.

RE: Remap files with curvlinear projection - Added by Jaison-Thomas Ambadan about 10 years ago

Also, time dimension has to be the first dimension for variables (if not, you can use ncpdq to reorder)

RE: Remap files with curvlinear projection - Added by Trond Kristiansen about 10 years ago

Thanks. I still cant' get this to work. I have changed all of the variables and dimensions to lat, lon, time, and lev. When I run
cdo sinfo out.nc I get the following information:

cdo sinfo out.nc

File format: netCDF
-1 : Institut Source Ttype Levels Num Gridsize Num Dtype : Parameter ID
1 : unknown IMR, instant 26 1 50000 1 I16 : -1
2 : unknown IMR, instant 26 1 50000 1 I16 : -2
3 : unknown IMR, instant 26 1 50000 1 I16 : -3
4 : unknown IMR, instant 26 1 50000 1 I16 : -4
5 : unknown IMR, constant 1 2 50000 1 F32 : -5
6 : unknown IMR, constant 1 2 50000 1 F32 : -6
Grid coordinates :
1 : generic > size : dim = 50000 nx = 250 ny = 200
Vertical coordinates :
1 : depth_below_sea m : 3000 2750 2500 2250 2000 1750 1500 1250 1000 800
700 600 500 400 300 250 200 150 100 75 50 30 20
10 5 0
2 : surface : 0
Time coordinate : 1 step
RefTime = 1948-01-01 00:00:00 Units = days Calendar = standard
YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss
2009-12-09 12:00:00
cdo sinfo: Processed 6 variables over 1 timestep ( 0.03s )

And my command for remapping fails:

cdo genbil,r360x180 out.nc out2.nc
cdo genbil (Abort): Unsupported grid type: generic

I really don't understand this. I have used remapping so many times without any problems until now. Suggestions are very welcome! Thanks. T.

RE: Remap files with curvlinear projection - Added by Jaison-Thomas Ambadan about 10 years ago

Vertical coordinates :
1 : depth_below_sea m : 3000 2750 2500 2250 2000 1750 1500 1250 1000 800
700 600 500 400 300 250 200 150 100 75 50 30 20
10 5 0
2 : surface : 0

It's probably due to mixed vertical coordinates in the NetCDF (surface, and depth_below_sea). Try selecting a variable, i.e, use -selvar or -select,param= to select a the appropriate variable before remap, like:

cdo genbil,r360x180 -selvar,myvar out.nc out2.nc

If this doesn't work you may upload the file here

RE: Remap files with curvlinear projection - Added by Jaison-Thomas Ambadan about 10 years ago

you may also try:

cdo -genbil,r360x180 -setgridtype,curvilinear out.nc out2.nc

RE: Remap files with curvlinear projection - Added by Trond Kristiansen about 10 years ago

Hi. Thanks for your continued help. I was unable to get this to work, but I did upload my file.

cdo genbil,r360x180 -selvar,vosaline out.nc out2.nc
cdo genbil: Started child process "selvar,vosaline out.nc (pipe1.1)".

cdo genbil (Abort): Unsupported grid type: generic

Thanks! T.

out.nc (10.3 MB) out.nc test file of ROMS output at z-level

RE: Remap files with curvlinear projection - Added by Jaison-Thomas Ambadan about 10 years ago

Sorry I'm running out of ideas - may be Uwe/Ralf can help you with that. As far as I understood the problem is your lat-lon coordinate variables are stored as data variables, and it's not according to CDO grid description of cuvilinear grids (see 1.3.2.3. SCRIP grids and 1.3.2.4. CDO grids). You may try interpolating using NCO bilinear inerpolation http://nco.sourceforge.net/nco.html#Bilinear-interpolation or use NCL to assign the lat-lon coordinates and interpolate. Anyway, I'm still looking for an easy way using CDO ...

RE: Remap files with curvlinear projection - Added by Trond Kristiansen almost 10 years ago

Hi Jaison. Thanks for your help. I am still unable to get this to work. If anyone else has suggestions on how to alter my NetCDF file so that CDO understands its' structure, I would highly appreciate it. Thanks. Cheers, Trond

RE: Remap files with curvlinear projection - Added by Jaison-Thomas Ambadan almost 10 years ago

You may use NCL to generate the equivalent SCRIP grid and use setgrid operator.

Here is an NCL example [I'm not an NCL expert, I just use the example script from http://www.ncl.ucar.edu/Document/Functions/ESMF/curvilinear_to_SCRIP.shtml ] how to generate the SCRIP curvilinear grids:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" 
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" 
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" 
load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" 
;
OutFileName = "scrip_grid.nc" 
;
f     = addfile ("out.nc", "r")
lat2d = f->lat                        
lon2d = f->lon                        
; 
Opt                      = True
Opt@InterpMethod         = "bilinear"     ; default
Opt@ForceOverwrite       = True
Opt@PrintTimings         = True
;
curvilinear_to_SCRIP(OutFileName,lat2d,lon2d,Opt)

This will generate scrip_grid.nc

cdo -f nc -setgrid,scrip_grid.nc out.nc new_out.nc

produce the output file new_out.nc, which you may use it for remapping/regridding using CDO. Attached is a scrip_grid.nc which I generated using your input file and the above script. You could also use NCL for remapping directly without CDO [there are many examples in the NCL webpage]

Cheers,
J

    (1-12/12)