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

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

Merged
merged 21 commits into from
Jul 27, 2023

Conversation

vindelico
Copy link
Collaborator

@vindelico vindelico commented Jul 6, 2023

Pull Request Checklist:

  • This PR addresses an already opened issue (for bug fixes / features)
    • This PR fixes #xyz
  • (If applicable) Documentation has been added / updated (for bug fixes / features).
  • (If applicable) Tests have been added.
  • This PR does not seem to break the templates.
  • HISTORY.rst has been updated (with summary of main changes).
  • Link to issue (:issue:number) and pull request (:pull:number) has been added.

What kind of change does this PR introduce?

  • spatial dimensions can be generalized as X/Y when rechunking and will be mapped to rlon/rlat or lon/lat accordingly.
  • The yml file can contain

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()

@vindelico vindelico added the enhancement New feature or request label Jul 6, 2023
@github-actions
Copy link

github-actions bot commented Jul 6, 2023

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.:

  • The relevant author information has been added to AUTHORS.rst and .zenodo.json.

Please make sure you've read our contributing guide. We look forward to reviewing your Pull Request shortly ✨

Copy link
Collaborator

@aulemahal aulemahal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition! Thanks!

xscen/io.py Outdated Show resolved Hide resolved
xscen/io.py Outdated Show resolved Hide resolved
Copy link
Contributor

@juliettelavoie juliettelavoie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

HISTORY.rst Outdated Show resolved Hide resolved
@RondeauG
Copy link
Contributor

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 and others added 4 commits July 10, 2023 16:26
Co-authored-by: Pascal Bourgault <bourgault.pascal@ouranos.ca>
Co-authored-by: Pascal Bourgault <bourgault.pascal@ouranos.ca>
Co-authored-by: juliettelavoie <juliette.lavoie@hotmail.ca>
HISTORY.rst Outdated Show resolved Hide resolved
@vindelico
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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.

tests/test_io.py Outdated Show resolved Hide resolved
tests/test_io.py Outdated Show resolved Hide resolved
xscen/io.py Outdated Show resolved Hide resolved
Copy link
Contributor

@RondeauG RondeauG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can help with the tests, if you want.

HISTORY.rst Show resolved Hide resolved
tests/test_io.py Outdated Show resolved Hide resolved
xscen/io.py Outdated Show resolved Hide resolved
docs/notebooks/2_getting_started.ipynb Outdated Show resolved Hide resolved
xscen/io.py Outdated Show resolved Hide resolved
vindelico and others added 3 commits July 25, 2023 11:29
Co-authored-by: RondeauG <38501935+RondeauG@users.noreply.github.com>
Co-authored-by: RondeauG <38501935+RondeauG@users.noreply.github.com>
@RondeauG RondeauG merged commit 267ed0b into main Jul 27, 2023
5 checks passed
@RondeauG RondeauG deleted the generalize_rlatrlon_latlon branch July 27, 2023 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants