-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSlope_Method.py
More file actions
50 lines (31 loc) · 1.55 KB
/
Slope_Method.py
File metadata and controls
50 lines (31 loc) · 1.55 KB
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
def Analyze(X,Y):
T = [x for x,y in zip(X,Y) if 9.6e-6 <= x <= 13e-6]
V = [y for x,y in zip(X,Y) if 9.6e-6 <= x <= 13e-6]
T = [x for x,y in zip(X,Y) if 9.6e-6 <= x <= T[V.index(min(V))-1]]
V = [y for x,y in zip(X,Y) if 9.6e-6 <= x <= T[V.index(min(V))-1]]
T_noise = [x for x,y in zip(X,Y) if 9.5e-6 <= x <= 10.5e-6]
V_noise = [y for x,y in zip(X,Y) if 9.5e-6 <= x <= 10.5e-6]
global derivative
derivative = np.gradient(V,T)
derivative_noise = np.gradient(V_noise,T_noise)
mean_noise = np.mean(V_noise)
mean = np.mean(derivative_noise)
std = np.std(derivative_noise)
for t,v,d in zip(T,V,derivative):
if np.abs(d) > np.abs(mean + 10*np.abs(std)):
descent = t
break
else:
continue
T = [x for x,y in zip(X,Y) if descent <= x <= (descent + 0.2e-6)]
V = [y for x,y in zip(X,Y) if descent <= x <= (descent + 0.2e-6)]
T_descent = [x for x,y in zip(X,Y) if descent <= x <= T[V.index(min(V))-1]]
V_descent = [y for x,y in zip(X,Y) if descent <= x <= T[V.index(min(V))-1]]
m, b = np.polyfit(T_descent, V_descent, deg=1)
arrival_P = (mean_noise - b) / m
T_S = [x for x,y in zip(X,Y) if 15.5e-6 <= x <= 19e-6]
V_S = [y for x,y in zip(X,Y) if 15.5e-6 <= x <= 19e-6]
T_S = [x for x,y in zip(X,Y) if 15.5e-6 <= x <= (T_S[V_S.index(max(V_S))] + 0.3e-6)]
V_S = [y for x,y in zip(X,Y) if 15.5e-6 <= x <= (T_S[V_S.index(max(V_S))] + 0.3e-6)]
arrival_S = T_S[V_S.index(min(V_S))]
return m, b, mean_noise, descent, arrival_P, arrival_S