Skip to content

Commit 3bf227c

Browse files
committed
Add temporal bounds and center times for group_average API
1 parent 27396e5 commit 3bf227c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

xcdat/temporal.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from xcdat import bounds # noqa: F401
1919
from xcdat._logger import _setup_custom_logger
20-
from xcdat.axis import get_dim_coords
20+
from xcdat.axis import center_times, get_dim_coords
2121
from xcdat.dataset import _get_data_var
2222

2323
logger = _setup_custom_logger(__name__)
@@ -885,6 +885,10 @@ def _averager(
885885
ds = ds.drop_dims(self.dim)
886886
ds[dv_avg.name] = dv_avg
887887

888+
if self._mode == "group_average":
889+
ds = ds.bounds.add_missing_bounds(axes="T")
890+
ds = center_times(ds)
891+
888892
if keep_weights:
889893
ds = self._keep_weights(ds)
890894

@@ -1884,6 +1888,8 @@ def _convert_df_to_dt(self, df: pd.DataFrame) -> np.ndarray:
18841888
"""
18851889
df_new = df.copy()
18861890

1891+
# TODO: This is where the result should be in the middle, not the
1892+
# beginning.
18871893
dt_components_defaults = {"year": 1, "month": 1, "day": 1, "hour": 0}
18881894
for component, default_val in dt_components_defaults.items():
18891895
if component not in df_new.columns:

0 commit comments

Comments
 (0)