コード例 #1
0
    def testGeofon(self):
        def is_the_haiti_event(ev):
            assert near(ev.magnitude, 7.2, 0.001)
            assert near(ev.lat, 18.37, 0.001)
            assert near(ev.lon, -72.55, 0.001)
            assert near(ev.depth, 17000., 1.)
            assert ev.region == 'Haiti Region'

        cat = catalog.Geofon()

        tmin = util.ctimegm('2010-01-12 21:50:00')
        tmax = util.ctimegm('2010-01-13 03:17:00')

        names = cat.get_event_names(time_range=(tmin, tmax),
                                    nmax=10,
                                    magmin=5.)

        assert len(names) > 0
        ident = None
        for name in names:
            ev = cat.get_event(name)
            if ev.magnitude >= 7:
                is_the_haiti_event(ev)
                ident = ev.name

        assert ident is not None

        cat.flush()
        ev = cat.get_event(ident)
        is_the_haiti_event(ev)
コード例 #2
0
    def testGeofonSingleEvent(self):
        cat = catalog.Geofon()
        ev = cat.get_event('gfz2010avtm')
        is_the_haiti_event_geofon(ev)
        cat.flush()

        ev = cat.get_event('gfz2019hkck')
        assert ev.name == 'gfz2019hkck'
コード例 #3
0
 def testGeofonMT(self):
     cat = catalog.Geofon()
     tmin = util.str_to_time('2014-01-01 00:00:00')
     tmax = util.str_to_time('2017-01-01 00:00:00')
     events = cat.get_events((tmin, tmax), magmin=8)
     self.assertEqual(len(events), 2)
     mt1, mt2 = [ev.moment_tensor for ev in events]
     angle = moment_tensor.kagan_angle(mt1, mt2)
     self.assertEqual(round(angle - 7.7, 1), 0.0)
コード例 #4
0
def command_init(args):
    '''
    Execution of command init
    '''
    def setup(parser):

        parser.add_option('--force',
                          dest='force',
                          action='store_true',
                          help='overwrite existing project directory')

    parser, options, args = cl_parse('init', args, setup)

    if len(args) != 1:
        help_and_die(parser, 'missing argument')
    else:
        fn_config = args[0]

    if not os.path.isfile(fn_config):
        die('config file missing: %s' % fn_config)

    conf = load(filename=fn_config)
    config.check(conf)

    if ((not options.force) and (os.path.isdir(conf.project_dir))):
        die('project dir exists: %s; use force option' % conf.project_dir)
    else:
        if os.path.isdir(conf.project_dir):
            shutil.rmtree(conf.project_dir)
        os.mkdir(conf.project_dir)
        conf.dump(filename=os.path.join(conf.project_dir, 'seiscloud.config'))

        dst = os.path.join(conf.project_dir, 'catalog.pf')

        if conf.catalog_origin == 'file':
            src = conf.catalog_fn
            shutil.copyfile(src, dst)
        else:
            if conf.catalog_origin == 'globalcmt':
                orig_catalog = catalog.GlobalCMT()
            else:  # geofon
                orig_catalog = catalog.Geofon()
            events = orig_catalog.get_events(time_range=(util.str_to_time(
                conf.tmin), util.str_to_time(conf.tmax)),
                                             magmin=conf.magmin,
                                             latmin=conf.latmin,
                                             latmax=conf.latmax,
                                             lonmin=conf.lonmin,
                                             lonmax=conf.lonmax)

            selevents = [ev for ev in events if ev.magnitude <= conf.magmax]
            model.dump_events(selevents, dst)

        print('Project directory prepared "%s"' % conf.project_dir)
コード例 #5
0
ファイル: catalogs.py プロジェクト: zhengjing8628/pyrocko
    def setup(self):

        self.catalogs = {
            'Geofon': catalog.Geofon(),
            'USGS/NEIC US': catalog.USGS('us'),
            'Global-CMT': catalog.GlobalCMT(),
            'Kinherd': catalog.Kinherd(),
            'Saxony (Uni-Leipzig)': catalog.Saxony(),
        }

        catkeys = sorted(self.catalogs.keys())
        self.set_name('Catalog Search')
        self.add_parameter(Choice('Catalog', 'catalog', catkeys[0], catkeys))
        self.add_parameter(Param('Min Magnitude', 'magmin', 0, 0, 10))
        self.set_live_update(False)
コード例 #6
0
    def testGeofonMT(self):
        cat = catalog.Geofon()
        tmin = util.str_to_time('2014-01-01 00:00:00')
        tmax = util.str_to_time('2017-01-01 00:00:00')
        events_a = cat.get_events((tmin, tmax), magmin=8)
        events_b = [
            cat.get_event('gfz2015sfdd'),
            cat.get_event('gfz2014gkgf')]

        for events in [events_a, events_b]:
            self.assertEqual(len(events), 2)
            mt1, mt2 = [ev.moment_tensor for ev in events]
            angle = moment_tensor.kagan_angle(mt1, mt2)
            self.assertEqual(round(angle - 7.7, 1), 0.0)

        ev = cat.get_event('gfz2020vimx')
        assert isinstance(ev.moment_tensor, moment_tensor.MomentTensor)
コード例 #7
0
ファイル: geofon.py プロジェクト: zhengjing8628/pyrocko
    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])
コード例 #8
0
ファイル: catalogs.py プロジェクト: wuxyair/pyrocko
    def setup(self):

        self.catalogs = {
            'Geofon': catalog.Geofon(),
            'USGS/NEIC US': catalog.USGS('us'),
            'Global-CMT': catalog.GlobalCMT(),
            'Saxony (Uni-Leipzig)': catalog.Saxony(),
        }

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

        catkeys = sorted(self.catalogs.keys())
        catkeys.extend(fdsn_has_events)

        self.set_name('Catalog Search')
        self.add_parameter(Choice('Catalog', 'catalog', catkeys[0], catkeys))
        self.add_parameter(Param('Min Magnitude', 'magmin', 0, 0, 10))
        self.set_live_update(False)
コード例 #9
0
    def testGeofon(self):

        cat = catalog.Geofon()

        tmin = util.str_to_time('2010-01-12 21:50:00')
        tmax = util.str_to_time('2010-01-13 03:17:00')

        names = cat.get_event_names(
            time_range=(tmin, tmax), nmax=10, magmin=5.)

        assert len(names) > 0
        ident = None
        for name in names:
            ev = cat.get_event(name)
            if ev.magnitude >= 7:
                is_the_haiti_event_geofon(ev)
                ident = ev.name

        assert ident is not None

        cat.flush()
コード例 #10
0
 def testGeofonMassive(self):
     cat = catalog.Geofon(get_moment_tensors=False)
     tmin = util.str_to_time('2010-01-01 00:00:00')
     tmax = util.str_to_time('2018-01-01 00:00:00')
     events = cat.get_events((tmin, tmax))
     print(len(events))
コード例 #11
0
from pyrocko import util
from pyrocko.client import catalog

tmin = util.ctimegm('2018-06-11 08:23:00')
tmax = util.ctimegm('2018-06-11 08:24:00')
mag = 4.0

# download event information from GEOFON web page

geofon = catalog.Geofon()
event_names = geofon.get_event_names(time_range=(tmin, tmax), magmin=mag)

for event_name in event_names:
    event = geofon.get_event(event_name)
    print(event)