comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Problems on the Savitzky-Golay smoothing filter
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Problems on the Savitzky-Golay smoothing filter [message #66488 is a reply to message #66483] Wed, 20 May 2009 05:03 Go to previous messageGo to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
mengran wrote:
> Hi,everybody,
> I have got a annoying problem about the implementing the
> Savitzky-Golay filter to smooth the time series RS data in the IDL.
> Actually, I know the function of the Savitzky-Golay filter in IDL is
> SAVGOL.But the question is the result I got is either a horizon line
> or the same as the original line(In other words, the filter seems not
> to work at all), when I changed the parameters of the SAVGOL function.
> (when the DEGREE = NL + NR(PARA OF THE SAVGOL FUNCTION), THE RESULT
> IS THE SAME AS THE ORIGINAL, OTHERWISE, THE RUSULT IS A HORISON LINE)
> My pro is as follows. The class1 to class9 from txt files are
> the samples of the time series RS data.
> Is there sth wrong with my code ? Or the RS data that I used
> is not appropriate for the Savitzky-Golay filter, and I take a wrong
> method to smooth data ? I need your suggestions, thanks a lot !

> savgolFilter = SAVGOL(2, 2, 0,4)

Hi Mengran,


so, print, savgolFilter --> 0.000000-8.04663e-007
1.00000-8.04663e-007 0.000000

meaning that the outer points have no effect, the central point has a
weight of 1 and the 2 middle points have a weight fairly close to
zero... so, from this, we can already suspect the smooth curve to be
similar to the original one.

Now, in convol, it is said that the kernel is "converted to the proper
type", in function of your input. So, if you are plotting integers, the
kernel is first converted to long... so the weights become 0,0,1,0,0
... and convol returns the same values as in the input!

Moreover, when you play with the degree, you get the following filters:
IDL> print, SAVGOL(2, 2, 0,3)
-0.0857143 0.342857 0.485714 0.342857 -0.0857143
IDL> print, SAVGOL(2, 2, 0,2)
-0.0857143 0.342857 0.485714 0.342857 -0.0857143

..once rounded, they are all zero... giving a nice horizontal line at zero!

Therefore, I would bet it is a problem with the input type... try to
convert it to float or double before applying the filter

Jean
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: NetCDF4 problem
Next Topic: Can i use CONTOUR to retrieve the subscripts within a closed contour?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 02:33:01 PDT 2025

Total time taken to generate the page: 2.72014 seconds