I'm trying to replicate what gnuradio is doing in "pure" python with a hackrf. Having mixed result, I decided to use the same data to compare the outputs I obtain. My gnuradio workflow is the following: It aims to create two files: one i'll plot directly with matplotlib and python (the "out" file sink), and one that has the format of the hackrf_transfer output (the "out.iq" file sink) that i'll
- modify to do the multiplication and complex conjugate thing that was done in gnuradio;
- plot using matplotlib and python.
To plot the first file, I use:
#!/bin/env python3 import scipy import matplotlib as mp import matplotlib.pyplot as plt import numpy as np f = scipy.fromfile(open("out"), dtype=scipy.float32) window_len = 5 w=np.ones(window_len, 'd') y=np.convolve(w/w.sum(), f, mode='valid') plt.plot(y) plt.show()
To plot the second file, I use:
#!/bin/env python3 import scipy import numpy as np import matplotlib as mp import matplotlib.pyplot as plt raw_data = scipy.fromfile(open("out.iq"), dtype=scipy.uint8) raw_data = (raw_data.astype(np.float32)/255) q = raw_data[::2] i = raw_data[1::2] N = len(i) i = 2*(i-0.5) q = 2*(q-0.5) signal = np.zeros(N) signal = i + 1j*q energy = signal * np.conj(signal) window_len = 5 w=np.ones(window_len, 'd') y=np.convolve(w/w.sum(), energy, mode='valid') plt.plot(2-y) plt.show()