1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

# http://pyrocko.org - GPLv3 

# 

# The Pyrocko Developers, 21st Century 

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

from __future__ import absolute_import 

from pyrocko.gui.snuffling import Snuffling 

from pyrocko.gui.util import EventMarker 

 

from pyrocko.client import catalog 

 

 

class GeofonEvents(Snuffling): 

''' 

Get events from GEOFON catalog. 

''' 

 

def __init__(self, magmin=None): 

self._magmin = magmin 

Snuffling.__init__(self) 

 

def setup(self): 

'''Customization of the snuffling.''' 

 

if self._magmin is None: 

self.set_name('Get GEOFON Events') 

else: 

self.set_name('Get GEOFON Events (> M %g)' % self._magmin) 

 

def call(self): 

'''Main work routine of the snuffling.''' 

 

# get time range visible in viewer 

viewer = self.get_viewer() 

tmin, tmax = viewer.get_time_range() 

 

# download event information from GEOFON web page 

# 1) get list of event names 

geofon = catalog.Geofon() 

event_names = geofon.get_event_names( 

time_range=(tmin, tmax), 

magmin=self._magmin) 

 

# 2) get event information and add a marker in the snuffler window 

for event_name in event_names: 

event = geofon.get_event(event_name) 

marker = EventMarker(event) 

self.add_markers([marker]) 

 

 

def __snufflings__(): 

'''Returns a list of snufflings to be exported by this module.''' 

 

return [ 

GeofonEvents(), 

GeofonEvents(magmin=6), 

GeofonEvents(magmin=7), 

GeofonEvents(magmin=8)]