GeophyAI

Python与地球物理数据处理

0%

OBSpy天然地震II

OBSpy教程之获取地震事件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from obspy import UTCDateTime
from obspy.geodetics.flinnengdahl import FlinnEngdahl
def get_events(starttime, endtime, minmagnitude):
from obspy.clients.fdsn import Client
c = Client("IRIS")
events = c.get_events(starttime=starttime,
endtime=endtime,
minmagnitude=minmagnitude)
return events
def get_region_and_mag(event):
if hasattr(event, "preferred_origin"):
# Get the time from the preferred origin, alternatively the first
# origin.
origin = event.preferred_origin()
if origin is None:
if event.origins:
origin = event.origins[0]
else:
return
time = origin.time

# Do the same for the magnitude.
mag = event.preferred_magnitude()
if mag is None:
if event.magnitudes:
mag = event.magnitudes[0]
if mag is None:
mag = ""
else:
# mag.mag/mag.magnitude_type:获取震级、震级单位类型
mag = "%.1f %s" % (mag.mag, mag.magnitude_type)
# 根据经纬度获取地区名
region = FlinnEngdahl().get_region(origin.longitude,
origin.latitude)
#or region = event.event_descriptions[0].text
else:
return False
return region, mag, time

starttime = UTCDateTime('2019-08-31T23:59:59.840000Z')
endtime = UTCDateTime('2020-08-31T23:59:59.840000Z')
minmagnitude = 6.5
events = get_events(starttime, endtime, minmagnitude)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
>>> print(events)
31 Event(s) in Catalog:
2020-08-30T21:20:29.655000Z | +0.769, -29.833 | 6.5 mww
2020-08-21T04:09:52.276000Z | -6.670, +123.493 | 6.9 mww
...
2019-09-25T23:46:43.029000Z | -3.460, +128.368 | 6.5 Mww
2019-09-01T15:54:20.411000Z | -20.360, -178.567 | 6.6 mww
To see all events call 'print(CatalogObject.__str__(print_all=True))'
>>> for i in range(len(events)):
....region, mag, time = get_region_and_mag(events[i])
....print(region, mag, time)
CENTRAL MID-ATLANTIC RIDGE 6.5 mww 2020-08-30T21:20:29.655000Z
BANDA SEA 6.9 mww 2020-08-21T04:09:52.276000Z
SOUTHERN SUMATRA, INDONESIA 6.9 mww 2020-08-18T22:29:24.731000Z
SOUTHERN SUMATRA, INDONESIA 6.8 mww 2020-08-18T22:23:59.478000Z
SAMAR, PHILIPPINES 6.6 mww 2020-08-18T00:03:48.698000Z
ALASKA PENINSULA 7.8 Mww 2020-07-22T06:12:44.593000Z
EASTERN NEW GUINEA REG., P.N.G. 7.0 mww 2020-07-17T02:50:22.162000Z
JAVA SEA 6.7 Mww 2020-07-06T22:54:47.897000Z
NEAR COAST OF OAXACA, MEXICO 7.4 mww 2020-06-23T15:29:04.329000Z
SOUTH OF KERMADEC ISLANDS 7.4 Mww 2020-06-18T12:49:53.747000Z
RYUKYU ISLANDS, JAPAN 6.6 Mww 2020-06-13T15:51:24.069000Z
NORTHERN CHILE 6.8 mww 2020-06-03T07:35:34.844000Z
NEVADA 6.5 Mww 2020-05-15T11:03:27.176000Z
SANTA CRUZ ISLANDS 6.6 mww 2020-05-12T22:41:12.177000Z
BANDA SEA 6.8 Mww 2020-05-06T13:53:56.960000Z
CRETE, GREECE 6.6 mww 2020-05-02T12:51:06.662000Z
BONIN ISLANDS, JAPAN REGION 6.6 Mww 2020-04-18T08:25:37.081000Z
WESTERN IDAHO 6.8 Ml 2020-03-31T23:52:31.094000Z
EAST OF KURIL ISLANDS 7.5 Mww 2020-03-25T02:49:20.896000Z
KURIL ISLANDS 7.0 mww 2020-02-13T10:33:44.492000Z
CUBA REGION 7.7 mww 2020-01-28T19:10:24.963000Z
TURKEY 6.7 Mww 2020-01-24T17:55:13.987000Z
MINDANAO, PHILIPPINES 6.8 mww 2019-12-15T06:11:51.155000Z
NORTHERN MOLUCCA SEA 7.1 Mww 2019-11-14T16:17:40.582000Z
FIJI ISLANDS REGION 6.5 Mww 2019-11-08T10:44:44.876000Z
TONGA ISLANDS 6.6 Mww 2019-11-04T22:43:32.280000Z
MINDANAO, PHILIPPINES 6.5 mww 2019-10-31T01:11:19.122000Z
MINDANAO, PHILIPPINES 6.6 Mww 2019-10-29T01:04:43.863000Z
OFF COAST OF CENTRAL CHILE 6.7 mww 2019-09-29T15:57:53.236000Z
SERAM, INDONESIA 6.5 Mww 2019-09-25T23:46:43.029000Z
FIJI ISLANDS REGION 6.6 mww 2019-09-01T15:54:20.411000Z
1
events.plot()

events

上述代码获取了从starttime到endtime之间一年以内,震级为6.5级以上的地震事件,并将其发生的地理位置、震级和时间(UTC)打印出来。