fr1ll commited on
Commit
c18aa6e
·
1 Parent(s): 9ea4f07

Add altair charts

Browse files
Files changed (1) hide show
  1. app.py +61 -2
app.py CHANGED
@@ -6,5 +6,64 @@ from bruges.reflection.reflection import zoeppritz_rpp as zrpp
6
  import pandas as pd
7
  import altair as alt
8
 
9
- x = st.slider("Select a value")
10
- st.write(x, "squared is", x*x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  import pandas as pd
7
  import altair as alt
8
 
9
+ p = st.slider("Select a value for Poisson's ratio", min_value=0.4, max_value=0.5)
10
+ st.write("Poisson's ratio is:", p)
11
+
12
+ def vs_from_poisson(vp, poisson):
13
+ return np.sqrt((vp**2 - 2*poisson*vp**2)/(2 - 2*poisson))
14
+
15
+ def gardners(vp):
16
+ return 1000*0.31*np.power(vp, 0.25)/1.33
17
+
18
+ def cartesian_product(*arrays):
19
+ ndim = len(arrays)
20
+ return (np.stack(np.meshgrid(*arrays), axis=-1)
21
+ .reshape(-1, ndim))
22
+
23
+ VP1 = np.arange(1530,1820,50)
24
+ THE = np.arange(0.0, 88., 1.)
25
+ POI = np.array([p])
26
+
27
+ params = cartesian_product(VP1, THE, POI)
28
+ VP1, THE, POI = [a.ravel() for a in np.hsplit(params, 3)]
29
+
30
+ VP0 = np.full(VP1.shape, 1520.)
31
+ # V-RMS for ~200 m water depth
32
+ VS0 = np.full(VP1.shape, 0.)
33
+ RH0 = np.full(VP1.shape, 1025)
34
+ # 1025 kg/m^3 per Inversion of the physical properties of seafloor surface, South China Sea, Zhou et al 2021
35
+ VP1 = VP1
36
+ VS1 = vs_from_poisson(VP1,POI)
37
+ RH1 = gardners(VP1)
38
+
39
+ params = {"vp1": VP0, "vs1": VS0, "rho1": RH1,
40
+ "vp2": VP1, "vs2": VS1, "rho2": RH1,
41
+ "theta1":THE}
42
+
43
+ def loop_zrpp(vp1,vs1,rho1,vp2,vs2,rho2,theta1):
44
+ refl_loop = np.empty(len(vp1), dtype=complex)
45
+ for i in range(vp1.shape[0]):
46
+ refl_loop[i] = zrpp(vp1=vp1[i], vs1=vs1[i], rho1=rho1[i],
47
+ vp2=vp2[i], vs2=vs2[i], rho2=rho2[i],
48
+ theta1=theta1[i])
49
+ return refl_loop
50
+
51
+ r = loop_zrpp(**params)
52
+
53
+ df = pd.DataFrame({"Vp sub-WB": VP1, "Poisson_s ratio": POI,
54
+ "Angle": THE, "Amplitude": np.real(r)})
55
+ df["Ang_Crit"] = np.degrees(np.arcsin(1500 / df["Vp sub-WB"].values))
56
+ df = df[df["Angle"] < df["Ang_Crit"]]
57
+
58
+ chart = alt.Chart(df).mark_line().encode(
59
+ x="Angle",
60
+ y="Amplitude",
61
+ color="Vp sub-WB"
62
+ ).properties(
63
+ width=180,
64
+ height=180
65
+ ).facet(
66
+ column='Poisson_s ratio:N'
67
+ )
68
+
69
+ st.altair_chart(chart)