Tuesday, October 29, 2019

downsampling - Scipy resample, "fourier method" explanation


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.



Answer



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.


No comments:

Post a Comment

digital communications - Understanding the Matched Filter

I have a question about matched filtering. Does the matched filter maximise the SNR at the moment of decision only? As far as I understand, ...