From 7d72390f8a6a6aed7abe534edf9bad0b50545ac4 Mon Sep 17 00:00:00 2001 From: RondeauG Date: Wed, 18 Sep 2024 09:40:13 -0400 Subject: [PATCH 1/3] fix typo in create_bnds --- src/xscen/regrid.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xscen/regrid.py b/src/xscen/regrid.py index 604ed7e7..499af17e 100644 --- a/src/xscen/regrid.py +++ b/src/xscen/regrid.py @@ -372,9 +372,9 @@ def create_bounds_rotated_pole(ds: xr.Dataset): # Get cartopy's crs for the projection RP = ccrs.RotatedPole( - pole_longitude=ds.rotated_pole.grid_north_pole_longitude, - pole_latitude=ds.rotated_pole.grid_north_pole_latitude, - central_rotated_longitude=ds.rotated_pole.north_pole_grid_longitude, + pole_longitude=float(ds.rotated_pole.grid_north_pole_longitude), + pole_latitude=float(ds.rotated_pole.grid_north_pole_latitude), + central_rotated_longitude=float(ds.rotated_pole.grid_north_pole_longitude), ) PC = ccrs.PlateCarree() From 99eb2af3809ae7e12f090dafe230e3802368139b Mon Sep 17 00:00:00 2001 From: RondeauG Date: Wed, 18 Sep 2024 10:29:08 -0400 Subject: [PATCH 2/3] revert change, add default --- src/xscen/regrid.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/xscen/regrid.py b/src/xscen/regrid.py index 499af17e..9e0ac843 100644 --- a/src/xscen/regrid.py +++ b/src/xscen/regrid.py @@ -369,12 +369,13 @@ def create_bounds_rotated_pole(ds: xr.Dataset): rlonv = rlonv1D.expand_dims(rlat_vertices=rlatv1D).transpose( "rlon_vertices", "rlat_vertices" ) - + central = ds.rotated_pole.attrs.get("north_pole_grid_longitude") + central = float(central) if central is not None else None # Get cartopy's crs for the projection RP = ccrs.RotatedPole( pole_longitude=float(ds.rotated_pole.grid_north_pole_longitude), pole_latitude=float(ds.rotated_pole.grid_north_pole_latitude), - central_rotated_longitude=float(ds.rotated_pole.grid_north_pole_longitude), + central_rotated_longitude=central, ) PC = ccrs.PlateCarree() From 636bfbe97a60a409380771ab38d92c370b951fa8 Mon Sep 17 00:00:00 2001 From: RondeauG Date: Wed, 18 Sep 2024 10:34:54 -0400 Subject: [PATCH 3/3] upd changelog --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9d7cc3cd..bf9fab82 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -29,6 +29,7 @@ Bug fixes * ``unstack_fill_nan`` now works if given a dictionary that contains both dimensions and coordinates. (:pull:`450`). * ``clean_up`` no longer modifies the original dataset. (:pull:`450`). * ``unstack_dates`` now works correctly for yearly datasets when `winter_starts_year=True`, as well as multi-year datasets. (:pull:`450`). +* ``create_bounds_rotated_pole`` now uses the default value if the dataset has no `north_pole_grid_longitude` attribute, instead of crashing. (:pull:`455`). Internal changes ^^^^^^^^^^^^^^^^