Upload 5 files
Browse files- capture_11.csv +0 -0
- capture_11.txt +0 -0
- capture_12.txt +0 -0
- sensor_data_filter.py +80 -0
- sensor_data_filter_LIVE.py +80 -0
capture_11.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
capture_11.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
capture_12.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sensor_data_filter.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# txt to csv
|
| 2 |
+
# convert txt json data to csv for ml
|
| 3 |
+
import csv
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
found = []
|
| 7 |
+
lask = []
|
| 8 |
+
band = []
|
| 9 |
+
last_pair = None
|
| 10 |
+
|
| 11 |
+
def send_chunk(data):
|
| 12 |
+
global lask
|
| 13 |
+
global band
|
| 14 |
+
temp = []
|
| 15 |
+
# array structure [signal_int * count,received time float]
|
| 16 |
+
if 'OM-LASK' in data['id']:
|
| 17 |
+
for i in data['data']:
|
| 18 |
+
temp.append(i)
|
| 19 |
+
temp.append(data['rec_time'])
|
| 20 |
+
lask.append(temp)
|
| 21 |
+
elif 'OM-Band' in data['id']:
|
| 22 |
+
for i in data['data']:
|
| 23 |
+
temp.append(i)
|
| 24 |
+
temp.append(data['rec_time'])
|
| 25 |
+
band.append(temp)
|
| 26 |
+
|
| 27 |
+
def check_chunk():
|
| 28 |
+
global lask
|
| 29 |
+
global band
|
| 30 |
+
global last_pair
|
| 31 |
+
global found
|
| 32 |
+
dindexL =[]
|
| 33 |
+
dindexB =[]
|
| 34 |
+
if len(band) > 10:
|
| 35 |
+
for i,x in enumerate(band):
|
| 36 |
+
time = x[-1]
|
| 37 |
+
for o,z in enumerate(lask):
|
| 38 |
+
if abs(z[-1] - time) < .02:
|
| 39 |
+
found.append([x,z])
|
| 40 |
+
last_pair = z[-1]
|
| 41 |
+
del lask[o]
|
| 42 |
+
for i in dindexB:
|
| 43 |
+
del band[i]
|
| 44 |
+
if len(band) > 20:
|
| 45 |
+
band = band[-10:]
|
| 46 |
+
if len(lask) > 20:
|
| 47 |
+
lask = lask[-10:]
|
| 48 |
+
#if not len(found) % 1000:
|
| 49 |
+
#print('found ammount: ',len(found))
|
| 50 |
+
|
| 51 |
+
text_file = open('capture_11.txt','r')
|
| 52 |
+
csv_file = open('capture_11.csv','w',newline="") #added newline="" FYI FMI
|
| 53 |
+
writer = csv.writer(csv_file)
|
| 54 |
+
writer.writerow(['OM1','OM2','OM3','OM4','OM5','OM6','OM7','OM8','OM9','OM10','OM11','OM12','om_time','LASK1','LASK2','LASK3','LASK4','lask_time'])
|
| 55 |
+
|
| 56 |
+
matched_pairs = []
|
| 57 |
+
for i in text_file.read().split('\n'):
|
| 58 |
+
#print(i)
|
| 59 |
+
try:
|
| 60 |
+
j = eval(i)
|
| 61 |
+
except:
|
| 62 |
+
print(i,'failed to eval()')
|
| 63 |
+
send_chunk(j)
|
| 64 |
+
check_chunk()
|
| 65 |
+
|
| 66 |
+
print('finished matching')
|
| 67 |
+
|
| 68 |
+
for i in found:
|
| 69 |
+
writer.writerow(i[0] + i[1])
|
| 70 |
+
|
| 71 |
+
csv_file.close()
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
|
sensor_data_filter_LIVE.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# txt to csv
|
| 2 |
+
# convert txt json data to csv for ml
|
| 3 |
+
import csv
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
found = []
|
| 7 |
+
lask = []
|
| 8 |
+
band = []
|
| 9 |
+
last_pair = None
|
| 10 |
+
|
| 11 |
+
def send_chunk(data):
|
| 12 |
+
global lask
|
| 13 |
+
global band
|
| 14 |
+
temp = []
|
| 15 |
+
# array structure [signal_int * count,received time float]
|
| 16 |
+
if 'OM-LASK' in data['id']:
|
| 17 |
+
for i in data['data']:
|
| 18 |
+
temp.append(i)
|
| 19 |
+
temp.append(data['rec_time'])
|
| 20 |
+
lask.append(temp)
|
| 21 |
+
elif 'OM-Band' in data['id']:
|
| 22 |
+
for i in data['data']:
|
| 23 |
+
temp.append(i)
|
| 24 |
+
temp.append(data['rec_time'])
|
| 25 |
+
band.append(temp)
|
| 26 |
+
|
| 27 |
+
def check_chunk():
|
| 28 |
+
global lask
|
| 29 |
+
global band
|
| 30 |
+
global last_pair
|
| 31 |
+
global found
|
| 32 |
+
dindexL =[]
|
| 33 |
+
dindexB =[]
|
| 34 |
+
if len(band) > 10:
|
| 35 |
+
for i,x in enumerate(band):
|
| 36 |
+
time = x[-1]
|
| 37 |
+
for o,z in enumerate(lask):
|
| 38 |
+
if abs(z[-1] - time) < .02:
|
| 39 |
+
found.append([x,z])
|
| 40 |
+
last_pair = z[-1]
|
| 41 |
+
del lask[o]
|
| 42 |
+
for i in dindexB:
|
| 43 |
+
del band[i]
|
| 44 |
+
if len(band) > 20:
|
| 45 |
+
band = band[-10:]
|
| 46 |
+
if len(lask) > 20:
|
| 47 |
+
lask = lask[-10:]
|
| 48 |
+
#if not len(found) % 1000:
|
| 49 |
+
#print('found ammount: ',len(found))
|
| 50 |
+
|
| 51 |
+
text_file = open('live_capture.txt','r')
|
| 52 |
+
csv_file = open('live_capture.csv','w',newline="") #added newline="" FYI FMI
|
| 53 |
+
writer = csv.writer(csv_file)
|
| 54 |
+
writer.writerow(['OM1','OM2','OM3','OM4','OM5','OM6','OM7','OM8','OM9','OM10','OM11','OM12','om_time','LASK1','LASK2','LASK3','LASK4','lask_time'])
|
| 55 |
+
|
| 56 |
+
matched_pairs = []
|
| 57 |
+
for i in text_file.read().split('\n'):
|
| 58 |
+
#print(i)
|
| 59 |
+
try:
|
| 60 |
+
j = eval(i)
|
| 61 |
+
except:
|
| 62 |
+
print(i,'failed to eval()')
|
| 63 |
+
send_chunk(j)
|
| 64 |
+
check_chunk()
|
| 65 |
+
|
| 66 |
+
print('finished matching')
|
| 67 |
+
|
| 68 |
+
for i in found:
|
| 69 |
+
writer.writerow(i[0] + i[1])
|
| 70 |
+
|
| 71 |
+
csv_file.close()
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
|