oceanspy icon indicating copy to clipboard operation
oceanspy copied to clipboard

cutout xRange when longitude is not monotonically increasing

Open Mikejmnez opened this issue 3 years ago • 2 comments

This is related to the compatibility of Oceanspy with the LLC grid. Here is the following scenario

XC is periodic and (in general takes values of -180 < xc < 180, and you are interested in the cutout region shown in the boxed region in the attached figure.

Screen Shot 2022-02-10 at 7 05 14 PM

The variable plotted is indeed XC (ECCO data), and the dataset has been transformed (face no longer a dimension). In this scenario the box is defined by a XC>0 value in the far left and a XC<0 in the right (there is no such issue in the latitude). So the argument to pass to od.subsample.cutout is (for example)

XRange = [170, -140]
YRange = [0, 50]

However, within the cutout function XRange is always set to be monotonically increasing function. The snippet of code is

# line 1374 (within def maskH) in subsample.py
XRange = _np.asarray([_np.min(XRange) - add_Hbdr, _np.max(XRange) + add_Hbdr])

this returns the incorrect range:

XRange = [-140, 170]

which is the opposite range of what we want. This might not be an issue when working with the ECCO dataset (since transforming all of it is quite fast now), but working with a bigger dataset (LLC4320 or similar), you don't want to trigger that computation...

We need to be able to (correctly) define the XRange in the above scenario, which may be relevant to people whose work focuses on the Pacific ocean.

This also important as maskH (above snippet is from the definition of maskH) is used to determined which faces survive the cutout.

Mikejmnez avatar Feb 11 '22 00:02 Mikejmnez

This could only occur when there is a discontinuity of longitude in the cutout region. We can define a new x scale as "how much east is a point relative to a reference point (0-360)" and select the reference point such that it is outside the cutout region. I am currently working on that

MaceKuailv avatar Feb 13 '22 21:02 MaceKuailv

This could only occur when there is a discontinuity of longitude in the cutout region. We can define a new x scale as "how much east is a point relative to a reference point (0-360)" and select the reference point such that it is outside the cutout region. I am currently working on that

That is true. Can you elaborate/demonstrate with an example? Say for example,

XRange=[-140, 170]

Maybe an if`` statement that whenever XRange[0]>XRange[1]``` you go around this way. If not, then continue as always?

Mikejmnez avatar Feb 13 '22 21:02 Mikejmnez