def detect(self, stream, threshold, threshold_type, trig_int, plotvar,<EOL>daylong=False, parallel_process=True, xcorr_func=None,<EOL>concurrency=None, cores=None, ignore_length=False,<EOL>group_size=None, overlap="<STR_LIT>", debug=<NUM_LIT:0>,<EOL>full_peaks=False, save_progress=False,<EOL>process_cores=None, **kwargs):
party = Party()<EOL>template_groups = []<EOL>for master in self.templates:<EOL><INDENT>for group in template_groups:<EOL><INDENT>if master in group:<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>new_group = [master]<EOL>for slave in self.templates:<EOL><INDENT>if master.same_processing(slave) and master != slave:<EOL><INDENT>new_group.append(slave)<EOL><DEDENT><DEDENT>template_groups.append(new_group)<EOL><DEDENT><DEDENT>for group in template_groups:<EOL><INDENT>if len(group) == <NUM_LIT:0>:<EOL><INDENT>template_groups.remove(group)<EOL><DEDENT><DEDENT>for group in template_groups:<EOL><INDENT>group_party = _group_detect(<EOL>templates=group, stream=stream.copy(), threshold=threshold,<EOL>threshold_type=threshold_type, trig_int=trig_int,<EOL>plotvar=plotvar, group_size=group_size, pre_processed=False,<EOL>daylong=daylong, parallel_process=parallel_process,<EOL>xcorr_func=xcorr_func, concurrency=concurrency, cores=cores,<EOL>ignore_length=ignore_length, overlap=overlap, debug=debug,<EOL>full_peaks=full_peaks, process_cores=process_cores, **kwargs)<EOL>party += group_party<EOL>if save_progress:<EOL><INDENT>party.write("<STR_LIT>")<EOL><DEDENT><DEDENT>if len(party) > <NUM_LIT:0>:<EOL><INDENT>for family in party:<EOL><INDENT>if family is not None:<EOL><INDENT>family.detections = family._uniq().detections<EOL><DEDENT><DEDENT><DEDENT>return party<EOL>
Detect using a Tribe of templates within a continuous stream.

: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 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 information 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 procesisng and detection.
: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 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 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.findpeak.find_peaks2_short`
:type save_progress: bool
:param save_progress:
    Whether to save the resulting party at every data step or not.
    Useful for long-running processes.
: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.

.. Note::
    `stream` must not be pre-processed. If your data contain gaps
    you should *NOT* fill those gaps before using this method.
    The pre-process functions (called within) will fill the gaps
    internally prior to processing, process the data, then re-fill
    the gaps with zeros to ensure correlations are not incorrectly
    calculated within gaps. If your data have gaps you should pass a
    merged stream without the `fill_value` argument
    (e.g.: `stream = stream.merge()`).

.. Note::
    Detections are not corrected for `pre-pick`, the
    detection.detect_time corresponds to the beginning of the earliest
    template channel at detection.

.. warning::
    Picks included in the output Party.get_catalog() will not be
    corrected for pre-picks in the template.

.. note::
    **Data overlap:**

    Internally this routine shifts and trims the data according to the
    offsets in the template (e.g. if trace 2 starts 2 seconds after
    trace 1 in the template then the continuous data will be shifted
    by 2 seconds to align peak correlations prior to summing).
    Because of this, detections at the start and end of continuous
    data streams **may be missed**.  The maximum time-period that
    might be missing detections is the maximum offset in the template.

    To work around this, if you are conducting matched-filter
    detections through long-duration continuous data, we suggest
    using some overlap (a few seconds, on the order of the maximum
    offset in the templates) in the continuous data.  You will then
    need to post-process the detections (which should be done anyway
    to remove duplicates).  See below note for how `overlap` argument
    affects data internally if `stream` is longer than the processing
    length.

.. Note::
    If `stream` is longer than processing length, this routine will
    ensure that data overlap between loops, which will lead to no
    missed detections at data start-stop points (see above note).
    This will result in end-time not being strictly
    honoured, so detections may occur after the end-time set.  This is
    because data must be run in the correct process-length.

.. note::
    **Thresholding:**

    **MAD** threshold is calculated as the:

    .. math::

        threshold {\\times} (median(abs(cccsum)))

    where :math:`cccsum` is the cross-correlation sum for a given
    template.

    **absolute** threshold is a true absolute threshold based on the
    cccsum value.

    **av_chan_corr** is based on the mean values of single-channel
    cross-correlations assuming all data are present as required for
    the template, e.g:

    .. math::

        av\_chan\_corr\_thresh=threshold \\times (cccsum /
        len(template))

    where :math:`template` is a single template from the input and the
    length is the number of channels within this template.