def _find_detections(cum_net_resp, nodes, threshold, thresh_type,<EOL>samp_rate, realstations, length):
cum_net_resp = np.nan_to_num(cum_net_resp)  <EOL>if np.isnan(cum_net_resp).any():<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>print('<STR_LIT>' + str(np.median(cum_net_resp)))<EOL>print('<STR_LIT>' + str(np.sqrt(np.mean(np.square(cum_net_resp)))))<EOL>print('<STR_LIT>' + str(np.median(np.abs(cum_net_resp))))<EOL>if thresh_type == '<STR_LIT>':<EOL><INDENT>thresh = (np.median(np.abs(cum_net_resp)) * threshold)<EOL><DEDENT>elif thresh_type == '<STR_LIT>':<EOL><INDENT>thresh = threshold<EOL><DEDENT>elif thresh_type == '<STR_LIT>':<EOL><INDENT>thresh = _rms(cum_net_resp) * threshold<EOL><DEDENT>print('<STR_LIT>' + str(thresh))<EOL>print('<STR_LIT>' + str(max(cum_net_resp)))<EOL>peaks = findpeaks.find_peaks2_short(cum_net_resp, thresh,<EOL>length * samp_rate, debug=<NUM_LIT:0>)<EOL>detections = []<EOL>if peaks:<EOL><INDENT>for peak in peaks:<EOL><INDENT>node = nodes[peak[<NUM_LIT:1>]]<EOL>detections.append(<EOL>Detection(template_name=str(node[<NUM_LIT:0>]) + '<STR_LIT:_>' +<EOL>str(node[<NUM_LIT:1>]) + '<STR_LIT:_>' + str(node[<NUM_LIT:2>]),<EOL>detect_time=peak[<NUM_LIT:1>] / samp_rate,<EOL>no_chans=len(realstations), detect_val=peak[<NUM_LIT:0>],<EOL>threshold=thresh, typeofdet='<STR_LIT>',<EOL>chans=realstations, id=str(node[<NUM_LIT:0>]) + '<STR_LIT:_>' +<EOL>str(node[<NUM_LIT:1>]) + '<STR_LIT:_>' + str(node[<NUM_LIT:2>]) +<EOL>str(peak[<NUM_LIT:1>] / samp_rate),<EOL>threshold_type=thresh_type,<EOL>threshold_input=threshold))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>detections = []<EOL><DEDENT>print('<STR_LIT>' + str(len(peaks)) + '<STR_LIT>')<EOL>return detections<EOL>
Find detections within the cumulative network response.

:type cum_net_resp: numpy.ndarray
:param cum_net_resp: Array of cumulative network response for nodes
:type nodes: list
:param nodes: Nodes associated with the source of energy in the \
    cum_net_resp
:type threshold: float
:param threshold: Threshold value
:type thresh_type: str
:param thresh_type: Either MAD (Median Absolute Deviation) or abs \
    (absolute) or RMS (Root Mean Squared)
:type samp_rate: float
:param samp_rate: Sampling rate in Hz
:type realstations: list
:param realstations:
    List of stations used to make the cumulative network response, will be
    reported in the :class:`eqcorrscan.core.match_filter.Detection`
:type length: float
:param length: Maximum length of peak to look for in seconds

:returns:
    Detections as :class:`eqcorrscan.core.match_filter.Detection` objects.
:rtype: list