2
$\begingroup$

I want to know what is the right way to downsample a sampled signal using Fourier transform as the implementation in scipy.signal.resample confuses me.

Reading through the code it first converts the signal to frequency domain, then discards the middle half of the frequencies (i.e. second and third quarters), then inverse-transform back to time domain. Therefore it is trying to keep the lowest and highest frequencies of the signal.

Due to Nyquist-Shannon we know that we cannot reconstruct a frequency of $f$ without at least $2f+1$ samples of the signal. Then when downsampling, shouldn't we instead discard the second half of the frequencies?

I already read some related answers but no one seems to address this specific question:

Scipy resample, "fourier method" explanation

Python's $\tt resample$ vs $\tt resample\_poly$ vs $\tt decimate$

$\endgroup$
1
$\begingroup$

Note that the result of a DFT is inherently periodic, so the second half of the resulting output vector does not correspond to the highest frequencies, but to the negative frequencies. The highest frequency (Nyquist) is in the middle of the vector, after that you get the most negative frequency and the last element is the smallest negative frequency just below DC. That's why when taking out the middle part of the vector you actually remove the highest frequencies.

| improve this answer | |
$\endgroup$
  • $\begingroup$ I should have read the code more carefully! $\endgroup$ – Michael Dec 14 '19 at 21:37
1
$\begingroup$

Given strictly real data as input, the "upper half" of an FFT is simply a redundant mirrored complex conjugate of the lower half.

And in order for an IFFT to produce a strictly real result, you have to maintain this symmetry or you will probably end up with lots of complex numbers in your downsampled result, which is likely not what you want. So you can't discard the entire upper half when downsampling, or you will end up with complex garbage.

The highest, non-mirrored frequencies are represented in the middle of an FFT result. Since this spectra needs to be discarded to bandlimit the spectrum to below Fs/4 before decimating, you cut out FFT bins from Fs/4 to Fs/4, AND also cut out the mirrored complex conjugates of them in the "upper half" to maintain strict mirrored symmetry, since you want a strictly real result after the IFFT.

| improve this answer | |
$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.