Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/gui/snuffler/snufflings/geofon.py: 64%
22 statements
« prev ^ index » next coverage.py v6.5.0, created at 2024-03-07 11:54 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2024-03-07 11:54 +0000
1# https://pyrocko.org - GPLv3
2#
3# The Pyrocko Developers, 21st Century
4# ---|P------/S----------~Lg----------
6from ..snuffling import Snuffling
7from ..marker import EventMarker
9from pyrocko.client import catalog
12class GeofonEvents(Snuffling):
13 '''
14 Get events from GEOFON catalog.
15 '''
17 def __init__(self, magmin=None):
18 self._magmin = magmin
19 Snuffling.__init__(self)
21 def setup(self):
22 '''
23 Customization of the snuffling.
24 '''
26 if self._magmin is None:
27 self.set_name('Get GEOFON Events')
28 else:
29 self.set_name('Get GEOFON Events (> M %g)' % self._magmin)
31 def call(self):
32 '''
33 Main work routine of the snuffling.
34 '''
36 # get time range visible in viewer
37 viewer = self.get_viewer()
38 tmin, tmax = viewer.get_time_range()
40 # download event information from GEOFON web page
41 # 1) get list of event names
42 geofon = catalog.Geofon()
43 event_names = geofon.get_event_names(
44 time_range=(tmin, tmax),
45 magmin=self._magmin)
47 # 2) get event information and add a marker in the snuffler window
48 for event_name in event_names:
49 event = geofon.get_event(event_name)
50 marker = EventMarker(event)
51 self.add_markers([marker])
54def __snufflings__():
55 '''
56 Returns a list of snufflings to be exported by this module.
57 '''
59 return [
60 GeofonEvents(),
61 GeofonEvents(magmin=6),
62 GeofonEvents(magmin=7),
63 GeofonEvents(magmin=8)]