Skip to content

Commit

Permalink
Add temporal bounds and center times for group_average API
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder committed Nov 22, 2024
1 parent 27396e5 commit 3bf227c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion xcdat/temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 3bf227c

Please sign in to comment.