Skip to content

Commit

Permalink
Change event_time dtype back to str
Browse files Browse the repository at this point in the history
  • Loading branch information
stellema committed Oct 4, 2024
1 parent 48971d9 commit 1d4c659
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions unseen/time_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ def get_agg_dates(ds, var, target_freq, agg_method, time_dim="time"):
Returns
-------
dates : xarray.DataArray
Event dates for the resampled array
Notes
-----
- Previously, the function returned a list of date strings
(event_datetimes_str = dates.load().dt.strftime("%Y-%m-%d"))
event_datetimes_str : xarray.DataArray
Event dates (YYYY-MM-DD) for the resampled array
"""

ds_arg = ds[var].resample(time=target_freq, label="left")
Expand All @@ -43,9 +38,9 @@ def get_agg_dates(ds, var, target_freq, agg_method, time_dim="time"):
dates = [da.idxmin(time_dim) for _, da in ds_arg]

dates = xr.concat(dates, dim=time_dim)
dates.attrs = ds[time_dim].attrs

return dates
event_datetimes_str = dates.load().dt.strftime("%Y-%m-%d")
event_datetimes_str = event_datetimes_str.astype(dtype=str)
return event_datetimes_str


def temporal_aggregation(
Expand Down

0 comments on commit 1d4c659

Please sign in to comment.