[SciPy-User] [SciPy-user] sinc interpolation

bdb112 boyd.blackwell at anu.edu.au
Thu Jun 7 05:05:18 EDT 2012


Corrected typo and improved code:

typo:  should be     yy = resample(y,100)

Improved code:
from scipy.signal import resample
from numpy import linspace, sin, pi
from pylab import plot, show

# replace 4*pi to see effect of non-periodic function (e.g. at either end) 
x = linspace(0,4*pi,10,endpoint=False)
y = sin(x)
# if you supply t, you get the interpolated t back as well.
(yy,xx) = resample(y, 100, t = x)

plot(x,y,'ro', xx, yy)
show()




Travis Oliphant-5 wrote:
> 
> 
> 
> On Nov 20, 2009, at 2:26 PM, David Trem wrote:
> 
>> Hello,
>>
>> Is sinc interpolation available in Scipy ?
> 
> Yes, use scipy.signal.resample  which uses a Fourier method to  
> downsample or upsample a signal:
> 
> from scipy.signal import resample
> from numpy import r_, sin
> from pylab import plot
> 
> x = r_[0:10]
> y = sin(x)
> yy = resample(x, 100)
> 
> # This is a bit tricky to get the x-samples right
> xx = r_[0:10:101j][:-1]
> 
> plot(x,y,'ro', xx, yy)
> 
> 
> -Travis
> 
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
> 
> 

-- 
View this message in context: http://old.nabble.com/sinc-interpolation-tp26449760p33974580.html
Sent from the Scipy-User mailing list archive at Nabble.com.




More information about the SciPy-User mailing list