Skip to content

Instantly share code, notes, and snippets.

@dmgolembiowski
Forked from axegon/read_samples.py
Created July 2, 2025 23:16
Show Gist options
  • Select an option

  • Save dmgolembiowski/d007fa7a674110a353fdb2b2cf035b40 to your computer and use it in GitHub Desktop.

Select an option

Save dmgolembiowski/d007fa7a674110a353fdb2b2cf035b40 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