-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsof_tracking_plot.py
48 lines (43 loc) · 1.33 KB
/
sof_tracking_plot.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
#%%
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
import scipy.stats as st
import re
with open('data_captured.dat', 'rb') as f:
# hex = ""
# for byte in f.read():
# hex += "{0:02x}".format(byte)
#
# pattern = re.compile(r'((00)(..){3}){4}')
# result = pattern.search(hex)
#
# f.seek(result.span()[0]//2)
dw = f.read(4)
data = []
while dw:
data.append(int.from_bytes(dw[1:4], byteorder='big', signed=True))
dw = f.read(4)
#myarray = np.asarray(dw)
#mu, sigma = 0, 0.1
#count, bins, _ = plt.hist(myarray, normed=True)
#plt.plot(bins, 1./(np.sqrt(2*np.pi)*sigma)*np.exp(-(bins-mu)**2/(2*sigma**2)), lw=2, c='r')
#s_fit = np.linspace(min(data), max(data))
#plt.plot(s_fit, st.norm(mu, sigma).pdf(s_fit), lw=2, c='r')
plt.plot(data)
plt.show()
#pattern = '''
# ^ #begin of the string
# ('\x00') #first should be 00 or aa
# #('\x'..){3} #3 any other bytes
# $
# '''
#s = np.loadtxt('data_captured.dat')
# plot first 20 points of the resulting data (why not all 1000?)
#plt.plot(s[:20])
#plt.show()
#from scipy.signal import lfilter
#sout = lfilter(lpf, 1, s)
#plt.plot(20*np.log10(abs(np.fft.fft(s))))
#plt.plot(20*np.log10(abs(np.fft.fft(sout))))
#plt.show()