ktk.TimeSeries.get_ts_between_indexes#

TimeSeries.get_ts_between_indexes(index1, index2, *, inclusive=False)[source]#

Get a TimeSeries between two specified time indexes.

Parameters
  • index1 (int) – Time indexes

  • index2 (int) – Time indexes

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

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

    • False or (False, False) (default): index1 < index < index2

    • True or (True, True): index1 <= index <= index2

    • (True, False): index1 <= index < index2

    • (False, True): index1 < index <= index2

Returns

A new TimeSeries that fulfils the specified conditions.

Return type

TimeSeries

Raises

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

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_indexes(2, 5).time
array([0.3, 0.4])
>>> ts.get_ts_between_indexes(2, 5, inclusive=True).time
array([0.2, 0.3, 0.4, 0.5])
>>> ts.get_ts_between_indexes(2, 5, inclusive=[True, False]).time
array([0.2, 0.3, 0.4])