0

This question is in extension to the previous post - How to uniformly resample a non-uniform signal using SciPy?

I am facing the same problem, when using scipy.signal.resample for a large data set. The uniformly sampled signal is shifted and not identical to the original as normally expected. In contrast, scipy.signal.resample works very well for small datasets. Most of the solution on the web, is on using scipy.interpolate to avoid this issue. Yeah, scipy.interpolate works as expected also for large dataset.

I am confused on why scipy.signal.resampling didnt work well for large dataset. As far as I know, scipy.singal.resampling using Fourier transform and then interpolates, but is the common solution to use only scipy.interpolate to avoid this issue right ?

  • what do you mean by "scipy.signal.resampling didnt work well for large dataset"? wrong values, bad performance? – dankal444 Apr 26 '23 at 11:44
  • I got the result just the same as in the attached post link. The expected result is that the sampled signal to be as much as similar to the original input signal, but it was not. the shape was a little bit similar, it was shifted and distorted. When I run the same scipy.signal.resample with a smaller dataset, the sampled and original input signal matches each other mostly. – python_noobie Apr 26 '23 at 12:56

1 Answers1

0

As explained in the post linked to your question and in the documentation, scipy.signal.resample expects equally spaced sample positions, so make sure your input signal meets this requirement. Otherwise, make use of interpolation methods.

Regarding the performance issue on large datasets, this is related to Fourier transformation and also clearly stated in the scipy.signal.resample documentation :

As noted, resample uses FFT transformations, which can be very slow if the number of input or output samples is large and prime; see scipy.fft.fft.

Beinje
  • 572
  • 3
  • 18
  • Thank you for the response. But the issue with the large dataset is not the speed. My large dataset contains non-uniformly sampled data. The output sampled waveform itself is distorted and shifted when compared to the original signal, which is expected as scipy.signal.sample requires an equally spaced sample position. In contrast, when I run the same program with scipy.signal.resample for a small dataset, it produces more or less expected results, where both the sample signal and original signal match each other, and so, I was confused – python_noobie Apr 26 '23 at 13:08
  • @python_noobie so, by some luck scipy.signal.resamply produced good result on "small datasert" and you are confused? Its like being surprised that 2*2=4 and 2+2=4 give same result. – dankal444 Apr 26 '23 at 14:02