ktk.TimeSeries.remove_duplicate_events

ktk.TimeSeries.remove_duplicate_events#

TimeSeries.remove_duplicate_events(*, in_place=False)[source]#

Remove events with same name and time so that each event gets unique.

Parameters:

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.

Returns:

The TimeSeries with only unique events.

Return type:

TimeSeries

Example

>>> ts = ktk.TimeSeries()

Three occurrences of event1:

>>> ts = ts.add_event(0.0, "event1")
>>> ts = ts.add_event(1E-12, "event1")
>>> ts = ts.add_event(0.0, "event1")

One occurrence of event2, but also at 0.0 second:

>>> ts = ts.add_event(0.0, "event2")

Two occurrences of event3:

>>> ts = ts.add_event(2.0, "event3")
>>> ts = ts.add_event(2.0, "event3")
>>> ts.events
[TimeSeriesEvent(time=0.0, name='event1'),
 TimeSeriesEvent(time=0.0, name='event1'),
 TimeSeriesEvent(time=0.0, name='event2'),
 TimeSeriesEvent(time=1e-12, name='event1'),
 TimeSeriesEvent(time=2.0, name='event3'),
 TimeSeriesEvent(time=2.0, name='event3')]
>>> ts2 = ts.remove_duplicate_events()
>>> ts2.events
[TimeSeriesEvent(time=0.0, name='event1'),
 TimeSeriesEvent(time=0.0, name='event2'),
 TimeSeriesEvent(time=2.0, name='event3')]