tsdive.switchback.cut_blocks
¶
cut_blocks(
times: ndarray, span: float, length: float
) -> Blocks
Blocks of length from time 0, K = schedule_blocks(span, length).
times are measured from the schedule start in the unit of
length. A time before 0 or at or after K * length is outside
the schedule.
Examples:
>>> import numpy as np
>>> from tsdive.switchback import cut_blocks
>>> times = np.array([0.0, 30.0, 60.0, 150.0, 250.0])
>>> blocks = cut_blocks(times, span=240.0, length=60.0)
>>> blocks.k, blocks.block.tolist(), blocks.offset.tolist()
(4, [0, 0, 1, 2, -1], [0.0, 30.0, 0.0, 30.0, 10.0])