1
$\begingroup$

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: enter image description here 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

  1. modify to do the multiplication and complex conjugate thing that was done in gnuradio;
  2. 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()

It seems to me I'm doing the same operations on the data in the two cases, yet I obtain really different data visualization: First case: enter image description here Second case: enter image description here Do you know where I messed up?

$\endgroup$
  • $\begingroup$ The second plot looks like a heavily quantized version of the first. $\endgroup$ – MBaz Apr 16 '18 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.