5.7.1.2. eqcorrscan.utils.findpeaks.find_peaks2_short¶
-
eqcorrscan.utils.findpeaks.
find_peaks2_short
(arr, thresh, trig_int, debug=0, starttime=False, samp_rate=1.0, full_peaks=False)[source]¶ 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 (numpy.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 (obspy.core.utcdatetime.UTCDateTime) – Starttime for plotting, only used if debug > 2.
- samp_rate (float) – Sampling rate in Hz, only used for plotting if debug > 2.
- full_peaks (bool) – If True, will remove the issue eluded to below, by declustering within data-sections above the threshold, rather than just taking the peak within that section. This will take more time. This defaults to True for match_filter.
Returns: peaks: Lists of tuples of peak values and locations.
Return type: list
>>> import numpy as np >>> arr = np.random.randn(100) >>> threshold = 10 >>> arr[40] = 20 >>> arr[60] = 100 >>> find_peaks2_short(arr, threshold, 3) [(20.0, 40), (100.0, 60)]
Note
peak-finding is optimised for zero-mean cross-correlation data where fluctuations are frequent. Because of this, in certain cases some peaks may be missed if the trig_int is short and the threshold is low. Consider the following case:
>>> arr = np.array([1, .2, .2, .2, .2, 1, .2, .2, .2, .2, 1]) >>> find_peaks2_short(arr, thresh=.2, trig_int=3) [(1.0, 0)]
Whereas you would expect the following:
>>> arr = np.array([1, .2, .2, .2, .2, 1, .2, .2, .2, .2, 1]) >>> find_peaks2_short(arr, thresh=.2, trig_int=3, full_peaks=True) [(1.0, 0), (1.0, 5), (1.0, 10)]
This is rare and unlikely to happen for correlation cases, where trigger intervals are usually large and thresholds high.