ts2segments (pyleoclim.utils.tsutils.ts2segments)

pyleoclim.utils.tsutils.ts2segments(ys, ts, factor=10)[source]

Chop a time series into several segments based on gap detection.

The rule of gap detection is very simple:

we define the intervals between time points as dts, then if dts[i] is larger than factor * dts[i-1], we think that the change of dts (or the gradient) is too large, and we regard it as a breaking point and chop the time series into two segments here

Parameters
  • ys (array) – A time series, NaNs allowed

  • ts (array) – The time points

  • factor (float) – the factor that adjusts the threshold for gap detection

Returns

  • seg_ys (list) – a list of several segments with potentially different lengths

  • seg_ts (list) – a list of the time axis of the several segments

  • n_segs (int) – the number of segments