perda.core_data_structures.split_helpers#

perda.core_data_structures.split_helpers.split_single_run_data(data, split_timestamps)[source]#

Split a SingleRunData into segments defined by a list of boundary timestamps.

Each consecutive pair of timestamps in split_timestamps defines one segment. The result is keyed by 1-based segment number.

Parameters:
  • data (SingleRunData)

  • split_timestamps (list[float]) – Ordered boundary timestamps in the same unit as data.timestamp_unit. Must contain at least 2 values.

Returns:

One SingleRunData per consecutive pair of boundaries.

Return type:

List[SingleRunData]

Examples

>>> from perda.core_data_structures import split_single_run_data
>>> data = aly.data
>>> middle = (data.data_start_time + data.data_end_time) / 2
>>> first_half, second_half = split_single_run_data(
...     data, [data.data_start_time, middle, data.data_end_time]
... )
perda.core_data_structures.split_helpers.trim_single_run_data(data, ts_start, ts_end)[source]#

Return a new SingleRunData with every variable trimmed to [ts_start, ts_end].

Parameters:
  • data (SingleRunData)

  • ts_start (float) – Timestamps in the same unit as data.timestamp_unit.

  • ts_end (float) – Timestamps in the same unit as data.timestamp_unit.

Returns:

Fresh object; the original is not mutated.

Return type:

SingleRunData

Examples

>>> from perda.core_data_structures import trim_single_run_data
>>> from perda.units import from_seconds
>>> start = aly.data.data_start_time
>>> first_minute = trim_single_run_data(
...     aly.data, start, start + from_seconds(60.0, aly.data.timestamp_unit)
... )