当前位置: 首页>>代码示例>>Python>>正文


Python Client.get_waveforms_bulk方法代码示例

本文整理汇总了Python中obspy.clients.fdsn.Client.get_waveforms_bulk方法的典型用法代码示例。如果您正苦于以下问题:Python Client.get_waveforms_bulk方法的具体用法?Python Client.get_waveforms_bulk怎么用?Python Client.get_waveforms_bulk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在obspy.clients.fdsn.Client的用法示例。


在下文中一共展示了Client.get_waveforms_bulk方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _download_bulk

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_waveforms_bulk [as 别名]
    def _download_bulk(stations, event):

        click.secho("Downloading: {}".format(event.name))
        client = Client("IRIS")

        # Remove duplicate stations. For some reasons NARS breaks obspy.
        bulk_req = [(s.net, s.sta, '*', 'BHE,BHN,BHZ') for s in stations]
        bulk_req = [s + (event.start, event.end) for s in set(bulk_req) if "NARS" not in s]

        filename = os.path.join("RAW_DATA", "{}.mseed".format(event.name))
        client.get_waveforms_bulk(bulk_req, filename=filename)
开发者ID:lermert,项目名称:OvalOffice,代码行数:13,代码来源:data_downloader.py

示例2: FDSN_bulk_request

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_waveforms_bulk [as 别名]
def FDSN_bulk_request(i, add_event, input_dics):
    """
    Send bulk request to FDSN
    """
    print "\nSending bulk request to FDSN: %s" % input_dics["fdsn_base_url"]
    client_fdsn = Client_fdsn(
        base_url=input_dics["fdsn_base_url"], user=input_dics["fdsn_user"], password=input_dics["fdsn_pass"]
    )
    bulk_list_fio = open(os.path.join(add_event[i], "info", "bulkdata_list"))
    bulk_list = pickle.load(bulk_list_fio)
    bulk_smgrs = client_fdsn.get_waveforms_bulk(bulk_list)
    print "Saving the retrieved waveforms...",
    for bulk_st in bulk_smgrs:
        bulk_st.write(
            os.path.join(
                add_event[i],
                "BH_RAW",
                "%s.%s.%s.%s"
                % (
                    bulk_st.stats["network"],
                    bulk_st.stats["station"],
                    bulk_st.stats["location"],
                    bulk_st.stats["channel"],
                ),
            ),
            "MSEED",
        )
开发者ID:kasra-hosseini,项目名称:obspyDMT,代码行数:29,代码来源:fdsn_handler.py

示例3: fdsn_bulk_request

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_waveforms_bulk [as 别名]
def fdsn_bulk_request(target_path, req_cli, input_dics):
    """
    send bulk request to FDSN
    :param target_path:
    :param req_cli:
    :param input_dics:
    :return:
    """
    print('\n[INFO] sending bulk request to: %s' % req_cli)

    client_fdsn = Client_fdsn(base_url=req_cli,
                              user=input_dics['username_fdsn'],
                              password=input_dics['password_fdsn'])

    bulk_list_fio = open(os.path.join(target_path, 'info',
                                      'bulkdata_list_%s' % req_cli), 'rb')
    bulk_list = pickle.load(bulk_list_fio)
    bulk_smgrs = client_fdsn.get_waveforms_bulk(bulk_list)
    print('[INFO] saving the retrieved waveforms from %s...' % req_cli)
    for bulk_st in bulk_smgrs:
        bulk_st.write(os.path.join(target_path, 'raw', '%s.%s.%s.%s'
                                   % (bulk_st.stats['network'],
                                      bulk_st.stats['station'],
                                      bulk_st.stats['location'],
                                      bulk_st.stats['channel'])),
                      'MSEED')
开发者ID:kasra-hosseini,项目名称:obspyDMT,代码行数:28,代码来源:data_handler.py

