From 1d4c65992c12482a73c404ddea954567b1f9fd6b Mon Sep 17 00:00:00 2001 From: Annette Stellema <40450353+stellema@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:52:31 +1000 Subject: [PATCH] Change event_time dtype back to str --- unseen/time_utils.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/unseen/time_utils.py b/unseen/time_utils.py index e200eb5..87ea649 100644 --- a/unseen/time_utils.py +++ b/unseen/time_utils.py @@ -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") @@ -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(