clouddrift.pairs.pair_time_overlap

clouddrift.pairs.pair_time_overlap#

clouddrift.pairs.pair_time_overlap(time1: list[float] | ndarray[float] | Series | DataArray, time2: list[float] | ndarray[float] | Series | DataArray, distance: float | None = 0) Tuple[ndarray[int], ndarray[int]][source]#

Given two arrays of times (or any other monotonically increasing quantity), return indices where the times are within a prescribed distance.

Although higher-level array containers like xarray and pandas are supported for input arrays, this function is an order of magnitude faster when passing in numpy arrays.

Parameters#

time1array_like

First array of times.

time2array_like

Second array of times.

distancefloat

Maximum distance within which the values of time1 and time2 are considered to overlap. Default is 0, or, the values must be exactly the same.

Returns#

overlap1np.ndarray[int]

Indices of time1 where its time overlaps with time2.

overlap2np.ndarray[int]

Indices of time2 where its time overlaps with time1.

Examples#

>>> time1 = np.arange(4)
>>> time2 = np.arange(2, 6)
>>> pair_time_overlap(time1, time2)
(array([2, 3]), array([0, 1]))
>>> pair_time_overlap(time1, time2, 1)
(array([1, 2, 3]), array([0, 1, 2]))