当前位置: 首页 > 工具软件 > ObsPy > 使用案例 >

20200615翻译_obspy的obspy.clients.fdsn模块

庄欣然
2023-12-01

obspy.clients.fdsn — ObsPy的FDSN网络服务客户端

obspy.clients.fdsn包包含一个访问实现fdsn 网络服务定义的web服务器的客户端。

内容

  • 基本的FDSN客户端用法
  • 基本的Routing(路由)客户端用法
  • 类&函数
  • 模块

1.基本的FDSN客户端用法

  第一步总是初始化客户端对象:

>>>from obspy.clients.fdsn import Client
>>>client = Client("IRIS")

  客户端对象可以用任何FDSN web服务的基URL(eg:http://service.iris.edu)或将映射到FDSN URL的快捷方式名称(eg:IRIS)初始化。所有示例都使用了IRIS的FDSN web服务。有关其他可用web服务提供者的列表可见–init–()。当前可用的提供者如下:

>>>from obspy.clients.fdsn.header import URL_MAPPINGS
>>>for key in sorted(URL_MAPPINGS.keys()):
...    print("{0:<11} {1}".format(key,  URL_MAPPINGS[key]))
BGR         http://eida.bgr.de
EMSC        http://www.seismicportal.eu
ETH         http://eida.ethz.ch
GEONET      http://service.geonet.org.nz
GFZ         http://geofon.gfz-potsdam.de
ICGC        http://ws.icgc.cat
INGV        http://webservices.ingv.it
IPGP        http://ws.ipgp.fr
IRIS        http://service.iris.edu
ISC         http://isc-mirror.iris.washington.edu
KNMI        http://rdsa.knmi.nl
KOERI       http://eida.koeri.boun.edu.tr
LMU         http://erde.geophysik.uni-muenchen.de
NCEDC       http://service.ncedc.org
NIEP        http://eida-sc3.infp.ro
NOA         http://eida.gein.noa.gr
ODC         http://www.orfeus-eu.org
ORFEUS      http://www.orfeus-eu.org
RASPISHAKE  http://fdsnws.raspberryshakedata.com
RESIF       http://ws.resif.fr
SCEDC       http://service.scedc.caltech.edu
TEXNET      http://rtserve.beg.utexas.edu
USGS        http://earthquake.usgs.gov
USP         http://sismo.iag.usp.br

1.1 get_waveforms():下面的例子说明如何请求和绘制IU台网的ANMO台站记录的2010-02-27 06:45 (UTC)地震事件LHZ分量发震后60分钟的记录,结果以流对象的形式返回。有关如何同时发送多个请求以避免不必要的网络开销的信息,请参阅 get_waveforms_bulk() 方法。

>>>from obspy import UTCDateTime
>>>t = UTCDateTime("2010-02-27T06:45:00.000")
>>>st = client.get_waveforms("IU", "ANMO", "00", "LHZ", t, t + 60 * 60)
>>>st.plot() 

1.2 get_events():从服务器检索事件数据。结果作为Catalog地震目录)对象返回。

>>>starttime = UTCDateTime("2002-01-01")
>>>endtime = UTCDateTime("2002-01-02")
>>>cat = client.get_events(starttime=starttime, endtime=endtime,
...                        minmagnitude=6, catalog="ISC")
>>>print(cat)  
2 Event(s) in Catalog:
2002-01-01T11:29:22.720000Z |  +6.282, +125.749 | 6.3 MW
2002-01-01T07:28:57.480000Z | +36.991,  +72.336 | 6.3 Mb
>>>cat.plot()  

1.3 get_stations():从服务器检索台站数据。结果作为Inventory对象返回。

>>>inventory = client.get_stations(network="IU", station="A*",
                                ...starttime=starttime,
                                ...endtime=endtime)
>>>print(inventory)  
Inventory created at ...
    Created by: IRIS WEB SERVICE: fdsnws-station | version: ...
                ...
    Sending institution: IRIS-DMC (IRIS-DMC)
    Contains:
            Networks (1):
                    IU
            Stations (3):
                    IU.ADK (Adak, Aleutian Islands, Alaska)
                    IU.AFI (Afiamalu, Samoa)
                    IU.ANMO (Albuquerque, New Mexico, USA)
            Channels (0):
