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


Python fdsn.Client类代码示例

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


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

示例1: FDSN_bulk_request

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,代码行数:27,代码来源:fdsn_handler.py

示例2: get_all_mags

def get_all_mags(eventid):
    """Get all magnitudes for a given event ID.

    Args:
        eventid (str): ComCat Event ID.
    Returns:
        dict: Dictionary where keys are "magsrc-magtype" and values
              are magnitude value.

    """
    row = {}
    msg = ''
    client = Client('USGS')
    try:
        obsevent = client.get_events(eventid=eventid).events[0]
    except Exception as e:
        msg = 'Failed to download event %s, error "%s".' % (eventid, str(e))
    for mag in obsevent.magnitudes:
        magvalue = mag.mag
        magtype = mag.magnitude_type
        magsrc = get_mag_src(mag)
        colname = '%s-%s' % (magsrc, magtype)
        if colname in row:
            continue
        row[colname] = magvalue
    return (row, msg)
开发者ID:usgs,项目名称:libcomcat,代码行数:26,代码来源:utils.py

示例3: get_waveforms

def get_waveforms():
    events = get_events()[::-1]
    client = Client('GFZ')
    stream_raw = Stream()
    stream = RFStream()
    coords = inventory.get_coordinates(seedid[:-1] + 'Z')
    for i, event in enumerate(events):
        t = event.preferred_origin().time
        args = seedid.split('.') + [t + 4.9 * 60, t + 14.1 * 60]
        s = client.get_waveforms(*args)
        s.trim(t+5*60, t+14*60)
        s.decimate(int(round(s[0].stats.sampling_rate)) // 5, no_filter=True)
        stream_raw.extend(s)
        if i in (0, 2, 4):
            s = s.copy()
            stats = rfstats(station=coords, event=event, dist_range=(20, 95))
            if stats is None:
                continue
            s.trim(stats.onset - 25, stats.onset + 75)
            stats = obj2stats(station=coords, event=event)
            s = RFStream(s)
            for tr in s:
                tr.stats.update(stats)
            stream.extend(s)
    stream_raw.write(wavname, 'MSEED')
    stream.write(wavname2, 'SAC')
开发者ID:trichter,项目名称:rf,代码行数:26,代码来源:create_example_files.py

示例4: test_rectangular_geo_queries

    def test_rectangular_geo_queries(self):
        client = FDSNClient(self.live_server_url)
        # lat = 48.995167
        # lon = 11.519922

        # This works.
        self.assertEqual(
            len(client.get_stations(
                minlatitude=48, maxlatitude=49,
                minlongitude=11, maxlongitude=12).get_contents()["stations"]),
            1)

        # Make sure one border does not include the point at a time.
        with self.assertRaises(FDSNException):
            client.get_stations(minlatitude=48.996, maxlatitude=49,
                                minlongitude=11, maxlongitude=12)

        with self.assertRaises(FDSNException):
            client.get_stations(minlatitude=48, maxlatitude=48.5,
                                minlongitude=11, maxlongitude=12)

        with self.assertRaises(FDSNException):
            client.get_stations(minlatitude=48, maxlatitude=49,
                                minlongitude=11.6, maxlongitude=12)

        with self.assertRaises(FDSNException):
            client.get_stations(minlatitude=48, maxlatitude=49,
                                minlongitude=11, maxlongitude=11.4)
开发者ID:krischer,项目名称:jane,代码行数:28,代码来源:test_station_1.py

示例5: test_station_to_seisan

    def test_station_to_seisan(self):
        from obspy.clients.fdsn import Client
        from obspy import UTCDateTime
        from eqcorrscan.utils.sfile_util import stationtoseisan

        t1 = UTCDateTime(2012, 3, 26)
        t2 = UTCDateTime(2012, 4, 26)
        client = Client('GEONET')
        bulk = [('NZ', 'FOZ', '*', '*', t1, t2),
                ('NZ', 'JCZ', '*', '*', t1, t2),
                ('NZ', 'WVZ', '*', '*', t1, t2)]
        inventory = client.get_stations_bulk(bulk, level="channel")
        for station in inventory[0]:
            sta_str = stationtoseisan(station)
            self.assertEqual(len(sta_str), 27)

        for station in inventory[0]:
            station.latitude = abs(station.latitude)
            station.longitude = abs(station.longitude)
            sta_str = stationtoseisan(station)
            self.assertEqual(len(sta_str), 27)

        with self.assertRaises(IOError):
            inventory = client.get_stations_bulk(bulk)
            for station in inventory[0]:
                sta_str = stationtoseisan(station)
开发者ID:xiansch,项目名称:EQcorrscan,代码行数:26,代码来源:sfile_util_test.py

示例6: test_level_argument

    def test_level_argument(self):
        client = FDSNClient(self.live_server_url)

        inv = client.get_stations(level="channel")
        c = inv.get_contents()
        self.assertEqual(len(c["networks"]), 1)
        self.assertEqual(len(c["stations"]), 1)
        self.assertEqual(len(c["channels"]), 3)

        inv = client.get_stations(level="station")
        c = inv.get_contents()
        self.assertEqual(len(c["networks"]), 1)
        self.assertEqual(len(c["stations"]), 1)
        self.assertEqual(len(c["channels"]), 0)

        inv = client.get_stations(level="network")
        c = inv.get_contents()
        self.assertEqual(len(c["networks"]), 1)
        self.assertEqual(len(c["stations"]), 0)
        self.assertEqual(len(c["channels"]), 0)

        inv = client.get_stations(level="response")
        c = inv.get_contents()
        self.assertEqual(len(c["networks"]), 1)
        self.assertEqual(len(c["stations"]), 1)
        self.assertEqual(len(c["channels"]), 3)

        for channel in inv[0][0]:
            self.assertIsNotNone(channel.response)
开发者ID:krischer,项目名称:jane,代码行数:29,代码来源:test_station_1.py

示例7: download

    def download(self, s):

        client = Client("IRIS")
        starttime = obspy.UTCDateTime("2010-01-01")
        endtime = obspy.UTCDateTime("2015-01-02")

        # for s in stations:
            # Try and download, don't worry if no data is available.
        try:
            stream = client.get_stations(network=s.net, station=s.sta, starttime=starttime, endtime=endtime,
                                         level="channel")
            fname = os.path.join("STATION_XML_META", "station.{}_{}.meta.xml".format(s.net, s.sta))
            stream.write(fname, format='STATIONXML')
        except Exception as e:
            print e
            pass

        try:
            stream = client.get_stations(network=s.net, station=s.sta, starttime=starttime, endtime=endtime,
                                         level="response")
            fname = os.path.join("STATION_XML_META", "station.{}_{}.response.xml".format(s.net, s.sta))
            stream.write(fname, format='STATIONXML')
            print 'Finished downloading {}.{}'.format(s.net, s.sta)
        except Exception as e:
            print e
            pass
开发者ID:lermert,项目名称:OvalOffice,代码行数:26,代码来源:DownloadStations.py

示例8: fdsn_bulk_request

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,代码行数:26,代码来源:data_handler.py

示例9: create_nodes_from_fdsn

    def create_nodes_from_fdsn(self, base_url, network_code, station_codes,
                               channel_codes, location_codes, country_code="",
                               node_prefix=""):
        '''
        Creates WebObs Nodes architecture and configuration files from FDSN
        Web Service (fdsnws)

        :type base_url: str
        :param base_url: A string representing the FDSN provider URL.
        :type network_code: str
        :param network_code: A string representing the FDSN network code.
        :type station_codes: str
        :param station_codes: A string representing the FDSN station(s) 
            (wildcard accepted).
        :type channel_codes: str
        :param channel_codes: A string representing the FDSN channel(s)
            (wildcard accepted).
        :type location_codes: str
        :param location_codes: A string representing the FDSN location 
            code(s) (wildcard accepted).
        :type country_code: str, optional
        :param country_code: A string representing the country code. 
        :type node_prefix: str, optional
        :param node_prefix: A string representing the node prefix.
        '''
        # Connect to FDSN web service and retrieve inventory
        fdsn_client = Client(base_url=base_url)
        inventory = fdsn_client.get_stations(network=network_code,
                                             station=station_codes,
                                             channel=channel_codes,
                                             location=location_codes,
                                             level="response")
        for network in inventory.networks:
            print("Processing %s network" % (network.code))
            for station in network.stations:
                print("|--Processing %s station" % (station.code))
                # Create node name and path
                node_name = "%s%s%s" % (country_code, node_prefix,
                                          station.code)
                node_path = "%s/%s" % (self.output_dir, node_name)
                # Create file tree and files
                if not os.path.exists(node_path):
                    os.makedirs(node_path)
                    os.makedirs("%s/DOCUMENTS/THUMBNAILS" % (node_path))
                    os.makedirs("%s/FEATURES" % (node_path))
                    os.makedirs("%s/INTERVENTIONS" % (node_path))
                    os.makedirs("%s/PHOTOS/THUMBNAILS" % (node_path))
                    os.makedirs("%s/SCHEMAS/THUMBNAILS" % (node_path))
                    open("%s/acces.txt" % (node_path), 'a').close()
                    open("%s/info.txt" % (node_path), 'a').close()
                    open("%s/installation.txt" % (node_path), 'a').close()
                    open("%s/%s.kml" % (node_path, node_name), 'a').close()
                    open("%s/FEATURES/sensor.txt" % (node_path), 'a').close()
                    open("%s/INTERVENTIONS/%s_Projet.txt" %
                         (node_path, node_name), 'a').close()
                    self.create_clb_file(node_path=node_path,
                                         node_name=node_name,
                                         network_code=network.code,
                                         station=station)
开发者ID:PBoissier,项目名称:fdsn2nodes,代码行数:59,代码来源:fdsn2nodes.py

示例10: inv4stream

def inv4stream(stream, network, client_name):

	start 	= stream[0].stats.starttime
	end 	= stream[0].stats.endtime
	client 	= Client(client_name)
	inv 	= client.get_stations(network=network, starttime=start, endtime=end)

	return inv
开发者ID:s-schneider,项目名称:FK-Toolbox,代码行数:8,代码来源:base.py

示例11: test_download_various_methods

    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,代码行数:58,代码来源:template_gen_test.py

示例12: test_query_data

 def test_query_data(self):
     # query using ObsPy
     t1 = UTCDateTime("2005-10-06T07:21:59.850000")
     t2 = UTCDateTime("2005-10-06T07:24:59.845000")
     client = FDSNClient(self.live_server_url)
     got = client.get_waveforms("", "RJOB", "", "Z", t1, t2)[0]
     expected = read(FILES[0])[0]
     np.testing.assert_equal(got.data, expected.data)
     self.assertEqual(got, expected)
开发者ID:krischer,项目名称:jane,代码行数:9,代码来源:test_dataselect_1.py

示例13: getCatData

def getCatData(date, opt):

    """
    Download data from IRIS or Earthworm waveserver with padding and filter it. This is
    a specialized version getData() for catalog events, pulling a smaller amount of time
    around a known event.

    date: UTCDateTime of known catalog event
    opt: Options object describing station/run parameters
    
    Returns ObsPy stream objects, one for cutting and the other for triggering
    """    
    
    nets = opt.network.split(',')
    stas = opt.station.split(',')
    locs = opt.location.split(',')
    chas = opt.channel.split(',')
    
    if opt.server == "IRIS":
        client = Client("IRIS")
    else:
        client = EWClient(opt.server, opt.port)
        
    st = Stream()
    for n in range(len(stas)):
        try:
            stmp = client.get_waveforms(nets[n], stas[n], locs[n], chas[n],
                    date - opt.atrig, date + 3*opt.atrig)
            stmp = stmp.filter("bandpass", freqmin=opt.fmin, freqmax=opt.fmax,
                corners=2, zerophase=True)
            stmp = stmp.merge(method=1, fill_value='interpolate')
        except (obspy.fdsn.header.FDSNException):
            try: # try again
                stmp = client.get_waveforms(nets[n], stas[n], locs[n], chas[n],
                        date - opt.atrig, date + 3*opt.atrig)
                stmp = stmp.filter("bandpass", freqmin=opt.fmin, freqmax=opt.fmax,
                    corners=2, zerophase=True)
                stmp = stmp.merge(method=1, fill_value='interpolate')
            except (obspy.fdsn.header.FDSNException):
                print('No data found for {0}.{1}'.format(stas[n],nets[n]))
                trtmp = Trace()
                trtmp.stats.sampling_rate = opt.samprate
                trtmp.stats.station = stas[n]
                stmp = Stream().extend([trtmp.copy()])
        # Resample to ensure all traces are same length
        if stmp[0].stats.sampling_rate != opt.samprate:
            stmp = stmp.resample(opt.samprate)
        st.extend(stmp.copy()) 
    
    st = st.trim(starttime=date-opt.atrig, endtime=date+3*opt.atrig, pad=True,
        fill_value=0)
    stC = st.copy() 

    return st, stC
开发者ID:iceseismic,项目名称:REDPy,代码行数:54,代码来源:trigger.py

示例14: get_channel_orientation

def get_channel_orientation(t0, net, st0, loc, duration, channel):
    """
    Get the station channel orientation.

    Returns azimuth and dip angle.
    """
    client = Client('IRIS')
    st0 = client.get_stations(starttime=t0, endtime=t0+duration*60,
                              network=net, station=st0, channel=channel,
                              level='channel')
    return st0[0][0].channels[0].azimuth, st0[0][0].channels[0].dip
开发者ID:jrleeman,项目名称:SeismoVisualize,代码行数:11,代码来源:SeismoVisualize.py

示例15: get_events

def get_events():
    try:
        return read_events(evname)
    except Exception:
        pass
    client = Client()
    events = client.get_events(starttime=t1, endtime=t2, latitude=lat,
                               longitude=lon, minradius=30, maxradius=90,
                               minmagnitude=6., maxmagnitude=6.5)
    events.write(evname, 'QUAKEML')
    return events
开发者ID:trichter,项目名称:rf,代码行数:11,代码来源:create_example_files.py


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