linetrack

linetrack(xs, ys=None, /, ntrack=None, seed=None, sep=None)[source]

Track individual “lines” across lists of coordinates.

Parameters
  • xs (list of lists) – The locations to be grouped into tracks.

  • ys (list of lists, optional) – The values corresponding to the locations xs.

  • ntrack (int, optional) – The maximum number of values to be simultaneously tracked. This can be used in combination with seed to ignore spurious tracks. The default value is numpy.inf (i.e. the number of tracks is unlimited).

  • seed (float or list of float, optional) – Seed value(s) for the track(s) that should be picked up at the start. If ntrack is None this has no effect.

  • sep (float, optional) – The maximum separation between points belonging to the same “track”. If a separation is larger than sep the algorithm will begin a new track. Default is numpy.inf (i.e. tracks are never ended due to “large” separations).

Returns

  • xs_sorted (ndarray) – 2D array of x coordinates whose columns correspond to individual “tracks”. Tracks may stop or start at rows in the middle of the array.

  • ys_sorted (ndarray, optional) – The corresponding y coordinates. Returned if ys is not None.

Examples

>>> import climopy as climo
>>> climo.linetrack(
...    [
...        [30, 20],
...        [22],
...        [24],
...        [32, 25],
...        [26, 40, 33],
...        [45],
...        [20, 47],
...        [23, 50],
...    ]
... )
array([[30., 20., nan],
       [nan, 22., nan],
       [nan, 24., nan],
       [32., 25., nan],
       [33., 26., 40.],
       [nan, nan, 45.],
       [20., nan, 47.],
       [23., nan, 50.]])