ktk.TimeSeries.get_index_after_event

ktk.TimeSeries.get_index_after_event#

TimeSeries.get_index_after_event(name, occurrence=0, inclusive=False)[source]#

Get the time index that is just after the specified event occurrence.

Parameters:
  • name (str) – Event name

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

  • inclusive (bool) – True to allow including one sample before the event if needed, to make sure that the event time is part of the output TimeSeries’s time. False to make sure that the returned TimeSeries does not include the event time. Default is False.

Returns:

The index in the time attribute.

Return type:

int

Raises:

TimeSeriesRangeError – If the resulting index would be outside the TimeSeries range.

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_after_event("event")
3
>>> ts.get_index_after_event("event", occurrence=1)
4
>>> ts.get_index_after_event("event", inclusive=True)
2