示例4: test_redirection

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_waveforms_bulk [as 别名]
    def test_redirection(self):
        """
        Tests the redirection of GET and POST requests. We redirect
        everything if not authentication is used.

        IRIS runs three services to test it:
            http://ds.iris.edu/files/redirect/307/station/1
            http://ds.iris.edu/files/redirect/307/dataselect/1
            http://ds.iris.edu/files/redirect/307/event/1
        """
        c = Client("IRIS", service_mappings={
            "station":
                "http://ds.iris.edu/files/redirect/307/station/1",
            "dataselect":
                "http://ds.iris.edu/files/redirect/307/dataselect/1",
            "event":
                "http://ds.iris.edu/files/redirect/307/event/1"},
            user_agent=USER_AGENT)

        st = c.get_waveforms(
            network="IU", station="ANMO", location="00", channel="BHZ",
            starttime=UTCDateTime("2010-02-27T06:30:00.000"),
            endtime=UTCDateTime("2010-02-27T06:30:01.000"))
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(st)))

        inv = c.get_stations(
            starttime=UTCDateTime("2000-01-01"),
            endtime=UTCDateTime("2001-01-01"),
            network="IU", station="ANMO", level="network")
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(inv.networks)))

        cat = c.get_events(starttime=UTCDateTime("2001-01-07T01:00:00"),
                           endtime=UTCDateTime("2001-01-07T01:05:00"),
                           catalog="ISC")
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(cat)))

        # Also test the bulk requests which are done using POST requests.
        bulk = (("TA", "A25A", "", "BHZ",
                 UTCDateTime("2010-03-25T00:00:00"),
                 UTCDateTime("2010-03-25T00:00:01")),
                ("TA", "A25A", "", "BHE",
                 UTCDateTime("2010-03-25T00:00:00"),
                 UTCDateTime("2010-03-25T00:00:01")))
        st = c.get_waveforms_bulk(bulk, quality="B", longestonly=False)
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(st)))

        starttime = UTCDateTime(1990, 1, 1)
        endtime = UTCDateTime(1990, 1, 1) + 10
        bulk = [
            ["IU", "ANMO", "", "BHE", starttime, endtime],
            ["IU", "CCM", "", "BHZ", starttime, endtime],
        ]
        inv = c.get_stations_bulk(bulk, level="network")
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(inv.networks)))
开发者ID:Keita1,项目名称:obspy,代码行数:61,代码来源:test_client.py

示例5: test_download_various_methods

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_waveforms_bulk [as 别名]
    def test_download_various_methods(self):
        """Will download data from server and store in various databases,
        then create templates using the various methods."""
        import obspy
        if int(obspy.__version__.split('.')[0]) >= 1:
            from obspy.clients.fdsn import Client
            from obspy import read_events
        else:
            from obspy.fdsn import Client
            from obspy import readEvents as read_events
        from obspy.core.event import Catalog
        from obspy import UTCDateTime
        from eqcorrscan.utils.sfile_util import eventtosfile
        import os
        import shutil

        client = Client('GEONET')
        # get the events
        catalog = Catalog()
        data_stream = client._download('http://quakeml.geonet.org.nz/' +
                                           'quakeml/1.2/2016p008194')
        data_stream.seek(0, 0)
        catalog += read_events(data_stream, format="quakeml")
        data_stream.close()
        # Select 3 channels to use and download
        sta_chans = [(pick.waveform_id.station_code,
                      pick.waveform_id.channel_code)
                     for pick in catalog[0].picks[0:3]]
        t1 = UTCDateTime(catalog[0].origins[0].time.date)
        t2 = t1 + 86400
        bulk = [('NZ', sta_chan[0], '*', sta_chan[1], t1, t2)
                for sta_chan in sta_chans]
        continuous_st = client.get_waveforms_bulk(bulk)
        continuous_st.merge(fill_value=0)
        # Test multi_template_gen
        templates = multi_template_gen(catalog, continuous_st, length=3)
        self.assertEqual(len(templates), 1)
        # Test without an event
        templates = multi_template_gen(Catalog(), continuous_st, length=3)
        self.assertEqual(len(templates), 0)
        # Test from contbase method
        sfile = eventtosfile(catalog[0], 'TEST', 'L', '.', 'None',
                             overwrite=True)
        os.makedirs(catalog[0].origins[0].time.date.strftime('Y%Y'))
        os.makedirs(catalog[0].origins[0].time.date.
                    strftime('Y%Y' + os.sep + 'R%j.01'))
        for tr in continuous_st:
            tr.write(catalog[0].origins[0].time.date.
                     strftime('Y%Y' + os.sep + 'R%j.01') + os.sep +
                     tr.stats.station + '.' + tr.stats.network + '.' +
                     tr.stats.location + '.' + tr.stats.channel +
                     tr.stats.starttime.strftime('%Y.%j'), format='MSEED')
        template = from_contbase(sfile,
                                 contbase_list=[('.', 'Yyyyy/Rjjj.01', 'NZ')],
                                 lowcut=1.0, highcut=5.0, samp_rate=20,
                                 filt_order=4, length=3, prepick=0.5,
                                 swin='all')
        shutil.rmtree(continuous_st[0].stats.starttime.strftime('Y%Y'))
