Skip to content

Commit

Permalink
Update static time dim ref to CF interpreted dim key
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder committed Oct 3, 2024
1 parent c5c4d46 commit 1a91228
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions xcdat/temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 1a91228

Please sign in to comment.