reactor¶
Reactor module of RT_EQcorrscan
reactor.reactor¶
Overarching tool for listening to and triggering from FDSN earthquakes.
-
class
rt_eqcorrscan.reactor.reactor.
Reactor
(client, listener, trigger_func, template_database, config, listener_starttime=None)[source]¶ A class to listen to a client and start-up a real-time instance.
The real-time instance will be triggered by the listener when set conditions are met. Appropriate templates will be extracted from the template database on disk and used as a Tribe for the real-time detection.
Once triggered, the listener will keep listening, but will not trigger in the same region again while the real-time detector is running. The real-time detector has to be stopped manually, or when rate or maximum-duration conditions are met.
- Parameters
client – An obspy or obsplus client that supports event and station queries.
listener (
_Listener
) – Listener for checking current earthquake activitytrigger_func (
Callable
) – A function that returns a list of events that exceed some trigger parameters given a catalog. See note below.template_database (
TemplateBank
) – A template database to be used to generate tribes for real-time matched-filter detection.config (
Config
) – Configuration for RT-EQcorrscan.
Notes
trigger_func must only take one argument, a catalog of events. To achieve this you should generate a partial function from your trigger function. For example, using the provided rate-and-magnitude triggering function:
>>> from rt_eqcorrscan.event_trigger import magnitude_rate_trigger_func >>> from functools import partial >>> trigger_func = partial( ... magnitude_rate_trigger_func, magnitude_threshold=4, ... rate_threshold=20, rate_bin=0.5)
-
check_running_tribes
()[source]¶ Check on the state of running tribes.
Because this process starts subprocesses, they need to be stopped by this process if they “complete”. This is recorded by the real-time-tribe by writing a .stopfile
- Return type
-
process_new_events
(new_events)[source]¶ Process any new events in the system.
Check if new events should be in one of the already running tribes and add them. Check all other events for possible triggers and spin-up a detector instance for triggers.
-
rt_eqcorrscan.reactor.reactor.
estimate_region
(event, min_length=50.0, scaling_relation='default', multiplier=1.25)[source]¶ Estimate the region to find templates within given a triggering event.
- Parameters
event (
Event
) – The event that triggered this functionmin_length (
float
) – Minimum length in km for diameter of event circle around the triggering eventscaling_relation (
Union
[str
,Callable
]) – Name of registered scaling-relationship or Callable that takes only the earthquake magnitude as an argument and returns length in kmmultiplier (
float
) – Fudge factor to scale the scaling relation up by a constant.
- Returns
- Return type
Dictionary keyed by “latitude”, “longitude” and “maxradius”
Notes
The scaling_relation * multiplier defines the maxradius of the region
reactor.spin_up¶
Functions for spinning up and running a real-time tribe based on trigger-events
-
rt_eqcorrscan.reactor.spin_up.
get_inventory
(client, tribe, triggering_event=None, location=None, starttime=None, max_distance=1000.0, n_stations=10, duration=10, level='channel', channel_list=('EH?', 'HH?'))[source]¶ Get a suitable inventory for a tribe - selects the most used, closest stations.
- Parameters
client – Obspy client with a get_stations service.
tribe (
Union
[RealTimeTribe
,Tribe
]) – Tribe or RealTimeTribe of templates to query for stations.triggering_event (
Optional
[Event
]) – Event with at least an origin to calculate distances from - if not specified will use locationlocation (
Optional
[dict
]) – Dictionary with “latitude” and “longitude” keys - only used if triggering event is not specified.starttime (
Optional
[UTCDateTime
]) – Start-time for station search - only used if triggering_event is not specified.max_distance (
float
) – Maximum distance from triggering_event.preferred_origin or location to find stations. Units: kmn_stations (
int
) – Maximum number of stations to returnduration (
float
) – Duration stations must be active for. Units: dayslevel (
str
) – Level for inventory parsable by client.get_stations.channel_list (
Union
[list
,tuple
]) – List of channel-codes to be acquired. If None then all channels will be searched.
- Returns
- Return type
Inventory of the most used, closest stations.