开发者ID:xiansch,项目名称:EQcorrscan,代码行数:60,代码来源:template_gen_test.py

示例6: FDSN_bulk_request

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_waveforms_bulk [as 别名]
def FDSN_bulk_request(i, add_event, input_dics):
    """
    Send bulk request to FDSN
    """
    print '\nSending bulk request to FDSN: %s' % input_dics['fdsn_base_url']
    client_fdsn = Client_fdsn(base_url=input_dics['fdsn_base_url'],
                              user=input_dics['fdsn_user'],
                              password=input_dics['fdsn_pass'])
    bulk_list_fio = open(os.path.join(add_event[i], 'info',
                                      'bulkdata_list'))
    bulk_list = pickle.load(bulk_list_fio)
    bulk_smgrs = client_fdsn.get_waveforms_bulk(bulk_list)
    print 'Saving the retrieved waveforms...',
    for bulk_st in bulk_smgrs:
        bulk_st.write(os.path.join(add_event[i], 'BH_RAW',
                                   '%s.%s.%s.%s'
                                   % (bulk_st.stats['network'],
                                      bulk_st.stats['station'],
                                      bulk_st.stats['location'],
                                      bulk_st.stats['channel'])),
                      'MSEED')
开发者ID:qingkaikong,项目名称:obspyDMT,代码行数:23,代码来源:fdsn_handler.py

示例7: test_redirection_auth

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_waveforms_bulk [as 别名]
    def test_redirection_auth(self):
        """
        Tests the redirection of GET and POST requests using authentication.

        By default these should not redirect and an exception is raised.
        """
        # Clear the cache.
        Client._Client__service_discovery_cache.clear()

        # The error will already be raised during the initialization in most
        # cases.
        self.assertRaises(
            FDSNRedirectException,
            Client, "IRIS", service_mappings={
                "station": "http://ds.iris.edu/files/redirect/307/station/1",
                "dataselect":
                    "http://ds.iris.edu/files/redirect/307/dataselect/1",
                "event": "http://ds.iris.edu/files/redirect/307/event/1"},
            user="[email protected]", password="anonymous",
            user_agent=USER_AGENT)

        # The force_redirect flag overwrites that behaviour.
        c_auth = Client("IRIS", service_mappings={
            "station":
                "http://ds.iris.edu/files/redirect/307/station/1",
            "dataselect":
                "http://ds.iris.edu/files/redirect/307/dataselect/1",
            "event":
                "http://ds.iris.edu/files/redirect/307/event/1"},
            user="[email protected]", password="anonymous",
            user_agent=USER_AGENT, force_redirect=True)

        st = c_auth.get_waveforms(
            network="IU", station="ANMO", location="00", channel="BHZ",
            starttime=UTCDateTime("2010-02-27T06:30:00.000"),
            endtime=UTCDateTime("2010-02-27T06:30:01.000"))
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(st)))

        inv = c_auth.get_stations(
            starttime=UTCDateTime("2000-01-01"),
            endtime=UTCDateTime("2001-01-01"),
            network="IU", station="ANMO", level="network")
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(inv.networks)))

        cat = c_auth.get_events(starttime=UTCDateTime("2001-01-07T01:00:00"),
                                endtime=UTCDateTime("2001-01-07T01:05:00"),
                                catalog="ISC")
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(cat)))

        # Also test the bulk requests which are done using POST requests.
        bulk = (("TA", "A25A", "", "BHZ",
                 UTCDateTime("2010-03-25T00:00:00"),
                 UTCDateTime("2010-03-25T00:00:01")),
                ("TA", "A25A", "", "BHE",
                 UTCDateTime("2010-03-25T00:00:00"),
                 UTCDateTime("2010-03-25T00:00:01")))
        st = c_auth.get_waveforms_bulk(bulk, quality="B", longestonly=False)
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(st)))

        starttime = UTCDateTime(1990, 1, 1)
        endtime = UTCDateTime(1990, 1, 1) + 10
        bulk = [
            ["IU", "ANMO", "", "BHE", starttime, endtime],
            ["IU", "CCM", "", "BHZ", starttime, endtime],
        ]
        inv = c_auth.get_stations_bulk(bulk, level="network")
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(inv.networks)))
开发者ID:Keita1,项目名称:obspy,代码行数:74,代码来源:test_client.py

