I am capturing samples with an RTL-SDR:
import numpy as np from rtlsdr import RtlSdr sdr = RtlSdr() F_station = int(88.7e6) Fc = F_station - F_offset Fs = 2.4e6 N = Fs sdr.sample_rate = Fs sdr.center_freq = Fc sdr.gain = 'auto' samples = sdr.read_samples(N) x1 = np.array(samples).astype("complex64")
I would like to walk through this spectrum 5kHz at a time. I am attempting to "tune" to each frequency:
width = 5000 targetFreq = Fc - Fs/2 + width/2 while targetFreq < Fc + Fs/2: Foffset = targetFreq + Fc fc1 = np.exp(-1.0j*2.0*np.pi* Foffset/Fs*np.arange(len(x1))) # center on target freq x2 = x1 * fc1
Then I decimate to reduce the bandwidth to the width I want to process, stepping over the whole bandwidth in 'width' increments. My decimate function uses scipy.signal's decimate function, often several times (to get down to the right width):
x3 = decimate(x2, width, Fs)
I process the x3s and put them together. The output has some sanity to it, but is not correct. Is the method I'm using to step through the larger bandwidth (multiply by a complex exponential with phase -F_offset/Fs and decimate to "narrow the bandwidth") the wrong approach?