9
$\begingroup$

I am seeking explanation of what "Fourier method" is that is described for resampling in documentation of resample() method. I want to downsample an array. I know what decimation is and how it works, I also know what fourier transform is. I cannot however find "scientific backup" so to say to the resample method in scipy. I saw this topic:

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

I also searched across some books regarding digital signal processing. Am I missing something obvious? I looked in the implementation of resample and I know it performs fourier transform on signal and then takes half of samples needed from the beginning of transformed array and from the end. Then it inverses fourier transform coming back to time-domain. I cannot find scientific description of this method. In the link above, this was mentioned:

https://en.wikipedia.org/wiki/Trigonometric_interpolation#Relation_with_the_discrete_Fourier_transform

I don't understand how interpolation is connected with downsampling. Could anyone explain and/or link some resources? Scipy docs has this in method description:

Resample x to num samples using Fourier method along the given axis.

The resampled signal starts at the same value as `x` but is sampled
with a spacing of ``len(x) / num * (spacing of x)``.  Because a
Fourier method is used, the signal is assumed to be periodic.

Thanks in advance.

$\endgroup$

1 Answer 1

7
$\begingroup$

Suppose you have initially a real-valued sequence x of length N. The function is basically doing this:

  • To upsample, it transforms to the frequency domain and adds N/2 zeros at the end. Then it transforms back to the time-domain.
  • To downsample, it transforms to the frequency domain and deletes the second and third groups of N/4 elements (which correspond to the half with the highest frequency components). Then it transforms back.

You can try it on your own running step by step the source code for the resample() function.

The theory regarding these methods can be found in this answer.

$\endgroup$
1
  • $\begingroup$ Scipy is actually padding zeros in the middle and they treat the points that border on the zeros specially if the input has an even number of points. Here's an updated link to the old version of scipy with the code: github.com/scipy/scipy/blob/… $\endgroup$
    – Aaron Swan
    Commented Mar 22, 2023 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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