seg1d.algorithm.get_peaks¶
-
seg1d.algorithm.
get_peaks
(x, minC=0.7, dst=None)[source]¶ Peak Detection
Find the peaks of a data array with a minimum value of a peak and an optional distance parameter.
Relies on
scipy.signal.find_peaks
Parameters: - xDict[int,List[float]]
{scale: [correlations] }
Returns: - n x 3 array
sorted by highest to lowest correlation of form
[ scale, correlation , peak index ]
Other Parameters: - minCfloat, optional
-1 to 1
- dstreal, optional
int or float
See also
combine_corr
- (input for this function)
uniques
- (takes the return of this function)
Examples
>>> import numpy as np >>> import seg1d.algorithm as alg
>>> # convenience function for generating wave >>> def s(f1, f2, f3): return np.sin( np.linspace(f1, f2, f3) )
Define some scales that have correlations
>>> x = { 10: s(-np.pi*1, np.pi*1, 10), 20: s(-np.pi*2, np.pi*2, 10) }
Query the peaks in the data
>>> np.around(alg.get_peaks(x), decimals=7) array([[10. , 0.9848078, 7. ], [20. , 0.9848078, 1. ], [20. , 0.8660254, 6. ]])
Define a minimum for the peak
>>> np.around(alg.get_peaks(x,minC = 0.9), decimals=7) array([[10. , 0.9848078, 7. ], [20. , 0.9848078, 1. ]])