ktk.TimeSeries.get_index_at_time#

TimeSeries.get_index_at_time(time)[source]#

Get the time index that is closest to the specified time.

Parameters

time (float) – Time to look for in the TimeSeries’ time vector.

Returns

The index in the time vector.

Return type

int

Example

>>> ts = ktk.TimeSeries(time=np.array([0, 0.5, 1, 1.5, 2]))
>>> ts.get_index_at_time(0.9)
2
>>> ts.get_index_at_time(1)
2
>>> ts.get_index_at_time(1.1)
2
>>> ts.get_index_at_time(2.1)
4