def _detect(detector, st, threshold, trig_int, moveout=<NUM_LIT:0>, min_trig=<NUM_LIT:0>,<EOL>process=True, extract_detections=False, cores=<NUM_LIT:1>, debug=<NUM_LIT:0>):
detections = []<EOL>if process:<EOL><INDENT>debug_print('<STR_LIT>', <NUM_LIT:0>, debug)<EOL>stream, stachans = _subspace_process(<EOL>streams=[st.copy()], lowcut=detector.lowcut,<EOL>highcut=detector.highcut, filt_order=detector.filt_order,<EOL>sampling_rate=detector.sampling_rate, multiplex=detector.multiplex,<EOL>stachans=detector.stachans, parallel=True, align=False,<EOL>shift_len=None, reject=False, cores=cores)<EOL><DEDENT>else:<EOL><INDENT>for tr in st:<EOL><INDENT>if not tr.stats.sampling_rate == detector.sampling_rate:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>stream = [st]<EOL>stachans = detector.stachans<EOL><DEDENT>outtic = time.clock()<EOL>if detector.multiplex:<EOL><INDENT>Nc = len(detector.stachans)<EOL><DEDENT>else:<EOL><INDENT>Nc = <NUM_LIT:1><EOL><DEDENT>fft_vars = _do_ffts(detector, stream, Nc)<EOL>debug_print('<STR_LIT>', <NUM_LIT:0>, debug)<EOL>debug_print('<STR_LIT>', <NUM_LIT:0>, debug)<EOL>stats = np.zeros((len(stream[<NUM_LIT:0>]),<EOL>(len(stream[<NUM_LIT:0>][<NUM_LIT:0>]) // Nc) - (fft_vars[<NUM_LIT:4>] // Nc) + <NUM_LIT:1>))<EOL>for det_freq, data_freq_sq, data_freq, i in zip(fft_vars[<NUM_LIT:0>], fft_vars[<NUM_LIT:1>],<EOL>fft_vars[<NUM_LIT:2>],<EOL>np.arange(len(stream[<NUM_LIT:0>]))):<EOL><INDENT>stats[i] = _det_stat_freq(det_freq, data_freq_sq, data_freq,<EOL>fft_vars[<NUM_LIT:3>], Nc, fft_vars[<NUM_LIT:4>], fft_vars[<NUM_LIT:5>])<EOL>debug_print('<STR_LIT>' % str(stats[i].shape), <NUM_LIT:0>, debug)<EOL>if debug >= <NUM_LIT:3>:<EOL><INDENT>fig, ax = plt.subplots()<EOL>t = np.arange(len(stats[i]))<EOL>ax.plot(t, stats[i], color='<STR_LIT:k>')<EOL>ax.axis('<STR_LIT>')<EOL>ax.set_ylim([<NUM_LIT:0>, <NUM_LIT:1>])<EOL>ax.plot([min(t), max(t)], [threshold, threshold], color='<STR_LIT:r>', lw=<NUM_LIT:1>,<EOL>label='<STR_LIT>')<EOL>ax.legend()<EOL>plt.title('<STR_LIT:%s>' % str(stream[<NUM_LIT:0>][i].stats.station))<EOL>plt.show()<EOL><DEDENT><DEDENT>trig_int_samples = detector.sampling_rate * trig_int<EOL>debug_print('<STR_LIT>', <NUM_LIT:0>, debug)<EOL>peaks = []<EOL>for i in range(len(stream[<NUM_LIT:0>])):<EOL><INDENT>peaks.append(findpeaks.find_peaks2_short(<EOL>arr=stats[i], thresh=threshold, trig_int=trig_int_samples,<EOL>debug=debug))<EOL><DEDENT>if not detector.multiplex:<EOL><INDENT>peaks = findpeaks.coin_trig(<EOL>peaks=peaks, samp_rate=detector.sampling_rate, moveout=moveout,<EOL>min_trig=min_trig, stachans=stachans, trig_int=trig_int)<EOL><DEDENT>else:<EOL><INDENT>peaks = peaks[<NUM_LIT:0>]<EOL><DEDENT>if len(peaks) > <NUM_LIT:0>:<EOL><INDENT>for peak in peaks:<EOL><INDENT>detecttime = st[<NUM_LIT:0>].stats.starttime +(peak[<NUM_LIT:1>] / detector.sampling_rate)<EOL>rid = ResourceIdentifier(<EOL>id=detector.name + '<STR_LIT:_>' + str(detecttime), prefix='<STR_LIT>')<EOL>ev = Event(resource_id=rid)<EOL>cr_i = CreationInfo(<EOL>author='<STR_LIT>', creation_time=UTCDateTime())<EOL>ev.creation_info = cr_i<EOL>thresh_str = '<STR_LIT>' + str(threshold)<EOL>ccc_str = '<STR_LIT>' + str(peak[<NUM_LIT:0>])<EOL>used_chans = '<STR_LIT>' +'<STR_LIT:U+0020>'.join([str(pair) for pair in detector.stachans])<EOL>ev.comments.append(Comment(text=thresh_str))<EOL>ev.comments.append(Comment(text=ccc_str))<EOL>ev.comments.append(Comment(text=used_chans))<EOL>for stachan in detector.stachans:<EOL><INDENT>tr = st.select(station=stachan[<NUM_LIT:0>], channel=stachan[<NUM_LIT:1>])<EOL>if tr:<EOL><INDENT>net_code = tr[<NUM_LIT:0>].stats.network<EOL><DEDENT>else:<EOL><INDENT>net_code = '<STR_LIT>'<EOL><DEDENT>pick_tm = detecttime<EOL>wv_id = WaveformStreamID(<EOL>network_code=net_code, station_code=stachan[<NUM_LIT:0>],<EOL>channel_code=stachan[<NUM_LIT:1>])<EOL>ev.picks.append(Pick(time=pick_tm, waveform_id=wv_id))<EOL><DEDENT>detections.append(<EOL>Detection(template_name=detector.name, detect_time=detecttime,<EOL>no_chans=len(detector.stachans), detect_val=peak[<NUM_LIT:0>],<EOL>threshold=threshold, typeofdet='<STR_LIT>',<EOL>threshold_type='<STR_LIT>', threshold_input=threshold,<EOL>chans=detector.stachans, event=ev))<EOL><DEDENT><DEDENT>outtoc = time.clock()<EOL>print('<STR_LIT>' % str(outtoc - outtic))<EOL>if extract_detections:<EOL><INDENT>detection_streams = extract_from_stream(st, detections)<EOL>return detections, detection_streams<EOL><DEDENT>return detections<EOL>
Detect within continuous data using the subspace method.

Not to be called directly, use the detector.detect method.

:type detector: eqcorrscan.core.subspace.Detector
:param detector: Detector to use.
:type st: obspy.core.stream.Stream
:param st: Un-processed stream to detect within using the subspace \
    detector
:type threshold: float
:param threshold: Threshold value for detections between 0-1
:type trig_int: float
:param trig_int: Minimum trigger interval in seconds.
:type moveout: float
:param moveout: Maximum allowable moveout window for non-multiplexed,
    network detection.  See note.
:type min_trig: int
:param min_trig: Minimum number of stations exceeding threshold for \
    non-multiplexed, network detection. See note.
:type process: bool
:param process: Whether or not to process the stream according to the \
    parameters defined by the detector.  Default is to process the \
    data (True).
:type extract_detections: bool
:param extract_detections: Whether to extract waveforms for each \
    detection or not, if true will return detections and streams.
:type debug: int
:param debug: Debug output level from 0-5.

:return: list of detections
:rtype: list of eqcorrscan.core.match_filter.Detection