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


Python Client.get_stations方法代码示例

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


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

示例1: test_level_argument

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_stations [as 别名]
    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,代码行数:31,代码来源:test_station_1.py

示例2: download

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_stations [as 别名]
    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,代码行数:28,代码来源:DownloadStations.py

示例3: test_rectangular_geo_queries

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_stations [as 别名]
    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,代码行数:30,代码来源:test_station_1.py

示例4: create_nodes_from_fdsn

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_stations [as 别名]
    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,代码行数:61,代码来源:fdsn2nodes.py

示例5: test_redirection

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_stations [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

示例6: inv4stream

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_stations [as 别名]
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,代码行数:10,代码来源:base.py

示例7: get_channel_orientation

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_stations [as 别名]
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,代码行数:13,代码来源:SeismoVisualize.py

示例8: get_inventory

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_stations [as 别名]
def get_inventory():
    try:
        return read_inventory(invname)
    except Exception:
        pass
    client = Client('GFZ')
    net, sta, loc, cha = seedid.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:trichter,项目名称:rf,代码行数:15,代码来源:create_example_files.py

示例9: test_total_and_selected_number_of_sta_and_cha

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_stations [as 别名]
    def test_total_and_selected_number_of_sta_and_cha(self):
        client = FDSNClient(self.live_server_url)

        inv = client.get_stations(level="network")
        self.assertEqual(inv[0].total_number_of_stations, 1)
        self.assertEqual(inv[0].selected_number_of_stations, 0)

        inv = client.get_stations(level="station")
        self.assertEqual(inv[0].total_number_of_stations, 1)
        self.assertEqual(inv[0].selected_number_of_stations, 1)
        self.assertEqual(inv[0][0].total_number_of_channels, 3)
        self.assertEqual(inv[0][0].selected_number_of_channels, 0)

        inv = client.get_stations(level="channel")
        self.assertEqual(inv[0].total_number_of_stations, 1)
        self.assertEqual(inv[0].selected_number_of_stations, 1)
        self.assertEqual(inv[0][0].total_number_of_channels, 3)
        self.assertEqual(inv[0][0].selected_number_of_channels, 3)

        inv = client.get_stations(level="response")
        self.assertEqual(inv[0].total_number_of_stations, 1)
        self.assertEqual(inv[0].selected_number_of_stations, 1)
        self.assertEqual(inv[0][0].total_number_of_channels, 3)
        self.assertEqual(inv[0][0].selected_number_of_channels, 3)
开发者ID:krischer,项目名称:jane,代码行数:26,代码来源:test_station_1.py

示例10: get_station_location

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_stations [as 别名]
def get_station_location(t0, net, st0, loc):
    """
    Get the station latitude, longitude, and elevation.

    Given a time, duration, loc code, and station network/name, get
    station information from IRIS.  Return a list containing the
    lat, lon, and elevation.
    """
    client = Client('IRIS')
    st0 = client.get_stations(starttime=t0, endtime=t0+timedelta(seconds=60),
                              network=net, station=st0, level='station')
    slat = st0[0][0].latitude
    slon = st0[0][0].longitude
    selev = st0[0][0].elevation
    return [slat, slon, selev]
开发者ID:jrleeman,项目名称:RealTimePlotters,代码行数:17,代码来源:plotter.py

示例11: download_stationxml

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_stations [as 别名]
def download_stationxml(stations, starttime, endtime, outputdir=None,
                        client=None, level="response"):

    if client is None:
        client = Client("IRIS")

    if starttime > endtime:
        raise ValueError("Starttime(%s) is larger than endtime(%s)"
                         % (starttime, endtime))

    if not os.path.exists(outputdir):
        raise ValueError("Outputdir not exists: %s" % outputdir)

    _status = {}
    for station_id in stations:
        error_code = "None"
        network, station, location, channel = _parse_station_id(station_id)

        if outputdir is not None:
            filename = os.path.join(outputdir, "%s.xml" % station_id)
            if os.path.exists(filename):
                os.remove(filename)
        else:
            filename = None

        try:
            inv = client.get_stations(
                network=network, station=station, location=location,
                channel=channel, starttime=starttime, endtime=endtime,
                level=level)
            if len(inv) == 0:
                error_code = "Inventory Empty"
            if filename is not None and len(inv) > 0:
                inv.write(filename, format="STATIONXML")
        except Exception as e:
            error_code = "Failed to download StationXML '%s' due to: %s" \
                % (station_id, str(e))
            print(error_code)

        _status[station_id] = error_code

    return {"inventory": inv, "status": _status}
开发者ID:mpbl,项目名称:pytomo3d,代码行数:44,代码来源:download.py

示例12: download_stationxml

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_stations [as 别名]
def download_stationxml(stations, starttime, endtime, outputdir=".",
                        client=None, level="response"):

    if client is None:
        client = Client("IRIS")

    if starttime > endtime:
        raise ValueError("Starttime(%s) is larger than endtime(%s)"
                         % (starttime, endtime))

    if not os.path.exists(outputdir):
        raise ValueError("Outputdir not exists: %s" % outputdir)

    _status = {}
    for station_id in stations:
        network, station, location, channel = _parse_station_id(station_id)

        filename = os.path.join(outputdir, "%s.xml" % station_id)
        if os.path.exists(filename):
            os.remove(filename)

        try:
            inv = client.get_stations(
                network=network, station=station, location=location,
                channel=channel, starttime=starttime, endtime=endtime,
                level=level)
            if len(inv) > 0:
                inv.write(filename, format="STATIONXML")
                error_code = 0
            else:
                error_code = 1
        except Exception as e:
            print("Failed to download StationXML '%s' due to: %s"
                  % (station_id, str(e)))
            error_code = 2
        _status[station_id] = error_code

    return _status
开发者ID:wjlei1990,项目名称:pytomo3d,代码行数:40,代码来源:download.py

示例13: get_inventory

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_stations [as 别名]
    def get_inventory(self):
        starttime = UTCDateTime()
        endtime = UTCDateTime()
        client = Client(self.fdsn_server)
        for s in self.streams:
            net, sta, chan, loc = s
            inv = client.get_stations(starttime=starttime,
                                      endtime=endtime,
                                      network=net,
                                      station=sta,
                                      location=loc,
                                      channel=chan,
                                      level="response")
            channels = set(inv.get_contents()['channels'])

            for c in channels:
                try:
                    coords = inv.get_coordinates(c, datetime=starttime)
                except:
                    try:
                        coords = inv.get_coordinates(c)
                    except:
                        print c, "No matching coordinates found"
                        continue

                latitude = coords['latitude']
                longitude = coords['longitude']
                elevation = coords['elevation']
                self.station_coordinfo[c] = \
                    {"latitude": latitude,
                     "longitude": longitude,
                     "elevation": elevation,
                     "geohash": Geohash.encode(latitude,
                                               longitude,
                                               precision=7)
                     }
开发者ID:marcopovitch,项目名称:sl2influxdb,代码行数:38,代码来源:station.py

示例14: test_radial_queries

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_stations [as 别名]
    def test_radial_queries(self):
        client = FDSNClient(self.live_server_url)
        lat = 48.995167 + 1.0
        lon = 11.519922

        self.assertEqual(
            len(client.get_stations(
                latitude=lat, longitude=lon,
                maxradius=2).get_contents()["stations"]),
            1)

        self.assertEqual(
            len(client.get_stations(
                latitude=lat, longitude=lon,
                maxradius=1.1).get_contents()["stations"]),
            1)

        with self.assertRaises(FDSNException):
            client.get_stations(latitude=lat, longitude=lon,
                                minradius=1.1, maxradius=10)

        with self.assertRaises(FDSNException):
            client.get_stations(latitude=lat, longitude=lon,
                                minradius=0.1, maxradius=0.5)
开发者ID:krischer,项目名称:jane,代码行数:26,代码来源:test_station_1.py

示例15: UTCDateTime

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_stations [as 别名]
starttime = UTCDateTime("2016-05-20")
endtime = UTCDateTime("2016-05-22")
cat = client.get_events(starttime=starttime, endtime=endtime, minmagnitude=2, limit=5, mindepth=5)
print(type(cat)) #Catalog
print(cat)
cat.plot(outfile='output/py_eq_utc20160521_ml3.0_event.png') #add also resouces like: projection="local"

#get stations with the event
evt = cat[1]
print(type(evt))
print(evt)
origin = evt.origins[0]
otime = origin.time
print(type(origin))
t = origin.time
inv = client.get_stations(longitude=origin.longitude, latitude=origin.latitude, maxradius=0.2, starttime=t, endtime =t+100, channel="HH?", network="CH", level="station")
print(type(inv))
print(inv)
inv.plot(projection="local", outfile='output/py_eq_utc20160521_ml3.0_station.png')

#get the waveforms
st = Stream()
for network in inv:
    for station in network:
        try:
            st += client.get_waveforms(network.code, station.code, "*", "HH?", t - 5 * 60, t + 30 * 60, attach_response=True)
        except:
            pass
#print(type(st))
#print(st)
#st.select(component="Z").plot(bgcolor="#FF5733")
开发者ID:cwebber04,项目名称:SAMSFAULTZ_CODE,代码行数:33,代码来源:py_eq_utc20160521_ml3.0.py


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