hamnet70/impl/utils/plot_constellation.py

28 lines
805 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_':
print(f"Error: not a complex signal file. Format {header} not implemented yet.")
exit(1)
T = np.fromfile(infile, dtype=np.float32, count=1)
data = np.fromfile(infile, dtype=np.complex64)
pp.plot(np.real(data), np.imag(data), 'x')
2022-02-13 19:53:17 +01:00
a = np.linspace(-np.pi, np.pi, 200)
pp.plot(np.cos(a), np.sin(a), 'k--', linewidth=0.7)
pp.plot([1, 1, -1, -1, 1], [1, -1, -1, 1, 1], 'k--', linewidth=0.7)
pp.plot([-1.5, 1.5], [0, 0], 'k--', linewidth=0.7)
pp.plot([0, 0], [-1.5, 1.5], 'k--', linewidth=0.7)
pp.xlim([-1.5, 1.5])
pp.ylim([-1.5, 1.5])
pp.axis('equal')
2021-10-17 19:46:30 +02:00
pp.show()