示例8: run_tutorial

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_waveforms_bulk [as 别名]
def run_tutorial(plot=False):
    """Main function to run the tutorial dataset."""

    from eqcorrscan.utils import pre_processing
    from eqcorrscan.utils import plotting
    from eqcorrscan.core import match_filter
    import glob

    # This import section copes with namespace changes between obspy versions
    import obspy
    if int(obspy.__version__.split('.')[0]) >= 1:
        from obspy.clients.fdsn import Client
    else:
        from obspy.fdsn import Client
    from obspy import UTCDateTime, Stream, read

    # First we want to load our templates
    template_names = glob.glob('tutorial_template_*.ms')

    if len(template_names) == 0:
        raise IOError('Template files not found, have you run the template ' +
                      'creation tutorial?')

    templates = [read(template_name) for template_name in template_names]

    # Work out what stations we have and get the data for them
    stations = []
    for template in templates:
        for tr in template:
            stations.append((tr.stats.station, tr.stats.channel))
    # Get a unique list of stations
    stations = list(set(stations))

    # We are going to look for detections on the day of our template, however, to
    # generalize, we will write a loop through the days between our templates, in
    # this case that is only one day.

    template_days = []
    for template in templates:
        template_days.append(template[0].stats.starttime.date)
    template_days = sorted(template_days)
    kdays = (template_days[-1] - template_days[0]).days + 1

    unique_detections = []

    for i in range(kdays):
        t1 = UTCDateTime(template_days[0]) + (86400 * i)
        t2 = t1 + 86400

        # Generate the bulk information to query the GeoNet database
        bulk_info = []
        for station in stations:
            bulk_info.append(('NZ', station[0], '*',
                              station[1][0] + 'H' + station[1][-1], t1, t2))

        # Set up a client to access the GeoNet database
        client = Client("GEONET")

        # Note this will take a little while.
        print('Downloading seismic data, this may take a while')
        st = client.get_waveforms_bulk(bulk_info)
        # Merge the stream, it will be downloaded in chunks
        st.merge(fill_value='interpolate')

        # Work out what data we actually have to cope with possible lost data
        stations = list(set([tr.stats.station for tr in st]))

        # Set how many cores we want to parallel across, we will set this to four
        # as this is the number of templates, if your machine has fewer than four
        # cores/CPUs the multiprocessing will wait until there is a free core.
        # Setting this to be higher than the number of templates will have no
        # increase in speed as only detections for each template are computed in
        # parallel.  It may also slow your processing by using more memory than
        # needed, to the extent that swap may be filled.
        ncores = 4

        # Pre-process the data to set frequency band and sampling rate
        # Note that this is, and MUST BE the same as the parameters used for the
        # template creation.
        print('Processing the seismic data')
        st = pre_processing.dayproc(st, lowcut=2.0, highcut=9.0,
                                    filt_order=4, samp_rate=20.0,
                                    debug=0, starttime=t1, num_cores=ncores)
        # Convert from list to stream
        st = Stream(st)

        # Now we can conduct the matched-filter detection
        detections = match_filter.match_filter(template_names=template_names,
                                               template_list=templates,
                                               st=st, threshold=8.0,
                                               threshold_type='MAD',
                                               trig_int=6.0, plotvar=plot,
                                               plotdir='.', cores=ncores,
                                               tempdir=False, debug=1,
                                               plot_format='jpg')

        # Now lets try and work out how many unique events we have just to compare
        # with the GeoNet catalog of 20 events on this day in this sequence
        for master in detections:
            keep = True
#.........这里部分代码省略.........
开发者ID:xiansch,项目名称:EQcorrscan,代码行数:103,代码来源:match_filter.py

示例9: Client

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_waveforms_bulk [as 别名]
    t2 = t1 + 86400

    # Generate the bulk information to query the GeoNet database
    bulk_info = []
    for station in stations:
        bulk_info.append(('NZ', station[0], '*', station[1][0]+'H*', t1, t2))
        # Note that we are only using the first letter of the channel code to
        # download all channels from that sensor at that site, e.g. if the
        # channel code is HHZ we will download HHE and HHN as well.

    # Set up a client to access the GeoNet database
    client = Client("GEONET")

    # Note this will take a little while.
    print('Downloading seismic data, this may take a while')
    st = client.get_waveforms_bulk(bulk_info)
    # Merge the stream, it will be downloaded in chunks
    st.merge(fill_value='interpolate')

    # Work out what data we actually have to cope with possible lost data
    stations = list(set([tr.stats.station for tr in st]))

    # Pre-process the data to set frequency band and sampling rate
    # Note that this is, and MUST BE the same as the parameters used for the
    # template creation.
    print('Processing the seismic data')
    st = Parallel(n_jobs=10)(delayed(pre_processing.dayproc)
                             (tr=tr, lowcut=2.0, highcut=9.0, filt_order=3,
                              samp_rate=20.0, debug=0, starttime=t1)
                             for tr in st)
    # Convert from list to stream
