Files
DSP/QAM/debug.py
2025-10-18 19:34:07 +02:00

33 lines
1.1 KiB
Python

import numpy as np
import matplotlib.pyplot as plt
def plot_constellations(ref_file, rx_file, title="Constellation comparison"):
# Charger et forcer 2D
ref_data = np.atleast_2d(np.loadtxt(ref_file))
rx_data = np.atleast_2d(np.loadtxt(rx_file))
x_ref, y_ref = ref_data[:,0], ref_data[:,1]
x_rx, y_rx = rx_data[:,0], rx_data[:,1]
plt.figure(figsize=(6,6))
plt.scatter(x_ref, y_ref, color='blue', s=50, marker='o', label='Référence')
plt.scatter(x_rx, y_rx, color='red', s=50, marker='x', label='Reçu')
# Ajustement automatique des limites
all_x = np.concatenate([x_ref, x_rx])
all_y = np.concatenate([y_ref, y_rx])
margin = 0.1 * max(np.ptp(all_x), np.ptp(all_y))
plt.xlim(min(all_x)-margin, max(all_x)+margin)
plt.ylim(min(all_y)-margin, max(all_y)+margin)
plt.xlabel('In-phase (I)')
plt.ylabel('Quadrature (Q)')
plt.title(title)
plt.grid(False)
plt.gca().set_aspect('equal', adjustable='box')
plt.legend()
plt.show()
plot_constellations("constellation_ref.dat", "constellation.dat", title="Constellation QAM")