>>>inventory.plot()  

以下为实际搜索NECESS台网

(base) [long@long testobspy]$ python 
Python 3.7.6 (default, Jan  8 2020, 19:59:22) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from obspy.clients.fdsn import Client
>>> client = Client("IRIS")
>>> from obspy import UTCDateTime
>>> starttime = UTCDateTime("2010-01-01")
>>> endtime = UTCDateTime("2011-01-01")
>>> inventory = client.get_stations(network="YP",station="*",starttime=starttime,endtime=endtime)
>>> print(inventory)
Inventory created at 2020-06-15T03:33:41.000000Z
	Created by: IRIS WEB SERVICE: fdsnws-station | version: 1.1.45
		    http://service.iris.edu/fdsnws/station/1/query?starttime=2010-01-01...
	Sending institution: IRIS-DMC (IRIS-DMC)
	Contains:
		Networks (1):
			YP
		Stations (129):
			YP.NE11 (Liaoning Changtuxian Taipingxiang)
			YP.NE12 (Jilin Liaoyuanshi Dongfengxian)
			YP.NE21 (Duolunxian Dabeigouzhen (ERI))
			YP.NE22 (Hebei Weichangxian (ERI))
			YP.NE23 (Chifengshi Songshanqu Damiaozhen (ERI))
			YP.NE31 (Zhenglanqi Sanggendalaizhen (ERI))
			YP.NE32 (Keshiketengqi Yuanbaoshan (ERI))
			YP.NE33 (Keshiketengqi Zhiruizhen (ERI))
			YP.NE34 (Wongniuteqi Wudanzhen (ERI))
			YP.NE35 (Wongniuteqi Ashihansumuderinailin (ERI))
			YP.NE36 (Aaohanqi Xiawazhen (ERI))
			YP.NE37 (Kulunqi Kulunzhen (ERI))
			YP.NE38 (Zhangwuxian Aerxiangzhen)
			YP.NE39 (Kangpinxian Haizhouhaixiang)
			YP.NE3A (Huadianshi Huajiaoxiang)
			YP.NE3B (Dunhuashi Yanjiangxiang)
			YP.NE3C (Bajiazilinyeju Gudonghelinchang)
			YP.NE41 (Xilinhaoteshi (ERI))
			YP.NE42 (Keshiketengqi Dalainuorizhen (ERI))
			YP.NE43 (Balinyouqi Dabanzhen (ERI))
			YP.NE44 (Balinyouqi Yihenuoersumu (ERI))
			YP.NE45 (Wongniuteqi Baiyintalazhen (ERI))
			YP.NE46 (Naimanqi Guoyouliuhaonongchang (ERI))
			YP.NE47 (Sipingshi Lishuxian6)
			YP.NE48 (Baishishanzhen Dabinghugou)
			YP.NE49 (Dunhuashi Dashitouzhen)
			YP.NE4A (Wangqingxian Daxinggouzhen)
			YP.NE4B (Wangqingxian Fuxingzhen)
			YP.NE51 (Xilinhaoteshi Aershanbaoligezhen (ERI))
			YP.NE52 (Xiwuqi Jirengaolezhen (ERI))
			YP.NE53 (Linxixian Xinlinzhen (ERI))
			YP.NE54 (Balinzuoqi Halahadazhen (ERI))
			YP.NE55 (Keerqinzuoyizhongqi Zhurihejingqu (ERI))
			YP.NE56 (Yaolinmaoduzhen Nantagacha)
			YP.NE57 (Tongliaoshi Keerqinzuozhongqi)
			YP.NE58 (Nonganxian Qianganggongshe)
			YP.NE59 (Jiutaishi Tumenlingzhen)
			YP.NE5A (Jiaoheshi Tianbeizhen) (2x)
			YP.NE5B (Wuchangshi Hetunlinyeju)
			YP.NE5C (Dunhuashi Qinggouzixiang)
			YP.NE5D (Ninganshi Wolongchaoxianzuxiang)
			YP.NE5E (Suiyanglinyeju Huangsongdiqu)
			YP.NE61 (Dongwuqi Ejizhaoerzhen (ERI)) (2x)
			YP.NE62 (Xiwuqi Bayanhushusumusharulagacha)
			YP.NE63 (Xiwuqi Balagaergaolezhen (ERI))
			YP.NE64 (Xiwuqi Hanwulasumu (ERI))
			YP.NE65 (Alukeerqinqi Hansumusumushaburitai (ERI))
			YP.NE66 (Zhaluteqi Qianjinzhen (ERI))
			YP.NE67 (Xinganmengkeerqinyouyizhongqi Gaolibanzhen  (ERI))
			YP.NE68 (Tongyuxian Xianghaimengguzuxiang)
			YP.NE69 (Songyuanshi Qiananxian)
			YP.NE6A (Qianguoerluosimengguzuzizhiqu)
			YP.NE6B (Fuyuxian Taolaizhaozhen)
			YP.NE6C (Wuchangshi Xiaoshanzizhen)
			YP.NE6D (Shangzhishi Shitouhezhen)
			YP.NE6E (Mulingshi Bamiantongzhen)
			YP.NE6F (Heilongjiangsheng Jidongxian Hadazhen)
			YP.NE71 (Dongwuqi Gadabuqizhen)
			YP.NE72 (Dongwuqi Wuliyasitaizhen)
			YP.NE73 (Dongwuqi Huretusumuhugejiriletugacha  (ERI))
			YP.NE74 (Dongwuqi Huretusumuhuteleaobaogacha (ERI))
			YP.NE75 (Alukeerqinqi Kunduzhen)
			YP.NE76 (Xinlinguoleshi Barenzhelimubaiyintala)
			YP.NE77 (Xinganmengtuquanxian Tuquanzhen (ERI))
			YP.NE78 (Baichengshi Daanshishelizhen (ERI))
			YP.NE79 (Daanshi Lianhexiang  (ERI))
			YP.NE7A (Shuangchengshi Shuiquanxiang)
			YP.NE7B (Haerbinshi Achengqu)
			YP.NE7C (Shangzhishi Heilonggongzhen)
			YP.NE7D (Heilongjiangsheng Shangzhishi qingyangzhen)
			YP.NE7E (Heilongjiangsheng Hailinshi Chaihelinyediqu)
			YP.NE7F (Linkouxian Shenmeijituan)
			YP.NE7G (Hulinshi Yunshannongkenshequ)
			YP.NE7H (Linkouxian Sandaotongzhen)
			YP.NE81 (Dongwuqi Samaisumuhuerqigegacha)
			YP.NE82 (Xilinhaoteshi Dongwuqi Samaisumuzhen)
			YP.NE83 (Dongwuqi Mandubaoligezhen)
			YP.NE84 (Wulagaiguanliqu Bayinhushuzhen)
			YP.NE85 (Xinganmengkeyouqianqi Alideermuchang (ERI))
			YP.NE86 (Keyouqianqi Wulanhaoteshi Halaheizhen (ERI))
			YP.NE87 (Keyouqianqi Wulanhaoteshi Eergetuzhen (ERI))
			YP.NE88 (Baichengshi Zhenlaixian Tantuzhen (ERI))
			YP.NE89 (Talahazhen Jiujiazicun)
			YP.NE8A (Zhaozhouxian Weixingmuchang)
			YP.NE8B (Suihuashi Xilanxian  (ERI))
			YP.NE8C (Hulanqu Kangjinzhen)
			YP.NE8D (Mulanxian Lidongzhen)
			YP.NE8E (Bayanxian Xinglonglinyeju Dongfangnongchang)
			YP.NE8F (Huananxian Huananzhen)
			YP.NE8G (Qitaiheshi Beixingnongchang)
			YP.NE8H (Baoqingxian nongkenshequ)
			YP.NE8I (Hulinshi Hutouzhen)
			YP.NE91 (Aershanshi Mingshuizhen)
			YP.NE92 (Xinganmengsuolunmuchang)
			YP.NE93 (Zhalaiteqi Badaerhuzhen)
			YP.NE94 (Qiqihaershi Longjiangxian)
			YP.NE95 (Daqingshi Taikangxian (ERI))
			YP.NE96 (Daqingshi Linjianxian Huayuanxiang)
			YP.NE97 (Suihuashi Qinggangxian Yongfengzhen)
			YP.NE98 (Hailunshi Gonghezhen)
			YP.NE99 (Tielishi Gongnongxiang)
			YP.NE9A (Yichunshi Dailingqu Hanyuenongchang)
			YP.NE9B (Tangyuanxian Taipingchuanxiang)
			YP.NE9C (Huachuanxian Xinchengzhen)
			YP.NE9D (Youyixian)
			YP.NE9E (Raohexian Xifengzhen)
			YP.NEA1 (Hulunbeiershi Xinbaerhuzuoqi Handagaiyangguangnong)
			YP.NEA2 (Aershanshi linyejusuhelinchang)
			YP.NEA3 (Zhalantunchaihezhen Wopingjie)
			YP.NEA4 (Zhalantunsamajie Yiqihannongchang (ERI))
			YP.NEA5 (Qiqihaershi Meilisiqu Woniutuzhen)
			YP.NEA6 (Qiqihaershi Yianxian Sanxingzhen)
			YP.NEA7 (Baiquanxian Yonglexiang)
			YP.NEA8 (Hailunshi Hailunnongkenshequ)
			YP.NEA9 (Suilingxian Suilinglinyeju)
			YP.NEAA (Yichunshi Jinshantunqu Baishanlinchang)
			YP.NEAB (Suibinxian Fuxingxiang)
			YP.NEAC (Tongjiangshi Tongjiangzhenchengjiao)
			YP.NEAD (Tongjiangshijiansanjiangguanju Honghenongchang)
			YP.NEAE (Fujinshi Erlongshanzhen)
			YP.NEP1 (Autuxiancheng)
			YP.NEP2 (Xiaoshihu Jilin)
			YP.NEP3 (Xinjiancun Xudashang)
			YP.NEP4 (Baicheng Yanjiaweizi)
			YP.NEP5 (Pingtaizhen Dajiangjia)
			YP.NEP6 (Hinggan Gegenaobao)
			YP.NEP7 (New Barag Zuoqi)
		Channels (0):

