From b770b91f2f58499de8e94d9dfdc53e184f0840ef Mon Sep 17 00:00:00 2001 From: tomvothecoder Date: Wed, 6 Nov 2024 15:32:51 -0800 Subject: [PATCH] Restore code in `bounds.py` that was accidentally deleted --- xcdat/bounds.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xcdat/bounds.py b/xcdat/bounds.py index 90984c6a..4ee799c3 100644 --- a/xcdat/bounds.py +++ b/xcdat/bounds.py @@ -641,6 +641,13 @@ def _create_time_bounds( # noqa: C901 # Determine the daily frequency for generating time bounds. if daily_subfreq is None: diff = time.values[1] - time.values[0] + + # Arrays with `dtype="timedelta64[ns]"` must be converted to + # pandas timedelta objects in order to access the `.seconds` + # time component. + if isinstance(diff, np.timedelta64): + diff = pd.to_timedelta(diff) + hrs = diff.seconds / 3600 daily_subfreq = int(24 / hrs) # type: ignore