hamnet70/impl/utils/plot_timedomain.py

27 lines
722 B
Python
Raw Permalink Normal View History

2021-10-17 19:46:30 +02:00
#!/usr/bin/env python3
import sys
import numpy as np
import matplotlib.pyplot as pp
with open(sys.argv[1], 'rb') as infile:
header = infile.read(4)
if header == b'CPX_':
2024-04-20 01:09:03 +02:00
T = np.fromfile(infile, dtype=np.float32, count=1)[0]
data = np.fromfile(infile, dtype=np.complex64)
elif header == b'FLT_':
2024-04-20 01:09:03 +02:00
T = np.fromfile(infile, dtype=np.float32, count=1)[0]
data = np.fromfile(infile, dtype=np.float32)
else:
print(f"Error: Format {header} not implemented yet.")
2021-10-17 19:46:30 +02:00
exit(1)
t = np.arange(0, T*data.size, T)
pp.plot(t, np.real(data), 'r-')
pp.plot(t, np.imag(data), 'b-')
pp.legend(['In-phase', 'Quadrature'])
pp.xlabel('Time [s]')
pp.show()