2.基本的Routing(路由)客户端用法

  路由器是可以查询哪些数据中心提供了某些(特定)数据的web服务。然后可以使用这些信息从全球各个数据中心获取实际数据。所有当前的路由服务只支持dataselect(数据选择)和station(台站)FDSNWS服务。

ObsPy已经支持两种(routing)路由服务:

使用它们需要调用RoutingClient() 函数:

>>>from obspy.clients.fdsn import RoutingClient

使用IRIS Federator获取一个路由客户端的实例:

>>>client = RoutingClient("iris-federator")
>>>print(type(client))  
<class '...fdsn.routing.federator_routing_client.FederatorRoutingClient'>

或者使用EIDAWS Routing web服务获得一个路由客户端的实例:

>>>client = RoutingClient("eida-routing")
>>>print(type(client))  
<class '...fdsn.routing.eidaws_routing_client.EIDAWSRoutingClient'>

  它们可以像普通的FDSNWS客户端一样使用,这意味着get_(waveforms|stations)(_bulk)()函数应该按预期工作。
  为了能够使用EIDA服务查询地理波形,ObsPy将在下载波形之前在内部执行一个台站查询。从用户的角度来看,这导致了EIDAIRIS routing服务之间的类似使用。
  下面的代码片段将调用IRIS federator,以确定谁拥有该特定查询的波形数据,然后调用各个数据中心来实际获取数据。这是完全自动发生的——请注意,客户端还支持非标准波形查询参数,如地理约束。

>>>from obspy import UTCDateTime
>>>client = RoutingClient("iris-federator")
>>>st = client.get_waveforms(
...    channel="LHZ", starttime=UTCDateTime(2017, 1, 1),
...    endtime=UTCDateTime(2017, 1, 1, 0, 5), latitude=10,
...    longitude=10, maxradius=25)  
>>>print(st)  
2 Trace(s) in Stream:
II.MBAR.00.LHZ | 2017-01-01T00:00:00Z - ... | 1.0 Hz, 300 samples
II.MBAR.10.LHZ | 2017-01-01T00:00:00Z - ... | 1.0 Hz, 300 samples

同样可应用于台站查询:

>>>client = RoutingClient("iris-federator")
>>>inv = client.get_stations(
...    channel="LHZ", starttime=UTCDateTime(2017, 1, 1),
...    endtime=UTCDateTime(2017, 1, 1, 0, 5), latitude=10,
...    level="channel", longitude=10, maxradius=25)  
>>>print(inv)  
Inventory created at 2017-10-09T14:26:28.466161Z
    Created by: ObsPy 1.0.3.post0+1706.gef068de324.dirty
                https://www.obspy.org
    Sending institution: IRIS-DMC,ObsPy ..., SeisComP3 (GFZ,IPGP, IRIS-DMC)
    Contains:
        Networks (6):
            AF, G, II, IU, TT, YY
        Stations (10):
            AF.EKNA (Ekona, Cameroon)
            AF.KIG (Kigali, Rwanda)
            G.TAM (Tamanrasset, Algeria)
            II.MBAR (Mbarara, Uganda)
            IU.KOWA (Kowa, Mali)
            TT.TATN (Station Tataouine, Tunisia)
            YY.GIDA (Health Center, Gidami, Ethiopia)
            YY.GUBA (Police Station, Guba, Ethiopia)
            YY.MEND (High School, Mendi, Ethiopia)
            YY.SHER (Police Station, Sherkole, Ethiopia)
        Channels (11):
            AF.EKNA..LHZ, AF.KIG..LHZ, G.TAM.00.LHZ, II.MBAR.00.LHZ,
            II.MBAR.10.LHZ, IU.KOWA.00.LHZ, TT.TATN.00.LHZ, YY.GIDA..LHZ,
            YY.GUBA..LHZ, YY.MEND..LHZ, YY.SHER..LHZ

请参阅每个方法的文档以获得更多信息和示例

3.类&函数(功能?)

模块功能
client.ClientFDSN Web service request client. FDSN网络服务请求客户端
routing.routing_client.RoutingClientHelper function to get the correct routing instance. 帮助函数,以获得正确的路由实例

4.模块

模块功能
clientFDSN Web service client for ObsPy. ObsPy的FDSN网络服务客户端
routingobspy.clients.fdsn.routing - Routing services for FDSN web services. obspy.clients.fdsn.routing - FDSN网络服务的Routing(路由) services
routing.routing_clientBase class for all FDSN routers. FDSN路由(routers)的基本类.
routing.routing_client.BaseRoutingClient
routing.eidaws_routing_clientRouting client for the EIDAWS routing service. EIDAWS routing 服务的路由(Routing)登陆.
routing.eidaws_routing_client.EIDAWSRoutingClientRouting client for the EIDAWS routing service. EIDAWS routing 服务的路由(Routing)登陆.
routing.federator_routing_clientRouting client for the IRIS federator routing service. IRIS federator routing 服务的路由(Routing)登陆.
routing.federator_routing_client.FederatorRoutingClient
mass_downloaderMass Downloader for FDSN Compliant Web Services. 大规模下载FDSN Compliant网络服务
mass_downloader.domainDomain definitions for the download helpers(下载帮助程序的域定义).
mass_downloader.mass_downloader.MassDownloaderClass facilitating data acquisition across all FDSN web service(类促进跨所有FDSN web服务的数据获取)
mass_downloader.restrictionsNon-geographical restrictions and constraints for the mass downloader(非地理限制和约束为大规模下载).
mass_downloader.download_helpersHelpers for the mass downloader(大容量下载器的助手).
 类似资料: