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

Fixed broken regridding code in file_regrid.py; Updated GCPy regridding documentation #253

Merged
merged 4 commits into from
Aug 22, 2023

Conversation

yantosca
Copy link
Contributor

This PR has introduced several updates into the gcpy/file_regrid.py script (see 0bb6ace):

  • Fixed broken regridding code (especially lat/lon -> cubed sphere/stretched grid)
  • Ensured that all combinations of regridding work
  • Refactored code from if/elif blocks into separate routines
  • Updated PyDoc comments

Also rewrote the docs/source/Regridding.rst page (see 2b160b6 and dddf513) to be consistent with the updates in gcpy/file_regrid.py. Also confirmed that all regridding examples with online and offline regridding weights work as advertised.

docs/source/Regridding.rst
- "23" -> "24" in gridspec command in Example 1.

Signed-off-by: Bob Yantosca <[email protected]>
gcpy/file_regrid.py
- Ignore any FutureWarnings
- Trimmed trailing whitespace, updated commments
- Remove pandas import (suggested by Pylint)
- Refactored code out of the big if/elif block in the file_regrid
  routine into separate functions
- Updated PyDoc comments
- Add "with xr.set_options(keep_attrs=True):" blocks to preserve
  DataSet and DataArray attributes
- Add calls to reformat_dims in the refactored functions that regrid
  to and/or from cubed-sphere/stretched-grid
- Replaced hardwired code to save to diagnostic/checkpoint with
  calls to reformat_dims
- Add "lat_bnds" and "lon_bnds" to drop_and_rename_classic_vars
- Added function "drop_lon_and_lat"

We have verified that file_regrid now works properly when regridding
from LL -> CS/SG, LL -> LL, CS/SG -> LL, and CS/SG -> CS/SG.

Signed-off-by: Bob Yantosca <[email protected]>
docs/source/Regridding.rst
- Updated text and examples for routines in file_regrid.py
- Updated text and examples for routines in regrid_restart_file.py
- Confirmed that examples work as advertised

Signed-off-by: Bob Yantosca <[email protected]>
@yantosca yantosca added category: Bug Something isn't working TODO: Documentation Related to manual pages or other documentation topic: Regridding Issues pertaining to horizontal & vertical regridding labels Aug 22, 2023
@yantosca yantosca added this to the 1.4.0 milestone Aug 22, 2023
@yantosca yantosca self-assigned this Aug 22, 2023
@yantosca
Copy link
Contributor Author

yantosca commented Aug 22, 2023

Perhaps we can resolve the issue in #167 with the knowledge gained from fixing file_regrid.py.

This merge brings PR #253 (Fixed broken regridding code in file_regrid.py;
Updated GCPy regridding documentation, by @yantosca) into the GCPy
1.4.0 development stream.

We have fixed several issues in the current gcpy/file_regrid.py script,
so that LL -> CS/SG, LL -> LL, CS/SG -> CS/SG, and CS/SG -> LL regridding
now work.  Furthermore, we have refactored the code in file_regrid.py
for clarity.

We have updated the Regridding.rst file and have added some extra
examples using file_regrid.py.  We have also verified that all examples
using file_regrid.py and regrid_restart_file.py work as advertised.

This will not affect benchmark code as the plotting routines
compare_zonal_mean() and compare_single_level() use the routine
regrid_comparison_data from gcpy/regrid.py.  Perhaps we can resolve
the issue reported in #167 with the knowledge thus gained in preparing
this PR.

Signed-off-by: Bob Yantosca <[email protected]>
@yantosca yantosca merged commit 8e98d3f into dev Aug 22, 2023
hannahnesser pushed a commit to hannahnesser/gcpy that referenced this pull request Jan 22, 2024
This merge brings PR geoschem#253 (Fixed broken regridding code in file_regrid.py;
Updated GCPy regridding documentation, by @yantosca) into the GCPy
1.4.0 development stream.

We have fixed several issues in the current gcpy/file_regrid.py script,
so that LL -> CS/SG, LL -> LL, CS/SG -> CS/SG, and CS/SG -> LL regridding
now work.  Furthermore, we have refactored the code in file_regrid.py
for clarity.

We have updated the Regridding.rst file and have added some extra
examples using file_regrid.py.  We have also verified that all examples
using file_regrid.py and regrid_restart_file.py work as advertised.

This will not affect benchmark code as the plotting routines
compare_zonal_mean() and compare_single_level() use the routine
regrid_comparison_data from gcpy/regrid.py.  Perhaps we can resolve
the issue reported in geoschem#167 with the knowledge thus gained in preparing
this PR.

Signed-off-by: Bob Yantosca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Bug Something isn't working TODO: Documentation Related to manual pages or other documentation topic: Regridding Issues pertaining to horizontal & vertical regridding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant