perda.utils.time_alignment#

perda.utils.time_alignment.apply_time_offset(di, offset_s, source_time_unit=Timescale.MS)[source]#

Shift signals in time by a fixed offset, but keeping the same timestamp list.

Shifts the values, not the timestamps. Create a new time series with the same values offset_s away, then re-interpolate the original timestamps onto this series.

Parameters:
  • di (DataInstance | list[DataInstance]) – Input signal(s). Lists are processed independently.

  • offset_s (float) – Time shift in seconds (positive shifts the signal later).

  • source_time_unit (Timescale, optional) – Timestamp unit of di.timestamp_np. Default is Timescale.MS.

Returns:

New DataInstance(s) with time-shifted value_np on the original timestamp grid.

Return type:

DataInstance | list[DataInstance]

Examples

>>> di_aligned = apply_time_offset(gps_speed_di, offset_s=-0.08)
>>> a, b = apply_time_offset([di_a, di_b], offset_s=0.05)