def find_peaks2_short(arr, thresh, trig_int, debug=<NUM_LIT:0>, starttime=False,<EOL>samp_rate=<NUM_LIT:1.0>, full_peaks=False):
if not starttime:<EOL><INDENT>starttime = UTCDateTime(<NUM_LIT:0>)<EOL><DEDENT>image = np.copy(arr)<EOL>image = np.abs(image)<EOL>debug_print("<STR_LIT>".format(thresh, max(image)),<EOL><NUM_LIT:2>, debug)<EOL>image[image < thresh] = <NUM_LIT:0><EOL>if len(image[image > thresh]) == <NUM_LIT:0>:<EOL><INDENT>debug_print("<STR_LIT>".format(thresh), <NUM_LIT:0>, debug)<EOL>return []<EOL><DEDENT>debug_print('<STR_LIT>'.format(<EOL>len(image[image > thresh])), <NUM_LIT:0>, debug)<EOL>initial_peaks = []<EOL>labeled_image, number_of_objects = ndimage.label(image)<EOL>peak_slices = ndimage.find_objects(labeled_image)<EOL>for peak_slice in peak_slices:<EOL><INDENT>window = arr[peak_slice[<NUM_LIT:0>].start: peak_slice[<NUM_LIT:0>].stop]<EOL>if peak_slice[<NUM_LIT:0>].stop - peak_slice[<NUM_LIT:0>].start > trig_int and full_peaks:<EOL><INDENT>peaks = decluster(<EOL>peaks=window, trig_int=trig_int,<EOL>index=np.arange(peak_slice[<NUM_LIT:0>].start, peak_slice[<NUM_LIT:0>].stop))<EOL><DEDENT>else:<EOL><INDENT>peaks = [(window[np.argmax(abs(window))],<EOL>int(peak_slice[<NUM_LIT:0>].start + np.argmax(abs(window))))]<EOL><DEDENT>initial_peaks.extend(peaks)<EOL><DEDENT>peaks = decluster(peaks=np.array(list(zip(*initial_peaks))[<NUM_LIT:0>]),<EOL>index=np.array(list(zip(*initial_peaks))[<NUM_LIT:1>]),<EOL>trig_int=trig_int)<EOL>if initial_peaks:<EOL><INDENT>if debug >= <NUM_LIT:3>:<EOL><INDENT>from eqcorrscan.utils import plotting<EOL>_fname = '<STR_LIT>'.join([<EOL>'<STR_LIT>', starttime.datetime.strftime('<STR_LIT>'), '<STR_LIT>'])<EOL>plotting.peaks_plot(<EOL>data=image, starttime=starttime, samp_rate=samp_rate,<EOL>save=True, peaks=peaks, savefile=_fname)<EOL><DEDENT>peaks = sorted(peaks, key=lambda time: time[<NUM_LIT:1>], reverse=False)<EOL>return peaks<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL>return []<EOL><DEDENT>
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.

:type arr: numpy.ndarray
:param arr: 1-D numpy array is required
:type thresh: float
:param thresh:
    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 starttime: obspy.core.utcdatetime.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.
:type full_peaks: bool
:param full_peaks:
    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.

:return: peaks: Lists of tuples of peak values and locations.
:rtype: 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.