5.3. findpeaks¶
Functions to find peaks in data above a certain threshold.
copyright: | Calum Chamberlain, Chet Hopp. |
---|---|
license: | GNU Lesser General Public License, Version 3 (https://www.gnu.org/copyleft/lesser.html) |
-
findpeaks.
find_peaks2
(arr, thresh, trig_int, debug=0, maxwidth=10, starttime=False, samp_rate=1.0)[source]¶ Function to determine peaks in an array of data using scipy find_peaks_cwt, works fast in certain cases, but for match_filter cccsum peak finding, find_peaks2_short works better. Test it out and see which works best for your application.
Parameters: - arr (ndarray) – 1-D numpy array is required
- thresh (float) – The threshold below which will be considered noise and
peaks will not be found in. :type trig_int: int :param trig_int: The minimum difference in samples between triggers, if multiple peaks within this window this code will find the highest. :type debug: int :param debug: Optional, debug level 0-5 :type maxwidth: int :param maxwidth: Maximum peak width to look for in samples :type starttime: osbpy.UTCDateTime :param starttime: Starttime for plotting, only used if debug > 2. :type samp_rate: float :param samp_rate: Sampling rate in Hz, only used for plotting if debug > 2.
Returns: peaks: Lists of tuples of peak values and locations.
-
findpeaks.
find_peaks2_short
(arr, thresh, trig_int, debug=0, starttime=False, samp_rate=1.0)[source]¶ Function to determine peaks in an array of data above a certain threshold. Uses a mask to remove data below threshold and finds peaks in what is left.
Parameters: - arr (ndarray) – 1-D numpy array is required
- thresh (float) – The threshold below which will be considered noise and peaks will not be found in.
- trig_int (int) – The minimum difference in samples between triggers,if multiple peaks within this window this code will find the highest.
- debug (int) – Optional, debug level 0-5
- starttime (osbpy.UTCDateTime) – Starttime for plotting, only used if debug > 2.
- samp_rate (float) – Sampling rate in Hz, only used for plotting if debug > 2.
Returns: peaks: Lists of tuples of peak values and locations.
-
findpeaks.
find_peaks_dep
(arr, thresh, trig_int, debug=0, starttime=False, samp_rate=1.0)[source]¶ Function to determine peaks in an array of data above a certain threshold.
Depreciated peak-finding routine, very slow, but accurate. If all else fails this one should work.
Parameters: - arr (ndarray) – 1-D numpy array is required
- thresh (float) – The threshold below which will be considered noise and peaks will not be found in.
- trig_int (int) – The minimum difference in samples between triggers,if multiple peaks within this window this code will find the highest.
- starttime (osbpy.UTCDateTime) – Starttime for plotting, only used if debug > 2.
- samp_rate (float) – Sampling rate in Hz, only used for plotting if debug > 2.
Returns: peaks: Lists of tuples of peak values and locations.
-
findpeaks.
is_prime
(number)[source]¶ Function to test primality of a number. Function lifted from online resource:
- This function is distributed under a seperate licence:
- This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Parameters: number (int) – Integer to test for primality Returns: bool