[SciPy-user] cubic splines in scipy
icy.flame.gm at gmail.com
Sun Jan 29 10:52:04 CST 2006
This is what I do with my data, might not be the best way to do
things, but it worked with the old SciPy, seems to work on the new one
too, but not fully tested.
from scipy import std
from scipy.interpolate import UnivariateSpline
from Numeric import ones
# ary =  1D array
length = len(ary)
weight = ones(length)
# In case you want to do smoothing, then
# you can supply the std of the noise.
# In this example I take the first 200
# data point to calculate the noise level.
# Which is pure noise in my measurement
# weight = ones(length) / std(ary[:200])
b = UnivariateSpline(range(length), ary, w = weight)
# Now b is a function, anypoint on the
# function can be call using:
InterpolatedValue = b.__call__(j)
The body maybe wounded, but it is the mind that hurts.
More information about the SciPy-user