1# http://pyrocko.org - GPLv3
2#
3# The Pyrocko Developers, 21st Century
4# ---|P------/S----------~Lg----------
6from ..snuffling import Snuffling, Param, Choice
7from ..util import EventMarker
9from pyrocko.client import catalog, fdsn
10from pyrocko.io import quakeml
13class CatalogSearch(Snuffling):
14 '''
15 <html>
16 <head>
17 <style type="text/css">
18 body { margin-left:10px };
19 </style>
20 </head>
21 <body>
22 <h1 align="center">Catalog Search</h1>
23 <p>
24 Retrieve event data from online catalogs.
25 </p>
26 <b>Parameters:</b><br />
27 <b>· Catalog</b> - Online database to search for events.<br />
28 <b>· Min Magnitude</b> -
29 Only consider events with magnitude greater than chosen..<br />
30 </p>
31 <p>
32 Data from the folowing catalogs can be retrieved:<br />
33 ·
34 <a href="http://geofon.gfz-potsdam.de/eqinfo/list.php">GEOFON</a><br />
35 ·
36 <a href="http://www.globalcmt.org/">Global CMT</a><br />
37 ·
38 <a href="http://earthquake.usgs.gov/regional/neic/">USGS</a><br />
39 </p>
40 <p>
41 The USGS catalog allows to destinguish between 'Preliminary
42 Determination of Epicenters' (PDE) and 'Quick Epicenters Determination'
43 (PDE-Q). Latter one includes events of approximately the last six
44 weeks. For detailed information about both catalog versions have a look
45 at <a href="http://earthquake.usgs.gov/research/data/pde.php">'The
46 Preliminary Determination of Epicenters (PDE) Bulletin'</a>.
47 </p>
48 </body>
49 </html>
50 '''
52 def setup(self):
54 self.catalogs = {
55 'GEOFON': catalog.Geofon(),
56 'USGS/NEIC US': catalog.USGS('us'),
57 'Global-CMT': catalog.GlobalCMT(),
58 'Saxony (Uni-Leipzig)': catalog.Saxony(),
59 }
61 fdsn_has_events = ['ISC', 'SCEDC', 'NCEDC', 'IRIS', 'GEONET']
63 catkeys = sorted(self.catalogs.keys())
64 catkeys.extend(fdsn_has_events)
66 self.set_name('Catalog Search')
67 self.add_parameter(Choice('Catalog', 'catalog', catkeys[0], catkeys))
68 self.add_parameter(Param('Min Magnitude', 'magmin', 0, 0, 10))
69 self.set_live_update(False)
71 def call(self):
73 viewer = self.get_viewer()
74 tmin, tmax = viewer.get_time_range()
76 cat = self.catalogs.get(self.catalog, None)
77 if cat:
78 event_names = cat.get_event_names(
79 time_range=(tmin, tmax),
80 magmin=self.magmin)
81 for event_name in event_names:
82 event = cat.get_event(event_name)
83 marker = EventMarker(event)
84 self.add_markers([marker])
85 else:
86 request = fdsn.event(
87 starttime=tmin, endtime=tmax, site=self.catalog.lower(),
88 minmagnitude=self.magmin)
90 qml = quakeml.QuakeML.load_xml(request)
91 events = qml.get_pyrocko_events()
93 for event in events:
94 marker = EventMarker(event)
95 self.add_markers([marker])
98def __snufflings__():
100 return [CatalogSearch()]