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


Python Client.get_stations方法代码示例

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


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

示例1: data_download

# 需要导入模块: from obspy.fdsn import Client [as 别名]
# 或者: from obspy.fdsn.Client import get_stations [as 别名]
def data_download(stations, starttime, endtime, event_name):

    print "\n========================================"
    print "event:", event_name
    print "time:", starttime, endtime
    waveforms_folder = "waveforms/" + event_name
    stationxml_folder = "stationxml/" + event_name
    c = Client("IRIS")

    if not os.path.exists(waveforms_folder):
        os.makedirs(waveforms_folder)

    if not os.path.exists(stationxml_folder):
        os.makedirs(stationxml_folder)

    for network, station in stations:
        ### First download waveforms.
        filename = os.path.join(waveforms_folder,
                            "%s.%s.mseed" % (network, station))
        if os.path.exists(filename):
            continue

        try:
            c.get_waveforms(network=network, station=station, location="*",
                            channel="BH?", starttime=starttime, endtime=endtime,
                            filename=filename)
        except Exception as e:
            print("Failed to download %s.%s due to %s" %
                (network, station, str(e)))
            continue

        print("Successfully downloaded %s." % filename)
        ###

        ### Then download stationxml file
        stationxml_filename = os.path.join(stationxml_folder,
                                       "%s.%s.xml" % (network, station))

        if os.path.exists(stationxml_filename):
            continue

        try:
            c.get_stations(network=network, station=station, location="*",
                            channel="BH?", starttime=starttime, endtime=endtime,
                            filename=stationxml_filename, level="response")
        except Exception as e:
            print("Failed to download %s.%s StationXML due to %s" % (
                network, station, str(e)))
            continue

        print("Successfully downloaded %s." % stationxml_filename)
开发者ID:yanhuay,项目名称:SeisProc,代码行数:53,代码来源:download_data.py

示例2: getepidata

# 需要导入模块: from obspy.fdsn import Client [as 别名]
# 或者: from obspy.fdsn.Client import get_stations [as 别名]
def getepidata(event_lat, event_lon, event_time, tstart=-5., tend=200., minradiuskm=0., maxradiuskm=20., channels='*', location='*', source='IRIS'):
    """
    Automatically pull existing data within a certain distance of the epicenter (or any lat/lon coordinates) and attach station coordinates to data
    USAGE
    st = getepidata(event_lat, event_lon, event_time, tstart=-5., tend=200., minradiuskm=0., maxradiuskm=20., channels='*', location='*', source='IRIS')
    INPUTS
    event_lat = latitude of event in decimal degrees
    event_lon = longitude of event in decimal degrees
    event_time = Event time in UTC in any format obspy's UTCDateTime can parse - e.g. '2016-02-05T19:57:26'
    tstart = number of seconds to add to event time for start time of data (use negative number to start before event_time)
    tend = number of seconds to add to event time for end time of data
    radiuskm = radius to search for data
    channels = 'strong motion' to get all strong motion channels (excluding low sample rate ones), 'broadband' to get all broadband instruments, 'short period' for all short period channels, otherwise a single line of comma separated channel codes, * wildcards are okay, e.g. channels = '*N*,*L*'
    location = comma separated list of location codes allowed, or '*' for all location codes
    source = FDSN source, 'IRIS', 'NCEDC', 'GEONET' etc., see list here http://docs.obspy.org/archive/0.10.2/packages/obspy.fdsn.html

    OUTPUTS
    st = obspy stream containing data from within requested area
    """
    event_time = UTCDateTime(event_time)
    client = FDSN_Client(source)

    if channels.lower() == 'strong motion':
        channels = 'EN*,HN*,BN*,EL*,HL*,BL*'
    elif channels.lower() == 'broadband':
        channels = 'BH*,HH*'
    elif channels.lower() == 'short period':
        channels = 'EH*'
    else:
        channels = channels.replace(' ', '')  # Get rid of spaces

    t1 = UTCDateTime(event_time) + tstart
    t2 = UTCDateTime(event_time) + tend

    inventory = client.get_stations(latitude=event_lat, longitude=event_lon, minradius=minradiuskm/111.32, maxradius=maxradiuskm/111.32, channel=channels, level='channel', startbefore=t1, endafter=t2)
    temp = inventory.get_contents()
    netnames = temp['networks']
    stas = temp['stations']
    stanames = [n.split('.')[1].split()[0] for n in stas]

    st = getdata(','.join(unique_list(netnames)), ','.join(unique_list(stanames)), location, channels, t1, t2, attach_response=True, clientname=source)

    if st is None:
        print('No data returned')
        return

    for trace in st:
        try:
            coord = inventory.get_coordinates(trace.id)
            trace.stats.coordinates = AttribDict({'latitude': coord['latitude'], 'longitude': coord['longitude'], 'elevation': coord['elevation']})
        except:
            print('Could not attach coordinates for %s' % trace.id)

    return st
