ktk.TimeSeries.add_event#

TimeSeries.add_event(time, name='event', *, in_place=False, unique=False)[source]#

Add an event to the TimeSeries.

Parameters
  • time (float) – The time of the event, in the same unit as time_info[“Unit”].

  • name (str) – Optional. The name of the event. Default is “event”.

  • in_place (bool) – Optional. True to modify and return the original TimeSeries. False to return a modified copy of the TimeSeries while leaving the original TimeSeries intact. Default is False.

  • unique (bool) – Optional. True to prevent duplicating an already existing event. In this case, if an event with the same time and name already exists, no event is added. Default is False.

Returns

A copy of the TimeSeries with the added event.

Return type

TimeSeries

Example

>>> ts = ktk.TimeSeries()
>>> ts = ts.add_event(5.5, "event1")
>>> ts = ts.add_event(10.8, "event2")
>>> ts = ts.add_event(2.3, "event2")
>>> ts.events
[TimeSeriesEvent(time=5.5, name='event1'),
 TimeSeriesEvent(time=10.8, name='event2'),
 TimeSeriesEvent(time=2.3, name='event2')]