ktk.TimeSeries.get_ts_between_times#

TimeSeries.get_ts_between_times(time1, time2, *, inclusive=False)[source]#

Get a TimeSeries between two specified times.

Parameters
  • time1 (float) – Times to look for in the TimeSeries’ time vector.

  • time2 (float) – Times to look for in the TimeSeries’ time vector.

  • inclusive (bool | tuple[bool, bool]) –

    Optional. Either a bool or a tuple of two bools. Used to specify which times are returned:

    • False or (False, False) (default): time1 < time < time2

    • True or (True, True): time1 <= time <= time2

    • (True, False): time1 <= time < time2

    • (False, True): time1 < time <= time2

Returns

A new TimeSeries that fulfils the specified conditions.

Return type

TimeSeries

Raises

TimeSeriesRangeError – If there is no data between the specified times.

Example

>>> ts = ktk.TimeSeries(time=np.arange(10)/10)
>>> ts.time
array([0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])
>>> ts.get_ts_between_times(0.2, 0.5).time
array([0.3, 0.4])
>>> ts.get_ts_between_times(0.2, 0.5, inclusive=True).time
array([0.2, 0.3, 0.4, 0.5])
>>> ts.get_ts_between_times(0.2, 0.5, inclusive=[True, False]).time
array([0.2, 0.3, 0.4])