Finding points¶
The methods listed here let you find indices corresponding to points in time, or perform aggregate functions (e.g. mean, min, max) on intervals within a time series.
Indices and values at specific times¶
- datkit.index(times, t, ttol=1e-09)¶
Returns the index of time
tintimes, assumingtimesis a non-decreasing sequence.A
ValueErrorwill be raised if timetcannot be found intimes. Two times will be regarded as equal if they are withinttolof each other.
- datkit.index_near(times, t)¶
Returns the index of time
tintimes, or the index of the nearest value to it, assumingtimesis a non-decreasing sequence.If
tis outside the range oftimesby more than half a sampling interval (as returned bydatkit.sampling_interval()), aValueErrorwill be raised.
- datkit.index_on(times, t0=None, t1=None, include_left=True, include_right=False)¶
Returns a tuple
(i0, i1)corresponding to the interval fromt0tot1intimes, assumingtimesis a non-decreasing sequence.By default, the interval is taken as
t0 <= times < t1, but this can be customized usinginclude_leftandinclude_right.If one or both points are out of range, indices corresponding to the first and/or last entries in
timesare returned. Note that this may result in an empty interval ift0 < t1 < times[0]ortimes[1] < t0 < t1.If
t0isNone, the first index will be0, regardless of the value ofinclude_left. Ift1isNonethe second index will belen(times), regardless of the value ofinclude_right.
- datkit.index_crossing(values, value=0)¶
Returns the lowest two indices
iandjfor whichvaluescrosses the givenvalue(going either from below to above, or vice versa).For example
datkit.index([0, 1, 2, 3, 4], 2.5)returns(2, 3).The method is best applied to smooth (denoised) data.
A
ValueErroris raised if no crossing can be found, or
- datkit.time_crossing(times, values, value=0)¶
Returns the time at which
valuesfirst crossesvalue.Specifically, the method linearly interpolates between the entries from
timesat the indices returned byindex_crossing(). No assumptions are made abouttimes(other than that it has the same length asvalues), so that arrays representing other quantities can also be passed in.The method is best applied to smooth (denoised) data.
See also
index_crossing().
- datkit.value_at(times, values, t, ttol=1e-09)¶
Returns
values[i]such thattimes[i]is withinttolof the timet.A
ValueErrorwill be raised if no suchican be found.
- datkit.value_near(times, values, t)¶
Returns
values[i]such thattimes[i]is the nearest point totin the data.A
ValueErrorwill be raised if no time neartcan be found intimes(seeindex_near()).
- datkit.value_interpolated(times, values, t)¶
Returns the value at the given time, obtained by linear interpolation if
tis not presesnt intimes.A
ValueErroris raised if noican be found such thattimes[i] <= t <= times[i + 1].
- datkit.data_on(times, values, t0=None, t1=None, include_left=True, include_right=False)¶
Returns a tuple
(times2, values2)corresponding to the interval fromt0tot1intimes.See also
index_on().
Averages and extremes¶
- datkit.mean_on(times, values, t0=None, t1=None, include_left=True, include_right=False)¶
Returns the mean of
valueson the interval fromt0tot1.See also
index_on().
- datkit.max_on(times, values, t0=None, t1=None, include_left=True, include_right=False)¶
Returns a tuple
(t_max, v_max)corresponding to the maximum value invalueson the interval fromt0tot1.See also
index_on().
- datkit.min_on(times, values, t0=None, t1=None, include_left=True, include_right=False)¶
Returns a tuple
(t_min, v_min)corresponding to the minimum value invalueson the interval fromt0tot1.See also
index_on().
- datkit.abs_max_on(times, values, t0=None, t1=None, include_left=True, include_right=False)¶
Returns a tuple
(t_max, v_max)corresponding to the maximum value inabs(values)on the interval fromt0tot1.See also
index_on().
- datkit.imax_on(times, values, t0=None, t1=None, include_left=True, include_right=False)¶
Returns the index
icorresponding to the maximum value on the interval fromt0tot1.See also
index_on().
- datkit.imin_on(times, values, t0=None, t1=None, include_left=True, include_right=False)¶
Returns the index
icorresponding to the maximum value on the interval fromt0tot1.See also
index_on().
- datkit.iabs_max_on(times, values, t0=None, t1=None, include_left=True, include_right=False)¶
Returns the index
icorresponding to the maximum ofabs(values)on the interval fromt0tot1.See also
index_on().