2023-05-17 22:27:40 +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_':
|
|
|
|
T = np.fromfile(infile, dtype=np.float32, count=1)
|
|
|
|
data = np.fromfile(infile, dtype=np.complex64)
|
|
|
|
else:
|
|
|
|
print(f"Error: Format {header} not implemented yet.")
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
t = np.arange(0, T*data.size, T)
|
|
|
|
|
|
|
|
amp = np.absolute(data)
|
2024-03-30 22:04:26 +01:00
|
|
|
phase = np.unwrap(np.angle(data))
|
2023-05-17 22:27:40 +02:00
|
|
|
|
|
|
|
pp.plot(t, amp, 'r-')
|
|
|
|
pp.legend(['Amplitude'])
|
|
|
|
pp.twinx()
|
|
|
|
pp.plot(t, phase, 'b-')
|
|
|
|
pp.legend(['Phase [radians]'])
|
|
|
|
pp.xlabel('Time [s]')
|
|
|
|
pp.show()
|