-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_main.py
63 lines (52 loc) · 2.17 KB
/
run_main.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
53
54
55
56
57
58
59
60
61
62
63
import data_streaming as stream
import config_general as cfg
import matplotlib.pyplot as plt
import numpy as np
import signal_processing as proc
def main():
test_forge()
if 2<1:
template = np.zeros(shape=(400, 400))
for i in range(400):
template[i, i] = 1.0
#TODO Bin - load template. If multiple templates are needed, we can parallelize the template matching call.
#TODO Needs to undergo same processing as the continuous data. dimensions are (channel, time)
data_iter = stream.DataIterator(proc_steps=cfg.proc_steps, folder_name=cfg.data_path,
db_name=cfg.events_db_name)
for curr_chunk in data_iter:
if curr_chunk.check_validity():
cc_res = proc.template_matching(curr_chunk.data, template, 0.0)
print(cc_res)
if cc_res:
with open('results.txt', 'a') as f:
f.write(curr_chunk.filename + '\t')
f.write(str(cc_res[0]))
f.write('\t')
f.write(str(cc_res[1]))
f.write('\t')
f.write(str(cc_res[2]))
f.write('\t')
f.write('\n')
return 0
def test_forge():
data_iter = stream.DataIterator(proc_steps=cfg.proc_steps, folder_name=cfg.data_path,
db_name=cfg.events_db_name, output_overlap=cfg.overlap_samples)
plt.figure(figsize=(17, 14))
for curr_chunk in data_iter:
if curr_chunk.check_validity():
plt.imshow(curr_chunk.data, aspect='auto', cmap='seismic')
plt.title(curr_chunk.filename)
plt.show()
def test_cc():
data = np.zeros(shape=(4926, 2400))
for i in range(1800, 2200):
data[i, i-1000] = 1.0
template = np.zeros(shape=(400, 400))
for i in range(400):
template[i, i] = 1.0
data = data + np.random.normal(loc=0.0, scale=0.5, size=data.shape)
data = proc.normalization(data, 'std')
cc_res = proc.template_matching(data, template, 0.1)
print(cc_res)
if __name__ == '__main__':
main()