-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselect_f.py
More file actions
55 lines (28 loc) · 821 Bytes
/
Copy pathselect_f.py
File metadata and controls
55 lines (28 loc) · 821 Bytes
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
import numpy as np
import sys
file_to_read = str(sys.argv[1])
f0 = float(sys.argv[2])
def apply_lin(filename, f0, v_lim=0.0035, v_thres=0.0002, gamma=1.5):
#f0 is dependent on the previous sequence
#setting up test features
try:
X = np.loadtxt(filename)
f = X[:, 0]
v = X[:, 1]
v_lin = np.empty((1, 0))
if len(X) > 1:
v_lin = v[v > v_thres]
print v_lin
if v_lin.size > 1:
idx = np.where(v> v_thres)
f_lin = f[idx]
z = np.polyfit(f_lin, v_lin, 1)
f_next = (v_lim - z[1])/z[0]
else:
f_next = gamma*f0
except:
f_next = f0
return f_next
if __name__ == "__main__":
f_next = apply_lin(filename=file_to_read, f0=f0)
print f_next