Skip to content

Commit

Permalink
fix for odd ns/us datetime conversions. converting to datetime64 alwa…
Browse files Browse the repository at this point in the history
…ys forces a us conversion, this only converts if we are in iris mode.
  • Loading branch information
freemansw1 committed Aug 30, 2024
1 parent 084c42d commit a4744e3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tobac/segmentation/watershed_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,12 @@ def segmentation(
features_out_list = []

# Iris workaround: convert cftime to datetime64
all_times = features["time"].map(np.datetime64)

if np.issubdtype(features["time"].dtype, np.datetime64):
# we are (likely) a numpy datetime
all_times = features["time"]
else:
all_times = features["time"].map(np.datetime64)

for i_time, time_i in enumerate(field.coords[time_var_name]):
field_at_time = field.isel({time_var_name: i_time})
Expand Down

0 comments on commit a4744e3

Please sign in to comment.