Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Area subset fails with extents which cross prime meridian #93

Closed
JamesVarndell opened this issue Jan 22, 2021 · 6 comments
Closed

Area subset fails with extents which cross prime meridian #93

JamesVarndell opened this issue Jan 22, 2021 · 6 comments

Comments

@JamesVarndell
Copy link

Workflows appear to be failing when they contain an area subset operator with extents which cross the 0 degree longitude line (i.e. with a negative western extent and a positive eastern extent).

For example:

wf = ops.Subset(
    ops.Input(
        'tas', ['CMIP6.ScenarioMIP.MIROC.MIROC6.ssp119.r1i1p1f1.day.tas.gn.v20191016']
    ),
    area='-5,50,30,65',
)

Through my WPS adaptor I'm just getting the generic "Sorry, process failed." error message, so I don't have a full traceback that might explain what's happening here - but I can successfully run area subsets for extents which don't cross the prime meridian.

@agstephens
Copy link
Contributor

To check in clisops:

  • what is the longitude range in the actual NetCDF file?
  • does a longitude extraction work if it does not cross the Greenwich Meridian.

Find (or add) example NetCDF files into the test CMIP6/c3s-cmip6 data that have longitude range:

  • 0 to 360
  • -180 to 180

Things to test at clisops level:

  • Dataset with longitude: 0 to 360:
    • subset request: 10 to 200
    • subset request: -50 to 100
  • Dataset with longitude: -180 to 180:
    • subset request: 10 to 200
    • subset request: -50 to 100

@agstephens
Copy link
Contributor

roocs/clisops#35

@agstephens
Copy link
Contributor

Suggested location for new code (assuming that roll works for us):

https://github.com/roocs/clisops/blob/master/clisops/ops/subset.py#L18-L24

Notes:

  • only relevant if longitude bounds are set
  • need to create a new function to check alignment of requested longitude bounds with the actual longitude in the data
  • and if necessary, roll the dataset itself

@ellesmith88
Copy link
Contributor

The longitude range of CMIP6.ScenarioMIP.MIROC.MIROC6.ssp119.r1i1p1f1.day.tas.gn.v20191016 is 0 to 360.

If the longitude bounds selected do not cross the prime meridian then the subsetting is successful.

Further testing:

Dataset with longitude: 0 to 360:

  • subset request: 10 to 200: test passes
  • subset request: -50 to 100: test raises NotImplementedError: Input longitude bounds ([-50. 100.]) cross the 0 degree meridian but dataset longitudes are all positive.

Dataset with longitude: -180 to 180:
Datasets with longitudes -180 to 180 are not easy to come by! I've done some initial tests with a dataset that has longitude -300 to 60:

  • subset request: 10 to 50: Subset is successful
  • subset request: -100 to 50: Subset is successful

@ellesmith88
Copy link
Contributor

Looking into using xarray roll here: https://github.com/roocs/clisops/blob/9f38ca78700e18ba676bebdc0c50ce514c1b1a41/tests/test_roll.py#L1-L180

The data has been rolled but still only contains values from 0 to 360.

I tested a subset operation after rolling a dataset by 180 here: https://github.com/roocs/clisops/blob/9f38ca78700e18ba676bebdc0c50ce514c1b1a41/tests/test_roll.py#L140-L157 and it still raises the prime meridian error.

@ellesmith88
Copy link
Contributor

closed with clisops PR #117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants