ktk.TimeSeries.get_index_at_event

ktk.TimeSeries.get_index_at_event#

TimeSeries.get_index_at_event(name, occurrence=0)[source]#

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

Parameters:
  • name (str) – Event name

  • occurrence (int) – Occurrence of the event. The default is 0.

Returns:

The index in the time attribute.

Return type:

int

Example

>>> ts = ktk.TimeSeries(time=np.arange(10)/10)
>>> ts = ts.add_event(0.2, "event")
>>> ts = ts.add_event(0.36, "event")
>>> ts.time
array([0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])
>>> ts.get_index_at_event("event")
2
>>> ts.get_index_at_event("event", occurrence=1)
4