[SciPy-user] data smoothing: interpolate.splrep ignores s parameter
george young
gry at ll.mit.edu
Wed Feb 25 14:01:50 CST 2004
[SciPy-0.2.0_alpha_200.4161, Numeric-23.1, Python 2.3.3, x86 Linux]
My goal really is to smooth some noisy measurement data without messing
up it's *shape*. My first attempt was 1d splines. I did:
from Numeric import *
import scipy
f = file('rough')
data = array([(float(x),float(y)) for (x,y) in [l.split() for l in f]])
rep = scipy.interpolate.splrep(data[:,0], data[:,1], s=s)
smooth_y = scipy.interpolate.splev(data[:,0], rep)
"s" is supposed to vary the amount of smoothing. For s=0, i get
my original data back, as expected. But for all other values, including
the recommended range of (m-sqrt(2.0*m)) to (m+sqrt(2.0*m), I get a
single, too much smoothed, result. It seems like splrep is not using
the "s" value to adjust the splines, except to sense that it's not zero.
Splines may not be the right method anyway, since they tend to warp the
shape of the curve, and I need to get the data's derivatives. Is there
some way to fashion a low pass filter? It seems like fft should be useful
here, but I have very little experience with fft's.
-- George Young
--
"Are the gods not just?" "Oh no, child.
What would become of us if they were?" (CSL)
More information about the SciPy-user
mailing list