The clusteror.utils Module

This module works as a transient store of useful functions. New standalone functions will be first placed here. As they grow in number and can be consolidated into an independent class, module, or even a new package.

clusteror.utils.find_local_extremes(series, contrast)[source]

Finds local minima and maxima according to contrast. In theory, they can be determined by first derivative and second derivative. The result derived this way is of no value in dealing with a very noisy, zig-zag data as too many local extremes would be found for any turn-around. The method presented here compares the point currently looked at and the opposite potential extreme that is updated as scanning through the data sequence. For instance, a potential maximum is 10, then a data point of value smaller than 10 / (1 + contrast) is written down as a local minimum.

Parameters:
  • series (Pandas Series) – One dimenional data to find local extremes in.
  • contrast (float) – A value between 0 and 1 as a threshold between minimum and maximum.
Returns:

  • local_min_inds (list) – List of indices for local minima.
  • local_mins (list) – List of minimum values.
  • local_max_inds (list) – List of indices for local maxima.
  • local_maxs (list) – List of maximum values.