Project

General

Profile

Rotating longitude with CDO

Added by Matt Thompson over 11 years ago

All,

I don't know if this would be possible or not, but it's something I was wondering about. Let's say I had a situation where an NC4 file was created such that the data was output for -180 -> 180 but the lon variable was mistakenly set for 0 -> 360. That is, the data is correct in the file, just the lon variable was incorrectly done somehow.

E.g., I run 'cdo sinfon' on my original file and I see:

   Grid coordinates :
     1 : lonlat       > size      : dim = 16380  nx = 180  ny = 91
                        lon       : first = 0  last = 358  inc = 2  degrees_east  circular
                        lat       : first = -90  last = 90  inc = 2  degrees_north

But I want to have:

   Grid coordinates :
     1 : lonlat       > size      : dim = 16380  nx = 180  ny = 91
                        lon       : first = -180  last = 178  inc = 2  degrees_east  circular
                        lat       : first = -90  last = 90  inc = 2  degrees_north

Is there a way to do that with CDO? I'm pretty sure I could go from -180 -> 180 to 0 -> 360 via "setgrid,r180x91" since CDO assumes lonlat grids are 0 -> 360. But is there a way to "subtract 180" from a coordinate like that?

Thanks,
Matt


Replies (2)

RE: Rotating longitude with CDO - Added by Uwe Schulzweida over 11 years ago

Hi Matt,

You have to create your own grid description file with the following contents:

gridtype  = lonlat
xsize     = 180
ysize     = 91
xfirst    = -180
xinc      = 2
yfirst    = -90
yinc      = 2
Store the above lines in a file (e.g. mygrid) and use this grid description file name instead of the predefined grid description:
cdo setgrid,mygrid ifile ofile

Cheers,
Uwe

RE: Rotating longitude with CDO - Added by Matt Thompson over 11 years ago

Uwe,

Ah. Very nice. Thanks. We're starting to use CDO more extensively here at GMAO at NASA Goddard Space Flight Center, so I'm trying to learn tips and tricks as people start asking for different functions/operations.

Thanks,
Matt

    (1-2/2)