linetrack

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

Track individual “lines” across lists of coordinates.

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

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

  • sep (float, optional) – The maximum separation between points belonging to the same “track”. Larger separations will cause the algorithm to begin a new track. The default behavior is to not separate into tracks this way.

  • seed (float or list of float, optional) – The track or tracks you want the algorithm to pick up if the number of tracks is limited by ntrack.

  • ntrack (int, optional) – The maximum number of values to be simultaneously tracked. This can be set to a low value to ignore spurious values in combination with seed. The default value is the maximum xs sublist length.

Returns

  • xs_sorted (ndarray) – 2D array of x coordinates whose columns correspond to individual “lines”. New “lines” 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.

Example

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