savitzky golay filtering
Hi I wanted to do a Savitzky Golay filtering on my data and came aross this piece of code: http://www.dalkescientific.com/writings/NBN/data/savitzky_golay.py Well, translating the necessary bits into current numpy/scipy code is driving me crazy. Can somebody give me a hint on the "M = ..."-line, please? (Or is there a better way to do this filtering with scipy?) TIA Christian
Hi, Meesters, Christian wrote:
Hi
I wanted to do a Savitzky Golay filtering on my data and came aross this piece of code: http://www.dalkescientific.com/writings/NBN/data/savitzky_golay.py Well, translating the necessary bits into current numpy/scipy code is driving me crazy. Can somebody give me a hint on the "M = ..."-line, please?
import numpy as N .. .. M = N.dot(N.linalg.inv(N.dot(B.transpose(),B)),B.transpose())
(Or is there a better way to do this filtering with scipy?)
I don't know. Christian
Christian Kristukat wrote:
Hi,
Meesters, Christian wrote:
Hi
I wanted to do a Savitzky Golay filtering on my data and came aross this piece of code: http://www.dalkescientific.com/writings/NBN/data/savitzky_golay.py Well, translating the necessary bits into current numpy/scipy code is driving me crazy. Can somebody give me a hint on the "M = ..."-line, please?
You can always import from numpy.oldnumeric and numpy.oldnumeric.linear_algebra Or, import numpy as N B = N.mat(B) M = (B.T*B).I * B.T return M.A # if you want an array returned. But, probably what you really want is to replace the whole line with M = N.linalg.pinv(B) -Travis
Thanks Travis & Christian! The filter not only looks like expected, the filtering also works like a charm on my data - without loosing resolution. Looks like taken from a textbook, absolutely great! Cheers Christian
participants (4)
-
Christian Kristukat -
Christian Meesters -
Meesters, Christian -
Travis Oliphant