-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathwrite_p_and_s.py
82 lines (62 loc) · 1.87 KB
/
write_p_and_s.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import os, sys
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = (13, 8) if False else (10, 6)
from obspy.taup.taup import getTravelTimes
from obspy.core.util.geodetics import gps2DistAzimuth
from obspy.taup import TauPyModel
from seismon.eqmon import ampRf, shoot
degrees = np.linspace(1,180,180)
distances = degrees*(np.pi/180)*6370000
depths = np.linspace(1,100,100)
model = TauPyModel(model="iasp91")
#model = TauPyModel(model="1066a")
fwd = 0
back = 0
eqlat, eqlon = 35.6895, 139.6917
GPS = 0
magnitude = 6.0
depth = 20.0
Rf0 = 76.44
Rfs = 1.37
cd = 440.68
rs = 1.57
Rfamp = ampRf(magnitude,distances/1000.0,depth,Rf0,Rfs,cd,rs)
lats = []
lons = []
Ptimes = []
Stimes = []
#Rtimes = []
Rtwotimes = []
RthreePointFivetimes = []
Rfivetimes = []
Rfamps = []
fid1 = open('p.dat','w')
fid2 = open('s.dat','w')
for distance, degree in zip(distances, degrees):
lon, lat, baz = shoot(eqlon, eqlat, fwd, distance/1000)
lats.append(lat)
lons.append(lon)
for depth in depths:
print "Calculating arrival for %.5f ..."%distance
#arrivals = model.get_travel_times(source_depth_in_km=depth,distance_in_degree=degree,phase_list=('P','S'))
arrivals = model.get_travel_times(source_depth_in_km=depth,distance_in_degree=degree)
Ptime = -1
Stime = -1
Rtime = -1
for phase in arrivals:
if Ptime == -1 and phase.name.lower()[0] == "p":
Ptime = GPS+phase.time
if Stime == -1 and phase.name.lower()[-1] == "s":
Stime = GPS+phase.time
Rtwotime = GPS+distance/2000.0
RthreePointFivetime = GPS+distance/3500.0
Rfivetime = GPS+distance/5000.0
fid1.write('%.5f '%Ptime)
fid2.write('%.5f '%Stime)
fid1.write("\n")
fid2.write("\n")
fid1.close()
fid2.close()