fr1ll commited on
Commit
6a1b8b1
·
1 Parent(s): 208bc83

single dipping layer

Browse files
Files changed (1) hide show
  1. app.py +22 -92
app.py CHANGED
@@ -1,114 +1,44 @@
1
  import streamlit as st
2
- import bruges as b
3
  from einops import repeat
4
  import numpy as np
5
- from bruges.reflection.reflection import zoeppritz_rpp as zrpp
6
  import pandas as pd
7
  import altair as alt
8
 
 
 
 
9
 
10
- def vs_from_poisson(vp, poisson):
11
- '''compute pressure velocity from
12
- shear velocity and poissons ratio'''
13
- return np.sqrt((vp**2 - 2*poisson*vp**2)/(2 - 2*poisson))
14
-
15
-
16
- def gardners(vp):
17
- '''compute density via gardners relation'''
18
- return 1000*0.31*np.power(vp, 0.25)/1.33
19
-
20
-
21
- def cartesian_product(*arrays):
22
- '''return cartesion product of several arrays'''
23
- ndim = len(arrays)
24
- return (np.stack(np.meshgrid(*arrays), axis=-1)
25
- .reshape(-1, ndim))
26
-
27
-
28
- def loop_zrpp(vp1,vs1,rho1,vp2,vs2,rho2,theta1):
29
- '''compute reflectivity for many values of
30
- input parameters.
31
- "1" denotes layer one, "2" denotes layer two.
32
- outside this function, I tend to use 0-indexing though.'''
33
- refl_loop = np.empty(len(vp1), dtype=complex)
34
- for i in range(vp1.shape[0]):
35
- refl_loop[i] = zrpp(vp1=vp1[i], vs1=vs1[i], rho1=rho1[i],
36
- vp2=vp2[i], vs2=vs2[i], rho2=rho2[i],
37
- theta1=theta1[i])
38
- return refl_loop
39
-
40
- def wb_ava_fig(vwater=1520., rwater = 1025., poissons=0.49):
41
  '''
42
  AVO: Amplitude Versus Offset
43
  AVA: Amplitude Versus Angle
44
  compute AVA at the WB for a range of values,
45
  then plot using altair
46
  '''
47
- ### Set up some variables
48
- VP1 = np.arange(1530,1820,50)
49
- THE = np.arange(0.0, 88., 1.)
50
- POI = np.array([poissons])
51
-
52
- ### Set variables that depend on those variables
53
- params = cartesian_product(VP1, THE, POI)
54
- VP1, THE, POI = [a.ravel() for a in np.hsplit(params, 3)]
55
- VP0 = np.full(VP1.shape, vwater)
56
- # V-RMS for ~200 m water depth
57
- VS0 = np.full(VP1.shape, 0.)
58
- RH0 = np.full(VP1.shape, rwater)
59
- # 1025 kg/m^3 per Inversion of the physical properties of seafloor surface, South China Sea, Zhou et al 2021
60
- VP1 = VP1
61
- VS1 = vs_from_poisson(VP1,POI)
62
- RH1 = gardners(VP1)
63
-
64
- ### Shove into a dict to pass to zrpp
65
- params = {"vp1": VP0, "vs1": VS0, "rho1": RH0,
66
- "vp2": VP1, "vs2": VS1, "rho2": RH1,
67
- "theta1":THE}
68
-
69
- # Compute zoeppritz equation
70
- r = loop_zrpp(**params)
71
-
72
- # Put the results into a DataFrame
73
- df = pd.DataFrame({"Vp sub-WB": VP1, "Poisson_s ratio": POI, "Vs sub-WB": VS1,
74
- "Angle": THE, "Amplitude": np.real(r)})
75
-
76
- # Select only points pre-critical angle
77
- df["Ang_Crit"] = np.degrees(np.arcsin(1500 / df["Vp sub-WB"].values))
78
- df = df[df["Angle"] < df["Ang_Crit"]]
79
-
80
- # Create the altair figure
81
- highlight = alt.selection(type='single', on='mouseover',
82
- fields=["Vp sub-WB:Q"], nearest=True)
83
-
84
- base = alt.Chart(df).encode(
85
- x="Angle",
86
- y="Amplitude",
87
- color="Vp sub-WB:Q",
88
- tooltip=["Vp sub-WB", "Vs sub-WB", "Angle", "Amplitude"]
89
- )
90
-
91
- points = base.mark_circle().encode(
92
- opacity=alt.value(0)
93
- ).add_selection(
94
- highlight
95
  ).properties(
96
- width=600,
97
- height=450
98
- )
99
-
100
- lines = base.mark_line().encode(
101
- size=alt.condition(~highlight, alt.value(3), alt.value(7))
102
  )
103
 
104
- return points + lines
105
 
106
- vwater = st.slider("Select a value for water velocity", min_value=1495, max_value=1545, value=1520)
107
- rwater = st.slider("Select a value for density of water", min_value=1005, max_value=1045, value=1025)
108
- poissons = st.slider("Select a value for Poisson's ratio", min_value=0.4, max_value=0.5, value=0.48)
109
  # st.write("Poisson's ratio is:", p)
110
 
111
 
112
- st.altair_chart(wb_ava_fig(vwater, rwater, poissons))
113
 
114
 
 
1
  import streamlit as st
 
2
  from einops import repeat
3
  import numpy as np
 
4
  import pandas as pd
5
  import altair as alt
6
 
7
+ MAXDIP = 60.
8
+ XMAX = 30
9
+ YMAX = XMAX*np.tan(np.deg2rad(MAXDIP))
10
 
11
+ def fig_1(dip=26.6):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  '''
13
  AVO: Amplitude Versus Offset
14
  AVA: Amplitude Versus Angle
15
  compute AVA at the WB for a range of values,
16
  then plot using altair
17
  '''
18
+ X = np.array([0,XMAX])
19
+ dipping_reflector = np.array([0,np.abs(X[0]-X[1])*np.tan(np.deg2rad(dip))])
20
+
21
+ df = pd.DataFrame({"x":X,
22
+ "z":dipping_reflector
23
+ }
24
+ )
25
+
26
+ lines = alt.Chart(df).mark_line().encode(
27
+ alt.X(field="x", type="quantitative", axis = alt.Axis(orient="top"),
28
+ scale=alt.Scale(domain=[0,XMAX])),
29
+ alt.Y(field="z", type="quantitative", scale=alt.Scale(domain=[0,YMAX],
30
+ reverse=True))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  ).properties(
32
+ width=YMAX*10,
33
+ height=XMAX*10
 
 
 
 
34
  )
35
 
36
+ return lines
37
 
38
+ refector_dip = st.slider("Set reflector dip in degrees", min_value=0.1, max_value=MAXDIP, value=26.6)
 
 
39
  # st.write("Poisson's ratio is:", p)
40
 
41
 
42
+ st.altair_chart(fig_1(refector_dip))
43
 
44