Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/gui/snuffler/snufflings/catalogs.py: 53%

34 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-10-04 09:52 +0000

1# https://pyrocko.org - GPLv3 

2# 

3# The Pyrocko Developers, 21st Century 

4# ---|P------/S----------~Lg---------- 

5 

6from ..snuffling import Snuffling, Param, Choice 

7from ..marker import EventMarker 

8 

9from pyrocko.client import catalog, fdsn 

10from pyrocko.io import quakeml 

11 

12 

13class CatalogSearch(Snuffling): 

14 

15 def help(self): 

16 return ''' 

17<html> 

18<head> 

19<style type="text/css"> 

20body { margin-left:10px }; 

21</style> 

22</head> 

23<body> 

24 <h1 align="center">Catalog Search</h1> 

25<p> 

26 Retrieve event data from online catalogs. 

27</p> 

28 <b>Parameters:</b><br /> 

29 <b>&middot; Catalog</b> - Online database to search for events.<br /> 

30 <b>&middot; Min Magnitude</b> - 

31 Only consider events with magnitude greater than chosen..<br /> 

32</p> 

33<p> 

34 Data from the folowing catalogs can be retrieved:<br /> 

35 &middot; 

36 <a href="http://geofon.gfz-potsdam.de/eqinfo/list.php">GEOFON</a><br /> 

37 &middot; 

38 <a href="http://www.globalcmt.org/">Global CMT</a><br /> 

39 &middot; 

40 <a href="http://earthquake.usgs.gov/regional/neic/">USGS</a><br /> 

41</p> 

42<p> 

43 The USGS catalog allows to destinguish between 'Preliminary 

44 Determination of Epicenters' (PDE) and 'Quick Epicenters Determination' 

45 (PDE-Q). Latter one includes events of approximately the last six 

46 weeks. For detailed information about both catalog versions have a look 

47 at <a href="http://earthquake.usgs.gov/research/data/pde.php">'The 

48 Preliminary Determination of Epicenters (PDE) Bulletin'</a>. 

49</p> 

50</body> 

51</html> 

52 ''' 

53 

54 def setup(self): 

55 

56 self.catalogs = { 

57 'GEOFON': catalog.Geofon(), 

58 'USGS/NEIC US': catalog.USGS('us'), 

59 'Global-CMT': catalog.GlobalCMT(), 

60 'Saxony (Uni-Leipzig)': catalog.Saxony(), 

61 } 

62 

63 fdsn_has_events = ['ISC', 'SCEDC', 'NCEDC', 'IRIS', 'GEONET'] 

64 

65 catkeys = sorted(self.catalogs.keys()) 

66 catkeys.extend(fdsn_has_events) 

67 

68 self.set_name('Catalog Search') 

69 self.add_parameter(Choice('Catalog', 'catalog', catkeys[0], catkeys)) 

70 self.add_parameter(Param('Min Magnitude', 'magmin', 0, 0, 10)) 

71 self.set_live_update(False) 

72 

73 def call(self): 

74 

75 viewer = self.get_viewer() 

76 tmin, tmax = viewer.get_time_range() 

77 

78 cat = self.catalogs.get(self.catalog, None) 

79 if cat: 

80 event_names = cat.get_event_names( 

81 time_range=(tmin, tmax), 

82 magmin=self.magmin) 

83 for event_name in event_names: 

84 event = cat.get_event(event_name) 

85 marker = EventMarker(event) 

86 self.add_markers([marker]) 

87 else: 

88 request = fdsn.event( 

89 starttime=tmin, endtime=tmax, site=self.catalog.lower(), 

90 minmagnitude=self.magmin) 

91 

92 qml = quakeml.QuakeML.load_xml(request) 

93 events = qml.get_pyrocko_events() 

94 

95 for event in events: 

96 marker = EventMarker(event) 

97 self.add_markers([marker]) 

98 

99 

100def __snufflings__(): 

101 

102 return [CatalogSearch()]