Skip to content

Commit 12afd27

Browse files
committed
Add temporal bounds and center times for group_average API
1 parent 96bc649 commit 12afd27

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
@@ -16,7 +16,7 @@
1616

1717
from xcdat import bounds # noqa: F401
1818
from xcdat._logger import _setup_custom_logger
19-
from xcdat.axis import get_dim_coords
19+
from xcdat.axis import center_times, get_dim_coords
2020
from xcdat.dataset import _get_data_var
2121

2222
logger = _setup_custom_logger(__name__)
@@ -819,6 +819,10 @@ def _averager(
819819
ds = ds.drop_dims(self.dim)
820820
ds[dv_avg.name] = dv_avg
821821

822+
if self._mode == "group_average":
823+
ds = ds.bounds.add_missing_bounds(axes="T")
824+
ds = center_times(ds)
825+
822826
if keep_weights:
823827
ds = self._keep_weights(ds)
824828

@@ -1614,6 +1618,8 @@ def _convert_df_to_dt(self, df: pd.DataFrame) -> np.ndarray:
16141618
"""
16151619
df_new = df.copy()
16161620

1621+
# TODO: This is where the result should be in the middle, not the
1622+
# beginning.
16171623
dt_components_defaults = {"year": 1, "month": 1, "day": 1, "hour": 0}
16181624
for component, default_val in dt_components_defaults.items():
16191625
if component not in df_new.columns:

0 commit comments

Comments
 (0)