rt_match_filter

Classes for real-time matched-filter detection of earthquakes.

class rt_eqcorrscan.rt_match_filter.RealTimeTribe(name=None, tribe=None, inventory=None, rt_client=None, detect_interval=60.0, backfill_interval=600.0, plot=True, plot_options=None, wavebank=WaveBank(base_path=/home/docs/checkouts/readthedocs.org/user_builds/rt-eqcorrscan/checkouts/latest/docs/Streaming_WaveBank), notifer=<rt_eqcorrscan.config.mailer.Notifier object>)[source]
add_templates(templates, min_stations=None)[source]

Add templates to the tribe.

This method will run the new templates back in time, then append the templates to the already running tribe.

Parameters
  • templates (Union[List[Template], Tribe]) – New templates to add to the tribe.

  • min_stations (Optional[int]) – Minimum number of stations required to make a detection.

Return type

set

Returns

Complete set of template names after addition

backfill(templates, threshold, threshold_type, trig_int, maximum_backfill=None, endtime=None, plot_detections=False, **kwargs)[source]

Backfill using data from rt_client’s wavebank.

This method will run the new templates through old data and record detections in the real-time-tribe.

Parameters
  • templates (Union[List[Template], Tribe]) – New templates to add to the tribe.

  • threshold (float) – Threshold for detection

  • threshold_type (str) – Type of threshold to use. See eqcorrscan.core.match_filter.Tribe.detect for options.

  • trig_int (float) – Minimum inter-detection time in seconds.

  • maximum_backfill (Union[float, UTCDateTime, None]) – Time in seconds to backfill to - if this is larger than the difference between the time now and the time that the tribe started, then it will backfill to when the tribe started.

  • endtime (Optional[UTCDateTime]) – Time to stop the backfill, if None will run to now.

Return type

None

property expected_seed_ids: set

ids of channels to be used for detection.

get_wavebank_files(bulk)[source]

processsafe way to get the file paths meeting bulk criteria

Return type

List[str]

get_wavebank_stream(bulk)[source]

processsafe get-waveforms-bulk call

Return type

Stream

property minimum_data_for_detection: float

Get the minimum required data length (in seconds) for detection.

plotting_exclude_channels = ['EHE', 'EHN', 'EH1', 'EH2', 'HHE', 'HHN', 'HH1', 'HH2']

Real-Time tribe for real-time matched-filter detection.

Parameters
  • name – Tribe identifier - used to define save path.

  • tribe – Tribe of templates to use for detection.

  • inventory – Inventory of stations used for detection.

  • rt_client – Real-Time Client for streaming data.

  • detect_interval – Frequency to conduct detection. Must be less than buffer_capacity.

  • plot – Whether to generate the real-time bokeh plot

  • plot_options – Plotting options parsed to rt_eqcorrscan.plotting.plot_buffer

  • wavebank – WaveBank to save data to. Used for backfilling by RealTimeTribe. Set to None to not use a WaveBank.

  • sleep_step – Default sleep-step in seconds while waiting for data. Defaults to 1.0

  • plotting_exclude_channels – Channels to exclude from plotting

run(threshold, threshold_type, trig_int, hypocentral_separation=None, min_stations=None, keep_detections=86400, detect_directory='{name}/detections', plot_detections=True, save_waveforms=True, max_run_length=None, minimum_rate=None, backfill_to=None, backfill_client=None, **kwargs)[source]

Run the RealTimeTribe detection.

Detections will be added to a party and returned when the detection is done. Detections will be stored in memory for up to keep_detections seconds. Detections will also be written to individual files in the detect_directory.

Parameters
  • threshold (float) – Threshold for detection

  • threshold_type (str) – Type of threshold to use. See eqcorrscan.core.match_filter.Tribe.detect for options.

  • trig_int (float) – Minimum inter-detection time in seconds.

  • hypocentral_separation (Optional[float]) – Maximum inter-event distance in km to consider detections as being duplicates.

  • min_stations (Optional[int]) – Minimum number of stations required to make a detection.

  • keep_detections (float) – Duration to store detection in memory for in seconds.

  • detect_directory (str) – Relative path to directory for detections. This directory will be created if it doesn’t exist - tribe name will be appended to this string to give the directory name.

  • plot_detections (bool) – Whether to plot detections or not - plots will be saved to the detect_directory as png images.

  • save_waveforms (bool) – Whether to save waveforms of detections or not - waveforms will be saved in the detect_directory as miniseed files.

  • max_run_length (Optional[float]) – Maximum detection run time in seconds. Default is to run indefinitely.

  • minimum_rate (Optional[float]) – Stopping criteria: if the detection rate drops below this the detector will stop. If set to None, then the detector will run until max_run_length. Units: events per day

  • backfill_to (Optional[UTCDateTime]) – Time to backfill the data buffer to.

  • backfill_client – Client to use to backfill the data buffer.

Return type

Party

Returns

  • The party created - will not contain detections expired by

  • keep_detections threshold.

property running_templates: set

Get a set of the names of the running templates.

Note that names are not guaranteed to be unique.

stop(write_stopfile=False)[source]

Stop the real-time system.

Parameters

write_stopfile (bool) – Used to write a one-line file telling listening systems that this has stopped. Used by the Reactor.

Return type

None

property template_seed_ids: set

Channel-ids used in the templates.

property used_seed_ids: set

Channel-ids in the inventory.

property used_stations: set

Set of station names used in detection.

rt_eqcorrscan.rt_match_filter.reshape_templates(templates, used_seed_ids)[source]

Reshape templates to have the full set of required channels (and no more).

This is done within matched-filter as well as here - we do it here so that the templates are not reshaped every iteration.

Parameters
  • templates (List[Template]) – Templates to be reshaped - the templates are changed in-place

  • used_seed_ids (Iterable[str]) – Seed-ids used for detection (network.station.location.channel)

Return type

Templates filled for detection.

rt_eqcorrscan.rt_match_filter.squash_duplicates(template)[source]

Remove duplicate channels in templates.

This happens when there are duplicate picks, and it fucks shit up. More explicitly (less?): when there are duplicate picks, duplicate channels appear in the template, which are then extended to all templates meaning that many copies of a template are run, resulting in excessive detection bias on one channel, and very expensive templates without good reason.