scipy - How do I limit the interpolation region in the InterpolatedUnivariateSpline in Python when given non-uniform samples? -


i'm trying nice upsampler using python when have non-uniform spaced inputs. suggestions helpful. i've tried number of interp functions. here's example:

from scipy.interpolate import interpolatedunivariatespline numpy import linspace, arange, append matplotlib.pyplot import plot f=[0, 1000,1500,2000,2500,3000,3500,4000,4500,5000,5500,22050] m=[0.,2.85,2.49,1.65,1.55,1.81,1.35,1.00,1.13,1.58,1.21,0.] ff=linspace(f[0],f[1],10) in arange(2, len(f)):     ff=append(ff,linspace(f[i-1],f[i], 10)) aa=interpolatedunivariatespline(x=f,y=m,k=2); mm=aa(ff) plot(f,m,'r-o'); plot(ff,mm,'bo'); show() 

this plot get:

enter image description here

i need interpolated values don't go below 0. note blue dots go below zero. red line represents original f vs. m data. if use k=1 (piece-wise linear interp) values shown here:

aa=interpolatedunivariatespline(x=f,y=m,k=1) mm=aa(ff); plot(f,m,'r-o');plot(ff,mm,'bo'); show() 

enter image description here

the problem need have "smooth" interpolation , not piece-wise value. know if bbox argument in interpolatedunivarientspline helps fix that? cant find documentation on bbox does. there easier way accomplish this?

thanks in advance help.


Comments

Popular posts from this blog

wordpress - .htaccess: RewriteRule: bad flag delimiters -

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -