GeophyAI

Python与地球物理数据处理

0%

OBSpy天然地震III

天然地震

OBSpy教程之Client

获取不同Client的url

1
2
3
4
5
6
7
8
9
10
11
12
13
14
from obspy.clients.fdsn import Client
c=Client(base_url="IRIS")
"""
base_url: Base URL of FDSN web service compatible server
(e.g. "http://service.iris.edu") or key string for recognized
server (one of 'BGR', 'EMSC', 'ETH', 'GEONET', 'GFZ', 'ICGC',
'INGV', 'IPGP', 'IRIS', 'ISC', 'KNMI', 'KOERI', 'LMU', 'NCEDC',
'NIEP', 'NOA', 'ODC', 'ORFEUS', 'RASPISHAKE', 'RESIF', 'SCEDC',
'TEXNET', 'UIB-NORSAR', 'USGS', 'USP').
"""
"""
The list below get from 'Client(abbr).base_url', where abbr
is the key string of server.
"""

在地图上显示network中的台站位置

1
2
3
c = Client("IRIS")
cgt = c.get_stations(network="II")
cgt.plot()

cgt

根据日期获取指定台站数据并按天分割

当需要下载指定台站、指定日期范围内的地震数据时,可以使用以下代码。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import obspy
from obspy.clients.fdsn.mass_downloader import RectangularDomain, Restrictions, MassDownloader
from obspy import UTCDateTime

domain = RectangularDomain(minlatitude=-90,
maxlatitude=90,
minlongitude=-180,
maxlongitude=180)

restrictions = Restrictions(starttime=UTCDateTime(2020, 7, 20),
endtime=UTCDateTime(2020, 7, 22),
chunklength_in_sec=86400,
network="II",
station="KDAK",
location="*",
channel="*",
reject_channels_with_gaps=False,
minimum_length=0.0,
minimum_interstation_distance_in_m=100.0)
mdl = MassDownloader()# providers=["IRIS"]
mdl.download(domain,
restrictions,
mseed_storage="./data/KDAK/waveforms",
stationxml_storage="./data/KDAK/stations")

以上代码中,下载了从starttimeendtime范围内,网络II、台站KDAK的所有通道数据,并将其截取为每个文件86400s长度(即一天)