-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathfit_shear_angle.py
71 lines (54 loc) · 1.96 KB
/
fit_shear_angle.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
import matplotlib.pyplot as plt
import sys
from fault_kinematics.homogeneous_simple_shear import invert_slip
import data
def optimize_single_alpha():
"""Find the single shear angle that best flattens all horizons using a grid
search."""
fault = data.to_world(data.to_xyz(data.fault))
alphas = range(-80, 85, 5)
roughness = []
for alpha in alphas:
update('Alpha = %i: ' % alpha)
rough = 0
for i, hor in enumerate(data.horizons):
xyz = data.to_world(data.to_xyz(hor))[::50]
update('%i ' % (len(data.horizons) - i))
slip, metric = invert(fault, xyz, alpha)
rough += metric
update('\n')
roughness.append(rough)
fig, ax = plt.subplots()
ax.plot(alphas, roughness)
ax.set_title('Optimizing Shear Angle')
ax.set_ylabel('Summed misfit (m)')
ax.set_xlabel('Shear angle (degrees)')
fig.savefig('optimize_single_alpha.pdf')
plt.show()
def optimize_individual_alpha():
"""Find the best shear angle for each horizon using a grid search."""
fault = data.to_world(data.to_xyz(data.fault))
alphas = range(-80, 85, 5)
for hor in data.horizons:
update(hor.name + ': ')
xyz = data.to_world(data.to_xyz(hor))[::50]
roughness = []
for i, alpha in enumerate(alphas):
update('%i ' % (len(alphas) - i))
slip, metric = invert(fault, xyz, alpha)
roughness.append(metric)
update('\n')
fig, ax = plt.subplots()
ax.plot(alphas, roughness)
ax.set_title(hor.name)
ax.set_ylabel('Misfit (m)')
ax.set_xlabel('Shear angle (degrees)')
fig.savefig('optimize_alpha_individual_%s.pdf'%hor.name)
plt.show()
def invert(fault, xyz, alpha):
return invert_slip(fault, xyz, alpha, overlap_thresh=1, return_metric=True)
def update(text):
sys.stdout.write(str(text))
sys.stdout.flush()
optimize_single_alpha()
#optimize_individual_alpha()