-
Notifications
You must be signed in to change notification settings - Fork 2
/
plot_atten_curve.py
executable file
·61 lines (54 loc) · 1.77 KB
/
plot_atten_curve.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
"""
Plot up attenuation curve
"""
from scipy import interpolate
import matplotlib.pyplot as plt
import numpy as np
import sys
python3 = sys.version_info > (3,0)
if python3:
import pickle
else:
import cPickle as pickle
class atten_spline:
def __init__(self, m0, pgvv, pgvh, pgvm, pgav, pgah, pgam):
self.m0 = m0
self.pgvv = pgvv
self.pgvh = pgvh
self.pgvm = pgvm
self.pgav = pgav
self.pgah = pgah
self.pgam = pgam
# Read in attenuation curve and sample on distarray
# model = 'DWAK'
# model = 'EH45Tcold'
# model = 'MAAK'
# model = '3d_1dmean'
depth_in_km = 10.0
f1 = 0.1
f2 = 1.0
fig = plt.figure()
lines = ['k-', 'k--']
models = ['EH45Tcold', 'EH45TcoldCrust1b']
for i, model in enumerate(models):
print("Working on model {}: {}".format(i, model))
attenfile = ("atten_curves/" +
"{}_{:.1f}km_filt_{:.3f}_{:.3f}".format(model, depth_in_km,
f1, f2) +
"_atten_interp.pkl")
with open(attenfile, 'rb') as f:
atten_interp = pickle.load(f, encoding='latin1')
diststep = 5.0
distarray = np.arange(diststep, 180.0 + diststep, diststep)
amparray = np.zeros_like(distarray)
for j, dist in enumerate(distarray):
amparray[j] = interpolate.splev(dist, atten_interp.pgav, ext=3)
plt.plot(distarray, amparray, lines[i], label=model)
plt.xlabel(r'Distance ($^{\circ}$)')
plt.ylabel('Peak acceleration ($m/s^2$)')
plt.legend()
# pngfile = "{}_{:.1f}km_filt_{:.3f}_{:.3f}_atten_interp.png".format(model,
# depth_in_km,
# f1, f2)
pngfile = 'atten_curve.png'
plt.savefig(pngfile)