From 3bf227cea431a1c4bbd22fc180c3cacbbb12aff9 Mon Sep 17 00:00:00 2001 From: tomvothecoder Date: Fri, 22 Nov 2024 14:02:40 -0800 Subject: [PATCH] Add temporal bounds and center times for group_average API --- xcdat/temporal.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xcdat/temporal.py b/xcdat/temporal.py index 3367e06a..e3b28870 100644 --- a/xcdat/temporal.py +++ b/xcdat/temporal.py @@ -17,7 +17,7 @@ from xcdat import bounds # noqa: F401 from xcdat._logger import _setup_custom_logger -from xcdat.axis import get_dim_coords +from xcdat.axis import center_times, get_dim_coords from xcdat.dataset import _get_data_var logger = _setup_custom_logger(__name__) @@ -885,6 +885,10 @@ def _averager( ds = ds.drop_dims(self.dim) ds[dv_avg.name] = dv_avg + if self._mode == "group_average": + ds = ds.bounds.add_missing_bounds(axes="T") + ds = center_times(ds) + if keep_weights: ds = self._keep_weights(ds) @@ -1884,6 +1888,8 @@ def _convert_df_to_dt(self, df: pd.DataFrame) -> np.ndarray: """ df_new = df.copy() + # TODO: This is where the result should be in the middle, not the + # beginning. dt_components_defaults = {"year": 1, "month": 1, "day": 1, "hour": 0} for component, default_val in dt_components_defaults.items(): if component not in df_new.columns: