pyyeti.dsp.get_turning_pts

pyyeti.dsp.get_turning_pts(y, x=None, getindex=True, tol=1e-06, atol=None)[source]

Find turning points (where slope changes) in a vector.

Parameters:
  • y (array_like) – y-axis data vector

  • x (array_like or None; optional) – If vector, x-axis data vector; must be monotonically ascending and same length as y. If None, the index is used.

  • getindex (bool, optional) – If True, return the index of turning points; otherwise, return the y (and x) data values at the turning points.

  • tol (scalar; optional) – A slope is considered different from a neighbor if the difference is more than tol*max(abs(all differences)).

  • atol (scalar or None; optional) – Alternative to tol. If input (and non-zero), atol specifies the absolute tolerance and tol is ignored. In this case, slope is considered different from a neighbor if the difference is more than atol.

Returns:

  • pv (ndarray; if getindex is True) – True/False vector with True for the turning points in y.

  • yn, xn (ndarray, ndarray or None; if getindex is False) – The possibly shortened versions of y and x; if x is None, xn is None.

Examples

>>> from pyyeti import dsp
>>> dsp.get_turning_pts([1, 2, 3, 3, 3])
array([ True, False,  True, False,  True], dtype=bool)
>>> y, x = dsp.get_turning_pts([1, 2, 3, 3, 3],
...                            [1, 2, 3, 4, 5],
...                            getindex=False)
>>> y
array([1, 3, 3])
>>> x
array([1, 3, 5])