开发者ID:mhearne-usgs,项目名称:smtools,代码行数:56,代码来源:iris.py

示例3: get_inventory

# 需要导入模块: from obspy.fdsn import Client [as 别名]
# 或者: from obspy.fdsn.Client import get_stations [as 别名]
def get_inventory():
    try:
        return read_inventory(invname)
    except:
        pass
    client = Client('GFZ')
    net, sta, loc, cha = seed_id.split('.')
    inv = client.get_stations(starttime=t1, endtime=t2, network=net,
                              station=sta, location=loc, channel=cha,
                              level='channel')
                              # latitude=lat, longitude=lon, maxradius=10)
    inv.write(invname, 'STATIONXML')
    return inv
开发者ID:iceseismic,项目名称:rf,代码行数:15,代码来源:create_example_files.py

示例4: get_inventory

# 需要导入模块: from obspy.fdsn import Client [as 别名]
# 或者: from obspy.fdsn.Client import get_stations [as 别名]
def get_inventory():
    print('Read inventory file')
    try:
        return read_inventory(invname, 'STATIONXML')
    except:
        pass
    print('Create inventory file...')
    client = FSDNClient('ORFEUS')
    inv = client.get_stations(**inventory_kwargs)
    for net in inv:
        for sta in net[:]:
            if sta.code not in stations:
                net.stations.remove(sta)
    inv.write(invname, 'STATIONXML')
    return inv
开发者ID:iceseismic,项目名称:qopen,代码行数:17,代码来源:create_example_files.py

示例5: getSlowestStation

# 需要导入模块: from obspy.fdsn import Client [as 别名]
# 或者: from obspy.fdsn.Client import get_stations [as 别名]
def getSlowestStation(lat,lon,depth,calc):
    client = Client("IRIS")
    inventory = client.get_stations(latitude=lat, longitude=lon,maxradius=1.5)
    lats = []
    lons = []
    codes = []
    for network in inventory.networks:
        for station in network.stations:
            lats.append(station.latitude)
            lons.append(station.longitude)
            codes.append(station.code)
    lats = np.array(lats)
    lons = np.array(lons)
    codes = np.array(codes)
    distances = []
    times = []
    for i in range(0,len(lats)):
        slat = lats[i]
        slon = lons[i]
        distance = locations2degrees(lat,lon,slat,slon)
        distances.append(distance)
        ptime,stime = calc.getTravelTimes(distance,depth)
        times.append(ptime)
    times = np.array(times)
    distances = np.array(distances)
    sortidx = np.argsort(distances)
    distances = distances[sortidx]
    times = times[sortidx]
    lats = lats[sortidx]
    lons = lons[sortidx]
    codes = codes[sortidx]
    distances = distances[0:4]
    times = times[0:4] + TELEMETRY_DELAY + PROCESSING_DELAY
    lats = lats[0:4]
    lons = lons[0:4]
    codes = codes[0:4]
    idx = times.argmax()
    sdict = {'lat':lats[idx],'lon':lons[idx],'time':times[idx],'code':codes[idx]}
    return sdict
开发者ID:mhearne-usgs,项目名称:alertmap,代码行数:41,代码来源:alertmap.py

示例6: Client

# 需要导入模块: from obspy.fdsn import Client [as 别名]
# 或者: from obspy.fdsn.Client import get_stations [as 别名]
endtime = None
network = "YV"
station = "*"
location = '*'
channel = '*H*'

file_name = 'list_stas_created.txt'
# ########################## END INPUT

client = Client(req_client)
if starttime:
    starttime = UTCDateTime(starttime)
if endtime:
    endtime = UTCDateTime(endtime)
inv = client.get_stations(network=network, station=station,
                          location=location, channel=channel,
                          starttime=starttime, endtime=endtime,
                          level='channel')
content = inv.get_contents()
chans = list(set(content['channels']))
chans.sort()

net_inv = inv.networks[0]

