diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f6f0768e..8e38f792 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -36,6 +36,7 @@ Bug fixes * ``unstack_dates`` now works correctly for yearly datasets when `winter_starts_year=True`, as well as multi-year datasets. (:pull:`450`). * Fix ``xs.catalog.concat_data_catalogs`` for catalogs that have not been search yet. (:pull:`431`). * Fix indicator computation using ``freq=2Q*`` by assuming this means a semiannual frequency anchored at the given month (pandas assumes 2 quarter steps, any of them anchored at the given month). (:pull:`431`). +* ``create_bounds_rotated_pole`` now uses the default value if the dataset has no `north_pole_grid_longitude` attribute, instead of crashing. (:pull:`455`). Breaking changes ^^^^^^^^^^^^^^^^ diff --git a/src/xscen/regrid.py b/src/xscen/regrid.py index 24c680cd..8397b588 100644 --- a/src/xscen/regrid.py +++ b/src/xscen/regrid.py @@ -370,12 +370,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=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=central, ) PC = ccrs.PlateCarree()