Skip to content

Commit

Permalink
Fix _keep_weights() for departures and average modes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder committed Sep 3, 2024
1 parent 0f4a1af commit b97e8ae
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions xcdat/temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,10 @@ def departures(
# ----------------------------------------------------------------------
ds_departs = self._calculate_departures(ds_obs, ds_climo, data_var)

if keep_weights:
self._weights = ds_climo[f"{self.dim}_wts"]
ds_departs = self._keep_weights(ds_departs)

return ds_departs

def _averager(
Expand Down Expand Up @@ -1644,6 +1648,8 @@ def _keep_weights(self, ds: xr.Dataset) -> xr.Dataset:
if self._mode in ["group_average", "climatology"]:
weights = self._weights.assign_coords({self.dim: self._dataset[self.dim]})
weights = weights.rename({self.dim: f"{self.dim}_original"})
else:
weights = self._weights

ds[weights.name] = weights

Expand Down

0 comments on commit b97e8ae

Please sign in to comment.