Ouranosinc / xscen

A climate change scenario-building analysis framework.
https://xscen.readthedocs.io/
Apache License 2.0
15 stars 2 forks source link

generalize dims as X/Y when lat/lon or rlat/rlon #221

Closed vindelico closed 1 year ago

vindelico commented 1 year ago

Pull Request Checklist:

What kind of change does this PR introduce?

rechunk: time: -1 X: 100 Y: 100

instead of

rechunk: time: -1 rlat: 100 rlon: 100

or

rechunk: time: -1 lat: 100 lon: 100

This allows to handle grids on different projections together. Example: RDRSv2 (rlat/rlon) and ERA5-Land (lat/lon); different CORDEX-NA RCMs;

Does this PR introduce a breaking change?

No.

Other information:

The duplicated code preparing for rechunking from save_to_netcdf() and save_to_zarr() was refactored into a private function _rechunk_for_saving()

github-actions[bot] commented 1 year ago

Welcome, new contributor!

It appears that this is your first Pull Request. To give credit where it's due, we ask that you add your information to the AUTHORS.rst and .zenodo.json.:

RondeauG commented 1 year ago

Looks good! I would add a mention of this both in the Docstrings for save_to_zarr and save_to_netcdf (probably where rechunk is defined), as well as in the documentation: https://xscen.readthedocs.io/en/latest/notebooks/2_getting_started.html#Saving-files-to-disk

vindelico commented 1 year ago

Looks good! I would add a mention of this both in the Docstrings for save_to_zarr and save_to_netcdf (probably where rechunk is defined), as well as in the documentation: https://xscen.readthedocs.io/en/latest/notebooks/2_getting_started.html#Saving-files-to-disk

I changed the docstrings and and added a line about this in the notebook.

vindelico commented 1 year ago

Nice! Are you able to add a test ? You could create a test/test_io.py file with the same structure as the other test files with a test_rechunk_for_saving function.

test/test_io.py created. I opted for four tests, to check if lat/lon, rlat/rlon are rechunked and when either is rechunked with X/Y as dims.