def _group_detect(templates, stream, threshold, threshold_type, trig_int,<EOL>plotvar, group_size=None, pre_processed=False, daylong=False,<EOL>parallel_process=True, xcorr_func=None, concurrency=None,<EOL>cores=None, ignore_length=False, overlap="<STR_LIT>",<EOL>debug=<NUM_LIT:0>, full_peaks=False, process_cores=None, **kwargs):
master = templates[<NUM_LIT:0>]<EOL>lap = <NUM_LIT:0.0><EOL>for template in templates:<EOL><INDENT>starts = [t.stats.starttime for t in template.st.sort(['<STR_LIT>'])]<EOL>if starts[-<NUM_LIT:1>] - starts[<NUM_LIT:0>] > lap:<EOL><INDENT>lap = starts[-<NUM_LIT:1>] - starts[<NUM_LIT:0>]<EOL><DEDENT>if not template.same_processing(master):<EOL><INDENT>raise MatchFilterError('<STR_LIT>')<EOL><DEDENT><DEDENT>if overlap is None:<EOL><INDENT>overlap = <NUM_LIT:0.0><EOL><DEDENT>elif not isinstance(overlap, float) and str(overlap) == str("<STR_LIT>"):<EOL><INDENT>overlap = lap<EOL><DEDENT>elif not isinstance(overlap, float):<EOL><INDENT>raise NotImplementedError(<EOL>"<STR_LIT>" % str(overlap))<EOL><DEDENT>if not pre_processed:<EOL><INDENT>if process_cores is None:<EOL><INDENT>process_cores = cores<EOL><DEDENT>streams = _group_process(<EOL>template_group=templates, parallel=parallel_process, debug=debug,<EOL>cores=process_cores, stream=stream, daylong=daylong,<EOL>ignore_length=ignore_length, overlap=overlap)<EOL><DEDENT>else:<EOL><INDENT>warnings.warn('<STR_LIT>')<EOL>streams = [stream]<EOL><DEDENT>detections = []<EOL>party = Party()<EOL>if group_size is not None:<EOL><INDENT>n_groups = int(len(templates) / group_size)<EOL>if n_groups * group_size < len(templates):<EOL><INDENT>n_groups += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>n_groups = <NUM_LIT:1><EOL><DEDENT>for st_chunk in streams:<EOL><INDENT>debug_print(<EOL>'<STR_LIT>' %<EOL>(st_chunk[<NUM_LIT:0>].stats.starttime, st_chunk[<NUM_LIT:0>].stats.endtime), <NUM_LIT:0>, debug)<EOL>st_chunk.trim(starttime=st_chunk[<NUM_LIT:0>].stats.starttime,<EOL>endtime=st_chunk[<NUM_LIT:0>].stats.endtime)<EOL>for tr in st_chunk:<EOL><INDENT>if len(tr) > len(st_chunk[<NUM_LIT:0>]):<EOL><INDENT>tr.data = tr.data[<NUM_LIT:0>:len(st_chunk[<NUM_LIT:0>])]<EOL><DEDENT><DEDENT>for i in range(n_groups):<EOL><INDENT>if group_size is not None:<EOL><INDENT>end_group = (i + <NUM_LIT:1>) * group_size<EOL>start_group = i * group_size<EOL>if i == n_groups:<EOL><INDENT>end_group = len(templates)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>end_group = len(templates)<EOL>start_group = <NUM_LIT:0><EOL><DEDENT>template_group = [t for t in templates[start_group: end_group]]<EOL>detections += match_filter(<EOL>template_names=[t.name for t in template_group],<EOL>template_list=[t.st for t in template_group], st=st_chunk,<EOL>xcorr_func=xcorr_func, concurrency=concurrency,<EOL>threshold=threshold, threshold_type=threshold_type,<EOL>trig_int=trig_int, plotvar=plotvar, debug=debug, cores=cores,<EOL>full_peaks=full_peaks, peak_cores=process_cores, **kwargs)<EOL>for template in template_group:<EOL><INDENT>family = Family(template=template, detections=[])<EOL>for detection in detections:<EOL><INDENT>if detection.template_name == template.name:<EOL><INDENT>family.detections.append(detection)<EOL><DEDENT><DEDENT>party += family<EOL><DEDENT><DEDENT><DEDENT>return party<EOL>
Pre-process and compute detections for a group of templates.

Will process the stream object, so if running in a loop, you will want
to copy the stream before passing it to this function.

:type templates: list
:param templates: List of :class:`eqcorrscan.core.match_filter.Template`
:type stream: `obspy.core.stream.Stream`
:param stream: Continuous data to detect within using the Template.
:type threshold: float
:param threshold:
    Threshold level, if using `threshold_type='MAD'` then this will be
    the multiple of the median absolute deviation.
:type threshold_type: str
:param threshold_type:
    The type of threshold to be used, can be MAD, absolute or
    av_chan_corr.  See Note on thresholding below.
:type trig_int: float
:param trig_int:
    Minimum gap between detections in seconds. If multiple detections
    occur within trig_int of one-another, the one with the highest
    cross-correlation sum will be selected.
:type plotvar: bool
:param plotvar:
    Turn plotting on or off, see warning about plotting below.
:type group_size: int
:param group_size:
    Maximum number of templates to run at once, use to reduce memory
    consumption, if unset will use all templates.
:type pre_processed: bool
:param pre_processed:
    Set to True if `stream` has already undergone processing, in this
    case eqcorrscan will only check that the sampling rate is correct.
    Defaults to False, which will use the
    :mod:`eqcorrscan.utils.pre_processing` routines to resample and
    filter the continuous data.
:type daylong: bool
:param daylong:
    Set to True to use the
    :func:`eqcorrscan.utils.pre_processing.dayproc` routine, which
    preforms additional checks and is more efficient for day-long data
    over other methods.
:type parallel_process: bool
:param parallel_process:
:type xcorr_func: str or callable
:param xcorr_func:
    A str of a registered xcorr function or a callable for implementing
    a custom xcorr function. For more details see:
    :func:`eqcorrscan.utils.correlate.register_array_xcorr`
:type concurrency: str
:param concurrency:
    The type of concurrency to apply to the xcorr function. Options are
    'multithread', 'multiprocess', 'concurrent'. For more details see
    :func:`eqcorrscan.utils.correlate.get_stream_xcorr`
:type cores: int
:param cores: Number of workers for processing and correlation.
:type ignore_length: bool
:param ignore_length:
    If using daylong=True, then dayproc will try check that the data
    are there for at least 80% of the day, if you don't want this check
    (which will raise an error if too much data are missing) then set
    ignore_length=True.  This is not recommended!
:type overlap: float
:param overlap:
    Either None, "calculate" or a float of number of seconds to
    overlap detection streams by.  This is to counter the effects of
    the delay-and-stack in calculating cross-correlation sums. Setting
    overlap = "calculate" will work out the appropriate overlap based
    on the maximum lags within templates.
:type debug: int
:param debug:
    Debug level from 0-5 where five is more output, for debug levels
    4 and 5, detections will not be computed in parallel.
:type full_peaks: bool
:param full_peaks: See `eqcorrscan.utils.findpeaks.find_peaks2_short`
:type process_cores: int
:param process_cores:
    Number of processes to use for pre-processing (if different to
    `cores`).

:return:
    :class:`eqcorrscan.core.match_filter.Party` of families of detections.