开发者ID:kstaniek,项目名称:EQcorrscan,代码行数:33,代码来源:match_filter.py

示例10: fdsnws

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_waveforms_bulk [as 别名]
def fdsnws(base_url="http://arclink.ethz.ch:8080",
                      endafter=40.,
                      maxradius=.6,
                      location='*',
                      channel='HNZ,HNE,HNN,HGZ,HGE,HGN,HHZ,HHE,HHN,EHZ,EHE,EHN,SHZ,SHE,SHN',
                      stations_base_url=None,
                      waveforms_base_url=None,
                      quality=None,
                      minimumlength=None,
                      longestonly=None,
           correction_method = remove_sensitivity,
         eventid=None,
                      **get_events_options):
    
    
    # First import :
    from obspy.clients.fdsn import Client
    fdsnclient = Client(base_url)
    
    # eventid in URL case
    if eventid is  None:
        eventid = 'smi:ch.ethz.sed/sc3a/2017epaqsp'
        print('Picks default eventid:',eventid)
    elif '#' in eventid :
        eventid = eventid.split('#')[-1]
        print('Picks eventid in URL format:',eventid)
    
    # Special clients systems
    stationsclient = fdsnclient
    waveformsclient = fdsnclient
    if stations_base_url:
        stationsclient = Client(stations_base_url)
        if not waveforms_base_url:
            waveformsclient = Client(stations_base_url)
    if waveforms_base_url:
        waveformsclient = Client(waveforms_base_url)
        if not stations_base_url:
            stationsclient = Client(waveforms_base_url)
    


    # Load event
    fdsnclient.get_events(eventid=eventid,format='sc3ml',filename='events.xml', **get_events_options)
    eventstreams = {'catalog': obspy.read_events('events.xml',format='sc3ml'),
                    'inventory': obspy.core.inventory.Inventory([],None),
                    'raw' : obspy.core.Stream()}
    if eventstreams['catalog'] is None:
        print('catalog is',eventstreams['catalog'])
    for output in ['catalog','inventory','raw']:
        eventstreams[output].output=output
    
    for event in eventstreams['catalog'].events :
        
        # Load stations
        t=event.preferred_origin().time
        try:
            inventory = stationsclient.get_stations(level='station',
                                                startbefore=t,
                                                endafter=t+endafter,
                                                latitude=event.preferred_origin().latitude,
                                                longitude=event.preferred_origin().longitude,
                                                maxradius=maxradius,
                                                location=location,
                                                channel=channel)
        except:
            print('No station found for event:')
            print(event)
            print('Using client:')
            print(stationsclient)
            continue
        # Load waveforms
        addons = [location, channel] + [t,t+endafter]
        bulk = [tuple(station.split()[0].split('.')[:2]+addons) for station in inventory.get_contents()['stations']]
        try:
            waveforms = waveformsclient.get_waveforms_bulk(bulk,
                                                      attach_response=True,
                                                      quality=quality,
                                                      minimumlength=minimumlength,
                                                      longestonly=longestonly)
        except:
            print('No waveform found for request:')
            print(bulk)
            print('Using client:')
            print(waveformsclient)
            continue
        # Improve waveforms attributes
        for trace in waveforms:
            station = inventory.select(network=trace.stats.network,
                                       station=trace.stats.station).networks[0].stations[0]
            trace.stats.coordinates = {'latitude':station.latitude,
                                       'longitude':station.longitude,
                                       'elevation':station.elevation}
            distance = obspy.geodetics.base.gps2dist_azimuth(station.latitude,
                                                             station.longitude,
                                                             event.preferred_origin().latitude,
                                                             event.preferred_origin().longitude)[0]
            distance = ((distance**2+(trace.stats.coordinates['elevation']*-1)**2.)**.5)
            distance = distance/len(eventstreams['catalog'].events)
            if not hasattr(trace.stats, 'distance'):
                trace.stats.distance = 0.
#.........这里部分代码省略.........
开发者ID:FMassin,项目名称:py-NnK,代码行数:103,代码来源:eventstreams.py


注:本文中的obspy.clients.fdsn.Client.get_waveforms_bulk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。