EventsComponent¶
-
class
lasif.components.events.
EventsComponent
(folder, communicator, component_name)[source]¶ Component managing a folder of QuakeML files.
Each file must adhere to the scheme
*.xml
.Parameters: - folder – Folder with QuakeML files.
- communicator – The communicator instance.
- component_name – The name of this component for the communicator.
-
count
()[source]¶ Get the number of events managed by this component.
>>> comm = getfixture('events_comm') >>> comm.events.count() 2
-
get
(event_name)[source]¶ Get information about one event.
This function uses multiple cache layers and is thus very cheap to call.
Parameters: event_name (str) – The name of the event. Return type: dict >>> comm = getfixture('events_comm') >>> comm.events.get('GCMT_event_TURKEY_Mag_5.9_2011-5-19-20-15') {'m_tp': -2.17e+17, 'm_tt': 8.92e+17, 'depth_in_km': 7.0, 'event_name': u'GCMT_event_TURKEY_Mag_5.9_2011-5-19-20-15', 'region': u'TURKEY', 'longitude': 29.1, 'filename': u'/.../GCMT_event_TURKEY_Mag_5.9_2011-5-19-20-15.xml', 'm_rr': -8.07e+17, 'magnitude': 5.9, 'magnitude_type': u'Mwc', 'latitude': 39.15, 'origin_time': UTCDateTime(2011, 5, 19, 20, 15, 22, 900000), 'm_rp': -5.3e+16, 'm_pp': -8.5e+16, 'm_rt': 2.8e+16}
The moment tensor components are in
Nm
. The dictionary will contain the following keys:>>> sorted(comm.events.get( ... 'GCMT_event_TURKEY_Mag_5.9_2011-5-19-20-15').keys()) ['depth_in_km', 'event_name', 'filename', 'latitude', 'longitude', 'm_pp', 'm_rp', 'm_rr', 'm_rt', 'm_tp', 'm_tt', 'magnitude', 'magnitude_type', 'origin_time', 'region']
It also works with an existing event dictionary. This eases calling the function under certain circumstances.
>>> ev = comm.events.get('GCMT_event_TURKEY_Mag_5.9_2011-5-19-20-15') >>> ev == comm.events.get(ev) True
-
get_all_events
()[source]¶ Returns a dictionary with the key being the event names and the values the information about each event, as would be returned by the
get()
method.>>> comm = getfixture('events_comm') >>> comm.events.get_all_events() {u'GCMT_event_TURKEY_Mag_5.9_2011-5-19-20-15': {...}, u'GCMT_event_TURKEY_Mag_5.1_2010-3-24-14-11': {...}}
-
has_event
(event_name)[source]¶ Test for existence of an event.
Parameters: event_name (str) – The name of the event. >>> comm = getfixture('events_comm') >>> comm.events.has_event('GCMT_event_TURKEY_Mag_5.9_2011-5-19-20-15') True >>> comm.events.has_event('random') False