Project

General

Profile

sellonlatbox flexibility

Added by Jay Su almost 7 years ago

Hello,

When we do spatial subsetting the lon/lat parameters could be positive or negative, no matter the original grid values.

For example, one file has grid lon [-180, 180] and cdo accepts the following:

sellonlatbox,50,-100
sellonlatbox,50,260
sellonlatbox,-150,260
sellonlatbox,260,-150
sellonlatbox,460,-150

I did not find the detailed documentation in the manual. Could you provide us a formal guide?

Thank you,
Jay


Replies (8)

RE: sellonlatbox flexibility - Added by Karin Meier-Fleischer almost 7 years ago

Hi Jay,

the documentation says that lon1 is western longitude and lon2 is eastern longitude:

sellonlatbox,lon1,lon2,lat1,lat2 infile outfile

where

lon1 is FLOAT  Western longitude
lon2 is FLOAT  Eastern longitude
lat1 is FLOAT  Southern or northern latitude
lat2 is FLOAT  Northern or southern latitude

Your example above with longitude units "degrees_east" will generate something like:

lon :   50 to 260  by 2 degrees_east
lon :   50 to 260  by 2 degrees_east
lon :  210 to 260  by 2 degrees_east
lon : -100 to 210  by 2 degrees_east
lon :  100 to 210  by 2 degrees_east

where

longitude -100 is equal to 260
longitude -150 is equal to 210
longitude  460 is equal to 100

lon1:

0 <= 360 = lon
>= 360 = lon - 360
<= 0 = lon + 360

-Karin

RE: sellonlatbox flexibility - Added by Jay Su almost 7 years ago

Thank you Karin,

As mentioned in my first post, the grid of my file has the range -180 < lon < 180. When the input lon = -150, cdo changes it to

1. lon = lon + 360 => 210
2. lon = lon - 180 => 30

Is it true?

Thanks,
Jay

RE: sellonlatbox flexibility - Added by Karin Meier-Fleischer almost 7 years ago

The range of lon1 and lon2 should be max. 360 degrees.

If the range of lon1 and lon2 is between -180 and 180 degrees then NO changes. lon: -180-0 AND lon2: 0-180; lon1 < lon2
If the range of lon1 and lon2 is between    0 and 360 degrees then NO changes. lon:  0-360 AND lon2: 0-360; lon1 < lon2

If lon1 > lon2 then lon2 will be set to lon2+360

-Karin

RE: sellonlatbox flexibility - Added by Jay Su almost 7 years ago

Thank you Karin again.

Here is what I guess cdo is doing:

1. decide the global grid range [lon01, lon02] of the input file: [0,360] or [-180, 180]
2. project the input lon1 and lon2 to this range: lon1f and lon2f, where abs(lon1-lon2) could > 360 but abs(lon1f-lon2f) must <= 360
3a. if lon1f < lon2f, subsets starting at lon1f and ending at lon2f
3b. else (lon1f > lon2f) paste [lon02, lon2f+360] after [lon1f, lon02]

For the 3b case, for example, if input [90,89], the output will be [90, 449]:
cdo sellonlatbox,90.,89.,0.,60. infile.nc outfile.nc
Would it be possible for cdo to shift the output grid in the range of [-180,360] in the next version?

RE: sellonlatbox flexibility - Added by Ralf Mueller almost 7 years ago

Hi Jay!

We don't plan to extend output coordnates for values outside [0,360] or [-180, 180], sorry.

IMO, these points simply do not exist on the globe - if people want to compute things based on that, they have to keep track on the values. Could be that the target grid is not a globe - in that case a generic or unstructured grid might be more useful.

cheers
ralf

RE: sellonlatbox flexibility - Added by Jay Su almost 7 years ago

Thank you Ralf,

It's sometime impossible to put the coordinates value inside of [0,360] or [-180, 180] if we ask for a monotonously increasing grid. In the example I mentioned last time, we either have [90, 449] or [-90, 269].

The target grid is a globe. The user just likes to subset a region across the dateline.

Jay

RE: sellonlatbox flexibility - Added by Karin Meier-Fleischer almost 7 years ago

'In the example I mentioned last time, we either have [90, 449] or [-90, 269]' - CDO will use exacly those values if

lon1,lon2 = [90, 449]
lon1,lon2 = [-90, 269]

Did you try

cdo -f nc -sellonlatbox,90,449,-90,90  $infile outfile_1.nc
cdo -s sinfo outfile_1.nc | grep lon
lon : 90 to 448.125 by 1.875 degrees_east  circular
cdo -f nc -sellonlatbox,-90,269,-90,90 $infile outfile_2.nc
cdo -s sinfo outfile_2.nc | grep lon
lon : -90 to 268.125 by 1.875 degrees_east  circular

-Karin

RE: sellonlatbox flexibility - Added by Jay Su almost 7 years ago

Karin,

Yes, it shows that we cant always put the grid in the range [0,360] or [-180, 180].

    (1-8/8)