core.match_filter.detection

Functions for network matched-filter detection of seismic data.

Designed to cross-correlate templates generated by template_gen function with data and output the detections.

copyright:EQcorrscan developers.
license:GNU Lesser General Public License, Version 3 (https://www.gnu.org/copyleft/lesser.html)

class eqcorrscan.core.match_filter.detection.Detection(template_name, detect_time, no_chans, detect_val, threshold, typeofdet, threshold_type, threshold_input, chans=None, event=None, id=None)[source]

Bases: object

Single detection from detection routines in eqcorrscan. Information required for a full detection based on cross-channel correlation sums.

Parameters:
  • template_name (str) – The name of the template for which this detection was made.
  • detect_time (obspy.core.utcdatetime.UTCDateTime) – Time of detection as an obspy UTCDateTime object
  • no_chans (int) – The number of channels for which the cross-channel correlation sum was calculated over.
  • detect_val (float) – The raw value of the cross-channel correlation sum for this detection.
  • threshold (float) – The value of the threshold used for this detection, will be the raw threshold value related to the cccsum.
  • typeofdet (str) – Type of detection, STA, corr, bright
  • threshold_type (str) – Type of threshold used for detection
  • threshold_input (float) – Threshold set for detection, relates to threshold according to the threshold_type.
  • chans (list) – List of stations for the detection
  • event (obspy.core.event.event.Event) – Obspy Event object for this detection, note that this is lost when writing to a Detection objects to csv files using eqcorrscan.core.match_filter.Detection.write()
  • id (str) – Identification for detection (should be unique).

Methods

copy() Returns a copy of the detection.
extract_stream(stream, length, prepick) Extract a cut stream of a given length around the detection.
write(fname[, append]) Write detection to csv formatted file.
__init__(template_name, detect_time, no_chans, detect_val, threshold, typeofdet, threshold_type, threshold_input, chans=None, event=None, id=None)[source]

Main class of Detection.

copy()[source]

Returns a copy of the detection.

Returns:Copy of detection
extract_stream(stream, length, prepick)[source]

Extract a cut stream of a given length around the detection.

Parameters:
  • stream (obspy.core.stream.Stream) – Stream of data to cut from
  • length (float) – Length of data to extract in seconds.
  • prepick (float) – Length before the expected pick on each channel to start the cut stream in seconds.
Return type:

obspy.core.stream.Stream

write(fname, append=True)[source]

Write detection to csv formatted file.

Will append if append==True and file exists

Parameters:
  • fname (str) – Full path to file to open and write to.
  • append (bool) – Set to true to append to an existing file, if True and file doesn’t exist, will create new file and warn. If False will overwrite old files.

Functions

eqcorrscan.core.match_filter.detection.read_detections(fname, encoding='UTF8')[source]

Read detections from a file to a list of Detection objects.

Parameters:
  • fname (str) – File to read from, must be a file written to by Detection.write.
  • encoding (str) – Encoding used for detection file.
Returns:

list of eqcorrscan.core.match_filter.Detection

Return type:

list

Note

eqcorrscan.core.match_filter.detection.Detection’s returned do not contain Detection.event

eqcorrscan.core.match_filter.detection.write_catalog(detections, fname, format='QUAKEML')[source]

Write events contained within detections to a catalog file.

Parameters:
  • detections (list) – list of eqcorrscan.core.match_filter.Detection
  • fname (str) – Name of the file to write to
  • format (str) – File format to use, see obspy.core.event.Catalog.write for supported formats.
eqcorrscan.core.match_filter.detection.get_catalog(detections)[source]

Generate an obspy.core.event.Catalog from list of Detection’s.

Parameters:detections (list) – list of eqcorrscan.core.match_filter.Detection
Returns:Catalog of detected events.
Return type:obspy.core.event.Catalog

Warning

Will only work if the detections have an event associated with them. This will not be the case if detections have been written to csv format using eqcorrscan.core.match_filter.Detection.write() and read back in.