Skip to content

Instantly share code, notes, and snippets.

@axegon
Created November 1, 2024 22:26
Show Gist options
  • Save axegon/1fcbfc2ad38a4e14625755b2cdbe32a3 to your computer and use it in GitHub Desktop.
Save axegon/1fcbfc2ad38a4e14625755b2cdbe32a3 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
with open('samples.bin', 'rb') as f:
raw_data = np.fromfile(f, dtype=np.uint8)
iq_data = raw_data.astype(np.float32) - 127.5
iq_data /= 127.5
i_data = iq_data[0::2]
q_data = iq_data[1::2]
complex_data = i_data + 1j * q_data
plt.figure()
plt.magnitude_spectrum(complex_data, Fs=2.048e6, scale='dB')
plt.title('Magnitude Spectrum')
plt.show()
plt.figure()
plt.plot(i_data[:1000], label='I')
plt.plot(q_data[:1000], label='Q')
plt.title('Time-Domain Signal')
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment