MCPcopy Index your code
hub / github.com/pydata/xarray / infer_timedelta_units

Function infer_timedelta_units

xarray/coding/times.py:798–805  ·  view source on GitHub ↗

Given an array of timedeltas, returns a CF compatible time-unit from {'days', 'hours', 'minutes' 'seconds'} (the first one that can evenly divide all unique time deltas in `deltas`)

(deltas)

Source from the content-addressed store, hash-verified

796
797
798def infer_timedelta_units(deltas) -> str:
799 """Given an array of timedeltas, returns a CF compatible time-unit from
800 {'days', 'hours', 'minutes' 'seconds'} (the first one that can evenly
801 divide all unique time deltas in `deltas`)
802 """
803 deltas = ravel(deltas)
804 unique_timedeltas = np.unique(deltas[pd.notnull(deltas)])
805 return _infer_time_units_from_diff(unique_timedeltas)
806
807
808def cftime_to_nptime(

Callers 2

Calls 3

ravelFunction · 0.90
notnullMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…