fio = open(file_name, 'w')
for _i in range(len(chans)):
    net, sta, loc, cha = chans[_i].split('.')
    try:
        coord_chan = get_coordinates(net_inv, chans[_i], None)
        fio.writelines('%s  %s  %s  %s  %s  %s  %s  %s\n'
                       % (sta, net, loc, cha, coord_chan['latitude'],
                          coord_chan['longitude'], coord_chan['elevation'],
开发者ID:qingkaikong,项目名称:obspyDMT,代码行数:34,代码来源:create_list_stas.py

示例7: test_download_urls_for_custom_mapping

# 需要导入模块: from obspy.fdsn import Client [as 别名]
# 或者: from obspy.fdsn.Client import get_stations [as 别名]
    def test_download_urls_for_custom_mapping(self, download_url_mock):
        """
        Tests the downloading of data with custom mappings.
        """
        base_url = "http://example.com"

        # More extensive mock setup simulation service discovery.
        def custom_side_effects(*args, **kwargs):
            if "version" in args[0]:
                return 200, "1.0.200"
            elif "event" in args[0]:
                with open(os.path.join(
                        self.datapath, "2014-01-07_iris_event.wadl"),
                        "rb") as fh:
                    return 200, fh.read()
            elif "station" in args[0]:
                with open(os.path.join(
                        self.datapath,
                        "2014-01-07_iris_station.wadl"), "rb") as fh:
                    return 200, fh.read()
            elif "dataselect" in args[0]:
                with open(os.path.join(
                        self.datapath,
                        "2014-01-07_iris_dataselect.wadl"), "rb") as fh:
                    return 200, fh.read()
            return 404, None

        download_url_mock.side_effect = custom_side_effects

        # Some custom urls
        base_url_event = "http://other_url.com/beta/event_service/11"
        base_url_station = "http://some_url.com/beta2/station/7"
        base_url_ds = "http://new.com/beta3/dataselect/8"

        # An exception will be raised if not actual WADLs are returned.
        # Catch warnings to avoid them being raised for the tests.
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            c = Client(base_url=base_url, service_mappings={
                "event": base_url_event,
                "station": base_url_station,
                "dataselect": base_url_ds,
            })
        for warning in w:
            self.assertTrue("Could not parse" in str(warning) or
                            "cannot deal with" in str(warning))

        # Test the dataselect downloading.
        download_url_mock.reset_mock()
        download_url_mock.side_effect = None
        download_url_mock.return_value = 404, None
        try:
            c.get_waveforms("A", "B", "C", "D", UTCDateTime() - 100,
                            UTCDateTime())
        except:
            pass
        self.assertTrue(
            base_url_ds in download_url_mock.call_args_list[0][0][0])

        # Test the station downloading.
        download_url_mock.reset_mock()
        download_url_mock.side_effect = None
        download_url_mock.return_value = 404, None
        try:
            c.get_stations()
        except:
            pass
        self.assertTrue(
            base_url_station in download_url_mock.call_args_list[0][0][0])

        # Test the event downloading.
        download_url_mock.reset_mock()
        download_url_mock.side_effect = None
        download_url_mock.return_value = 404, None
        try:
            c.get_events()
        except:
            pass
        self.assertTrue(
            base_url_event in download_url_mock.call_args_list[0][0][0])
开发者ID:avuan,项目名称:obspy,代码行数:82,代码来源:test_client.py

示例8: Client

# 需要导入模块: from obspy.fdsn import Client [as 别名]
# 或者: from obspy.fdsn.Client import get_stations [as 别名]
outfolder = '/storage/ANT/NZ Station Responses'
# create list of all possible FDSN clients that work under obspy. 
client_list = (u'BGR', u'ETH', u'GEONET', u'GFZ', u'INGV',
               u'IPGP', u'IRIS', u'KOERI', u'LMU', u'NCEDC', 
               u'NEIP', u'NERIES', u'ODC', u'ORFEUS', u'RESIF',
               u'SCEDC', u'USGS', u'USP')
                
client = Client("GEONET")

starttime = UTCDateTime("2014-01-01")
endtime = UTCDateTime("2015-01-01")

inventory = client.get_stations(network="*", 
                                station="*",
                                loc='*',
                                channel="*Z",
                                starttime=starttime, 
                                endtime=endtime,
                                level="response")

for net in inventory: 
    print net
    for sta in net:
        print sta

quit()

# save all response plots
#inventory[0].plot_response(min_freq=1E-4, 
#                           channel="BHZ",  
#                           location="10",
开发者ID:iceseismic,项目名称:SeisSuite,代码行数:33,代码来源:FDSN_resp.py

示例9: value

# 需要导入模块: from obspy.fdsn import Client [as 别名]
# 或者: from obspy.fdsn.Client import get_stations [as 别名]
#
# Normalize traces and find absolute max value (for plotting)
#
stalist_obtained = []
absmax = -999999
st.normalize()
for tr in st:
    stalist_obtained.append(tr.stats.station)
    tr_abs_max = np.max(np.abs(tr.data))
    if tr_abs_max > absmax:
        absmax = tr_abs_max

# Get station inventory so we have lats/lons
stalist_obtained_string = str.join(",",stalist_obtained)
inventory = client.get_stations(network=netlist, station=stalist_obtained_string, location=loclist, channel=chanlist, starttime=starttime, endtime=endtime)

# Normalize the color map (can adjust to play with saturation)
cmap = cm.bwr
#norm = mpl.colors.Normalize(vmin=-absmax, vmax=absmax)
norm = mpl.colors.Normalize(vmin=-0.5, vmax=0.5)
print(-absmax, absmax)

#
# Get list of station lat/lons
# 
lats = []
lons = []
codes = []
nets = []
for net in inventory:
开发者ID:ewolin,项目名称:PythonGMV,代码行数:32,代码来源:GMV.py

示例10: Client

# 需要导入模块: from obspy.fdsn import Client [as 别名]
# 或者: from obspy.fdsn.Client import get_stations [as 别名]
from obspy.fdsn import Client
client = Client("IRIS")

from obspy.fdsn.header import URL_MAPPINGS
for key in sorted(URL_MAPPINGS.keys()):
    print("{0:<7} {1}".format(key,  URL_MAPPINGS[key]))
    

# Inventory (from link above) --------------------------------------------------

starttime = UTCDateTime("2002-01-01")
endtime = UTCDateTime("2002-01-02")

inventory = client.get_stations(network="IU", station="A*",
                                starttime=starttime,
                                endtime=endtime)

print(inventory)


# NCEDC channels request -------------------------------------------------------

client = Client("NCEDC")

starttime = UTCDateTime("2015-07-07")
endtime = UTCDateTime("2015-07-08")


# NOTE:  Good documentation on STATIONXML and the ObsPy "Inventory" object is here:
# NOTE:
开发者ID:MazamaScience,项目名称:ispaq,代码行数:32,代码来源:test_obspy_fdsn.py

示例11: Client

# 需要导入模块: from obspy.fdsn import Client [as 别名]
# 或者: from obspy.fdsn.Client import get_stations [as 别名]
if __name__ == '__main__':
    client = Client("IRIS")
    network = "XF"
    starttime = UTCDateTime("2003-06-01")
    endtime = UTCDateTime("2003-11-01")
    # endtime = UTCDateTime("1999-05-19")
    # endtime = UTCDateTime("1998-12-04")
    # endtime = UTCDateTime("1998-12-05")    

    events = client.get_events(starttime=starttime, endtime=endtime,
                               minmagnitude=5.5, catalog="ISC")
    # events.plot()

    stations = client.get_stations(network=network, station="H*",
                                   starttime=starttime, endtime=endtime,
                                   level="response")
    # stations.plot()
    # stations.plot(projection=u'local', resolution=u'f')
    default_dir = os.getcwd() + '/data_60_120/'
    for event in events:
        origin = event.origins[0]
        print origin
        event_latitude = origin.latitude
        event_longitude = origin.longitude
        event_depth = origin.depth  # km
        event_time = origin.time
        event_time_str = str(event_time.year) + '.' + str(event_time.julday).zfill(3) + '.' +\
            str(event_time.hour).zfill(2) + str(event_time.minute).zfill(2) + \
            str(event_time.second).zfill(2)
        event_dir = default_dir + '/' + event_time_str
开发者ID:IFDYS,项目名称:Process_HiCLIMB,代码行数:32,代码来源:download_data.py

示例12: Client

# 需要导入模块: from obspy.fdsn import Client [as 别名]
# 或者: from obspy.fdsn.Client import get_stations [as 别名]
output_dir = "StationXML"

c = Client()

inv = read_inventory("./all_stations.xml")


def print_error(msg):
    print colorama.Fore.RED + msg + colorama.Fore.RESET


def print_ok(msg):
    print colorama.Fore.GREEN + msg + colorama.Fore.RESET


for network in inv.networks:
    for station in network.stations:
        output_filename = os.path.join(output_dir, "%s.%s.xml" % (network.code, station.code))
        if os.path.exists(output_filename):
            continue

        try:
            out = c.get_stations(network=network.code, station=station.code, level="response")
        except:
            print_error("Failed to download %s.%s." % (network.code, station.code))
            continue
        with open(output_filename, "w") as fh:
            fh.write(out)
        print_ok("Downloaded %s.%s." % (network.code, station.code))
开发者ID:jordklode,项目名称:sandbox,代码行数:31,代码来源:download_all_stations.py


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