-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignal_generator.py
52 lines (41 loc) · 1.44 KB
/
signal_generator.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
import numpy as np
import sys
import matplotlib
import matplotlib.pyplot as plt
points = int(sys.argv[1]) # total points
frequency = 50000 # fake made-up sample frequency of input signal -- Chimera is 1MHz
high_mean = 10
current_sd = 0.1
event_space = 1 # second
event_time = 0.1 # second
event_time_sd = 0.05 # second
event_depth = 0.6
event_depth_sd = 0.05
print("I see a point count of "+str(points))
print("I see a frequency of "+str(frequency))
print("I calculate EVENTS = "+str(points/frequency))
print("NOW GO EDIT THE VALUE in find_events.cu -- and yes, TODO a better way of handing this")
mu, sigma = high_mean, current_sd
s = np.float16(np.random.normal(mu, sigma, points))
x_axis = np.arange(points, dtype='int32')
event_count = int((points/frequency)/event_space)
for start in range(1, event_count):
go = int(start*points/event_count)
cur_time = np.random.normal(event_time, event_time_sd)
cur_depth = np.random.normal(event_depth, event_depth_sd)
for index in range(go, go+int(cur_time*frequency)):
s[index] = s[index]*cur_depth
y = np.array(s)
x = np.array(x_axis)
plt.plot(x, y,
color='blue',
linestyle='solid',
linewidth=2, marker='o',
markerfacecolor='blue',
markersize=2)
plt.savefig('generated_signal.png')
plt.close()
file_signal = open("signal.csv", "w")
print(points, file=file_signal)
for value in s:
print(value, file=file_signal)