-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplot_m.py
More file actions
40 lines (29 loc) · 884 Bytes
/
plot_m.py
File metadata and controls
40 lines (29 loc) · 884 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
import struct
import numpy as np
import pyqtgraph as pg
app = pg.mkQApp("DateAxisItem Example")
class FmtAxisItem(pg.AxisItem):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def tickStrings(self, values, scale, spacing):
strings = []
for v in values:
vs = v * scale
vs = int(vs)
vstr = ("0x%x") % vs
strings.append(vstr)
return strings
data = open('./trace.binary', 'rb').read()
traces = []
for i in range(160, len(data), 8):
num = struct.unpack('<Q', data[i:i+8])[0]
traces.append(num)
data = np.array(traces)
# data = np.fft.rfft(data)
w = pg.PlotWidget(axisItems={'left': FmtAxisItem(orientation='left')})
w.showGrid(x=True, y=True)
w.plot(data)
w.setWindowTitle('pyqtgraph example: DateAxisItem')
w.show()
if __name__ == '__main__':
pg.exec()