From 1a91228d14a1541a494067f6de4cf0a8c8933963 Mon Sep 17 00:00:00 2001 From: tomvothecoder Date: Thu, 1 Aug 2024 10:50:49 -0700 Subject: [PATCH] Update static time dim ref to CF interpreted dim key --- xcdat/temporal.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/xcdat/temporal.py b/xcdat/temporal.py index 36d1f8b6..675acf42 100644 --- a/xcdat/temporal.py +++ b/xcdat/temporal.py @@ -1135,11 +1135,13 @@ def _subset_coords_for_custom_seasons( """ month_ints = sorted([MONTH_STR_TO_INT[month] for month in months]) - coords_by_month = ds.time.groupby(f"{self.dim}.month").groups + coords_by_month = ds[self.dim].groupby(f"{self.dim}.month").groups month_to_time_idx = { k: coords_by_month[k] for k in month_ints if k in coords_by_month } - month_to_time_idx = sorted(list(chain.from_iterable(month_to_time_idx.values()))) # type: ignore + month_to_time_idx = sorted( + list(chain.from_iterable(month_to_time_idx.values())) + ) # type: ignore ds_new = ds.isel({f"{self.dim}": month_to_time_idx}) return ds_new @@ -1224,7 +1226,9 @@ def _drop_leap_days(self, ds: xr.Dataset): ------- xr.Dataset """ - ds = ds.sel(**{self.dim: ~((ds.time.dt.month == 2) & (ds.time.dt.day == 29))}) + ds = ds.sel( # type: ignore + **{self.dim: ~((ds[self.dim].dt.month == 2) & (ds[self.dim].dt.day == 29))} + ) return ds def _average(self, ds: xr.Dataset, data_var: str) -> xr.DataArray: