ktk.TimeSeries.get_index_at_time

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 attribute.

Returns:

The index in the time attribute.

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