[SciPy-User] Usage of scipy.signal.resample

Ivo Maljevic ivo.maljevic at gmail.com
Wed Aug 26 10:11:29 EDT 2009


Unless you have a periodic function, I wouldn't rely much on the resample
function. It uses FFT approach, and the basic assumption is that x is
periodic. Without even trying to go into details, my first guess is that
what you see is the consequence
of aliasing.

A function that uses polyphase filter would do a better job, but it hasn't
been written yet :(
Until that is done, maybe you want to experiment by appending zeros to x,
resampling, and then discarding the last half:

>>> x=linspace(0,9,10)
>>> xx=r_[x, zeros(10)]
>>> yy=resample(xx,10)
>>> yy
array([ 0.16423509,  1.89281122,  4.1904564 ,  5.66068461,  8.68487231,
        2.33576491, -0.6288792 ,  0.3095436 , -0.16068461,  0.05119566])


>>> y=yy[0:5]
>>> y
array([ 0.16423509,  1.89281122,  4.1904564 ,  5.66068461,  8.68487231])

This is by no means a perfect solution, but I'm just throwing some ideas,
and you can try and see if that is good enough for you.

Ivo

2009/8/26 <markus.proeller at ifm.com>

>
> Hello,
>
> I have a question concerning the resample function of scipy.
> I have the following code:
>
> from scipy.signal import resample
> >>>x = array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
> >>>resample(x,5)
> array([ 2.5       ,  1.26393202,  4.5       ,  5.5       ,  8.73606798])
>
> I don't understand the first value of 2.5.
> My scipy version is 0.7.0
>
> Thanks for help,
>
> Markus
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20090826/e611130e/attachment.html>


More information about the SciPy-User mailing list