Project

General

Profile

shifting longitudes on grid

Added by Rob Nicholas almost 14 years ago

Suppose I have a file with a regular half-degree lat-lon grid where the longitudes run from +0.25 to +359.75. How can I use CDO to "shift" the grid such that the longitudes run from -179.75 to +179.75? The conservative remapping operator sort of works but seem to introduce small errors that I'd rather avoid. Any suggestions?

Thanks,
Rob


Replies (4)

RE: shifting longitudes on grid - Added by Uwe Schulzweida almost 14 years ago

You can use the CDO function sellonlatbox also for shifting the longitudes if you have a global regular grid.
To shift the longitudes of any global regular grid to the range -180 to 180 degrees, use:

cdo sellonlatbox,-180,180,-90,90 ifile ofile

There is no interpolation involved. The data values are unchanged, only the position of the values in the array is changed!

Best regards,
Uwe

RE: shifting longitudes on grid - Added by Rob Nicholas almost 14 years ago

Great! That solves the more difficult of my two cases.

Can you recommend a way to do this for regular grids that are NOT global? My current hack for regional datasets is to use NCL to rewrite the values in the longitude variable and dimension, which is sufficient so long as the grid crosses neither the prime meridian nor the date line.

~Rob

RE: shifting longitudes on grid - Added by Uwe Schulzweida almost 14 years ago

Hi Rob,

you can do a 360 degree shift of the longitudes by overwriting the grid description with setgrid if you have a regular lonlat grid which crosses neither the prime meridian nor the date line:

cdo griddes ifile > mygrid
edit mygrid and set xfirst to the new value
cdo setgrid,mygrid ifile ofile

Regards,
Uwe

RE: shifting longitudes on grid - Added by Miriam Ferrer Gonzalez over 8 years ago

Hi,

Is there any way to shift longitudes for an irregular grid?

Thanks,
Miriam

    (1-4/4)