I have an I/Q signal with $f_c=2.06\text{MHz}$ and $f_s=50\text{KHz}$. I am looking the first 256 samples of the signal, which is a NumPY array of complex numbers. If I do a spectrogram of this signal I get this picture:


Sample spectrogram

Notice that the Y-axis range of the spectrogram is $-25000$ to $+25000$.

If I do an FFT of the 256-sample signal, I will get 256 numbers, like this:


enter image description here

Notice that the $y$-axis range is now $-250$ to $250$. I want to be able to tightly bandpass this signal at any level in this range. I write the following naive bandpass function. In writing it I discover that I have to do a little tweaking to get a continuous response:

def bandpass(M,lo,hi):
    lo = (lo+N//2) % N
    hi = (hi+N//2) % N
    return M-F

The tweaking I had to do is in these lines:

    lo = (lo+N//2) % N
    hi = (hi+N//2) % N

As a result of this tweaking, I get the linear response I am looking for, which is I want to be able to knock out any bin in the frequency range linearly index from 0 to 255:


bandpass 50


specgram(fft.ifft(bandpass(fft.fft(sig),180,182)),Fs=fs); enter image description here

Why do I have to do the modulo tweak to get the linear response I was looking for?


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.