hamnet70/impl/utils/plot_constellation.py

28 lines
805 B
Python
Executable File

#!/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')
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')
pp.show()