event_trigger

Triggering functions for RT-EQcorrscan.

event_trigger.listener

Listener ABC.

class rt_eqcorrscan.event_trigger.listener.EventInfo(event_id, event_time)
property event_id

Alias for field number 0

property event_time

Alias for field number 1

rt_eqcorrscan.event_trigger.listener.event_time(event)[source]

Get the origin or first pick time of an event.

Parameters

event (Event) – Event to get a time for

Return type

Reference time for event.

event_trigger.catalog_listener

Listener to an event stream.

class rt_eqcorrscan.event_trigger.catalog_listener.CatalogListener(client, template_bank, catalog=None, catalog_lookup_kwargs=None, interval=10, keep=86400, waveform_client=None)[source]

Client query class for obspy clients with a get_events service.

Parameters
  • client – Client to query - must have at least a get_events method.

  • catalog (Optional[Catalog]) – Catalog of past events - can be empty. Any new events will be compared to this catalog and only added to the template bank if they are not in the original catalog.

  • catalog_lookup_kwargs (Optional[dict]) – Dictionary of keyword arguments for client.get_events.

  • template_bank (TemplateBank) – A Template database - new events will be added to this database.

  • interval (float) – Interval for querying the client in seconds. Note that rapid queries may not be more efficient, and will almost certainly piss off your provider.

  • keep (float) – Time in seconds to keep events for in the catalog in memory. Will not remove old events on disk. Use to reduce memory consumption.

  • waveform_client – Client with at least a get_waveforms and get_waveforms_bulk method. If this is None (default) then the client will be used.

run(make_templates=True, template_kwargs=None, min_stations=0, auto_event=True, auto_picks=True, event_type=None, filter_func=None, starttime=None, **filter_kwargs)[source]

Run the listener. New events will be added to the template_bank.

Parameters
  • make_templates (bool) – Whether to add new templates to the database (True) or not.

  • template_kwargs (Optional[dict]) – Dictionary of keyword arguments for making templates, requires at-least: lowcut, highcut, samp_rate, filt_order, prepick, length, swin.

  • min_stations (int) – Minimum number of stations for an event to be added to the TemplateBank

  • auto_event (bool) – If True, both automatic and manually reviewed events will be included. If False, only manually reviewed events will be included

  • auto_picks (bool) – If True, both automatic and manual picks will be included. If False only manually reviewed picks will be included. Note that this is done before counting the number of stations.

  • event_type (Union[list, str, None]) – List of event types to keep.

  • filter_func (Optional[Callable]) – Function used for filtering. If left as none, this will use the catalog_listener.filter_events function.

  • starttime (Optional[UTCDateTime]) – When to start to get events from, defaults to the last time the listener was run.

  • filter_kwargs – If the filter_func has changed then this should be the additional kwargs for the user-defined filter_func.

Return type

None

rt_eqcorrscan.event_trigger.catalog_listener.filter_events(events, min_stations, auto_picks, auto_event, event_type, **kwargs)[source]

Filter events from a catalog based on some quality attributes.

Parameters
  • events (Union[list, Catalog]) – Events to apply filter to.

  • min_stations (int) – Minimum number of stations for event to be kept.

  • auto_picks (bool) – Whether to keep automatic picks or not.

  • auto_event (bool) – Whether to keep automatic events or not.

  • event_type (Union[list, str]) – Event types to keep.

Return type

Events that pass the criteria

event_trigger.triggers

Standardised trigger functions for use with a Reactor.

rt_eqcorrscan.event_trigger.triggers.average_rate(catalog, starttime=None, endtime=None)[source]

Compute mean rate (in events per day) of occurrence of events in catalog.

Parameters
  • catalog (Union[List[Detection], Catalog]) – Catalog of events, or list of detections

  • starttime (Optional[UTCDateTime]) – Start-time to calculate rate for, if not set will use the time of the first event in the catalog

  • endtime (Optional[UTCDateTime]) – End-time to calculate rate for, if not set will use the time of the last event in the catalog

Returns

Average rate over duration of catalog. Units

Return type

events / day

rt_eqcorrscan.event_trigger.triggers.get_nearby_events(event, catalog, radius)[source]

Get a catalog of events close to another event.

Parameters
  • event (Event) – Central event to calculate distance relative to

  • catalog (Catalog) – Catalog to extract events from

  • radius (float) – Radius around event in km

Return type

Catalog of events close to event

rt_eqcorrscan.event_trigger.triggers.inter_event_distance(event1, event2)[source]

Calculate the distance (in degrees) between two events

Return type

float

Returns

distance in degrees between events

rt_eqcorrscan.event_trigger.triggers.magnitude_rate_trigger_func(catalog, magnitude_threshold=5.5, rate_threshold=10.0, rate_bin=0.2, minimum_events_in_bin=5)[source]

Function to turn triggered response on based on magnitude and rate.

Parameters
  • catalog (Catalog) – Catalog to look in

  • magnitude_threshold (float) – magnitude threshold for triggering a response

  • rate_threshold (float) – rate in events per day for triggering a response

  • rate_bin (float) – radius in degrees to calculate rate for.

  • minimum_events_in_bin (int) – Minimum number of events in a bin to calculate a rate for.

Return type

The events that forced the trigger.