-
Notifications
You must be signed in to change notification settings - Fork 9
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
Regridding functionalities (powered by xESMF) #243
Conversation
- Fix typo importing cf_xarray - Fix missing brackets in if statement in Grid.__repr__() - Fix reformatting the bounds in Grid.grid_reformat() when reformatting xESMF to CF. Now using cfxr.vertices_to_bounds instead of _reravel - Now updating the format attribute when executing Grid.grid_reformat() - Added compute_bounds for format CF and grid_type regular_lat_lon
- Added basic adaptive_masking function that will be obsolete as soon as adaptive masking is implemented in xesmf. - Added basic regrid function. - Added basic Weights class. The method add_matrix_NaNs to mask out-of-source-domain grid cells in the remapping weights will likely be obsolete with future xesmf versions. Yet, Weights can only be generated by xesmf by specifying input and output grid as well as the remapping method. - Minor changes to the Grid class: - Default attributes mostly set to None. - Now raising exception when none of the input parameters are specified (Dataset, grid_id or grid_instructor). - Added temporary fix for a small cf_xarray bug that identifies lat_bnds/lon_bnds as latitude and longitude coordinates if the bounds are specified as xarray.Dataset.coords and they have a units attribute. - detect_coords now uses roocs_utils.xarray_utils.get_coord_by_attr - Cleared open questions regarding tests/core/test_regrid.py leading to minor changes.
… core/regrid.py - Added the necessary methods to the Regrid class in ops/regrid.py Yet adaptive masking can result in an error when providing an xarray.Dataset as input. Also, the xesmf regridding seems to drop a few variables and keep others that are not necessary to be kept. - Added Grid.__str__() method to core/regrid.py - Added Grid.remove_halo() method to core/regrid.py. For partially duplicated rows/columns an exception will be raised. Fully duplicated rows/columns will be cut off.
- Added unmapped_to_nan parameter for init calls to xesmf.Regridder class, replaces Weights.add_matrix_NaNs - Added parameters skip_na and na_thres for calls to xesmf.Regridder instances, replacing custom adaptive_masking function calls - core/regrid.py - calls to roocs-utils.xarray-utils.get_coord_by_type adjusted to include ignore_aux_coords=False to allow 2D coordinate variables to be identified as coordinates - Requirement for xesmf set to xesmf>=0.6.0 - test_grid_init_ds_tos_curvilinear adjusted for removed halo - Regridding tests only run for xesmf>=0.6
@Zeitsperre @cehbrecht I removed python 3.8 from the CI checks because of the
I am not sure how such a setting can be added in the
|
That's exactly what you would need to do to maintain Python3.8 support. Everything is using |
@Zeitsperre I leave the last words to you :) We would like to merge this PR and make the new clisops release with the regrid operator. I have prepared daops and rook already for the new operator and it works. |
Hey all, Working on this now. I'm going to be adding a few changes to docstrings and updating some deprecated calls. I also might split the failing upstream build into its own workflow so that it isn't constantly failing. Will give everything a final overview after that's all done. Should have something today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a ton going on here, but we've collectively been examining this PR for a very long time. Things look good beyond a handful of small issues I noticed when cleaning up the typing/docstrings. Congrats!
- Addressed review comments regarding environment.yml - Added test: regridding of data array - core.regrid: Fixed problems in case of DataArray instead of Dataset
@Zeitsperre Thanks a lot for the review and your contribution. I addressed the outstanding issues you found |
Well done. Feel free to merge whenever you're ready! |
Pull Request Checklist:
AUTHORS.md
What kind of change does this PR introduce?:
clisops.ops.regrid.regrid
one line remapping function orchestrating below functions and classesclisops.core.Grid
class:xarray.Dataset
holding description / coordinates of a regular lat-lon grid in CF compliant format:xarray.Dataset/DataArray
(optionally of adaptive resolution, if source is not a regular lat-lon grid)clisops.core.Weights
:xesmf.Regridder
objectclisops.core.regrid
:xarray.Dataset/DataArray
Does this PR introduce a breaking change?:
Other information:
Future planned PR(s) specific for remapping:
Future planned PR(s) generally for clisops: