[SciPy-User] Filter problem

Warren Weckesser warren.weckesser@enthought....
Sat Jan 30 13:55:30 CST 2010

Balachandar wrote:
> Hello, I am a newbie in Scipy and also to filtering. I have a data 
> from a pressure sensor. It needs to be filtered. The graph can be seen 
> from the attachment. The top one is unfiltere and the bottom one is 
> filtered. As you can see the shape looks the same. I need a good 
> smooth line. My code goes like this..
> b,a = butter(10, 0.2, 'low')
>     ICPfiltered = lfilter(b,a,ICPunfiltered)
> where ICPfiltered is the filtered value and ICP unfiltered is the data 
> from the sensor. Its a 1-dimensional array. Am i doing anything wrong 
> with the usage of the api's. I have tried to change the cut
> -off frequency also but it isn't  of any use. Should i use any other 
> filter other than butterworth iir to get a smooth curve. Thank you....


The second argument to butter() is the (roughly) the cutoff frequency Wn,
expressed as a fraction of the Nyquist rate, which is half the sampling
rate of the original signal. Wn=0.2 implies that the cutoff frequency of
the lowpass filter is 0.1 times the sampling rate of the signal.  If most
of the noise that you want to remove is below this frequency, you won't
see much difference in the filtered signal.

The attached script provides a demonstration of how altering Wn affects
the result of filtering with butter().  It creates a test signal as the
sum of several sinusoidal functions, and then applies a Butterworth filter
for several values of Wn.  The attached plot shows the result.

Whether you should use butter() or some other filtering algorithm depends
on your objectives.  "A good smooth line" does not give a well-defined
set of criteria for choosing an appropriate filter. :)


> Thanks,
> Bala
> ------------------------------------------------------------------------
> ------------------------------------------------------------------------
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: filter_demo.py
Url: http://mail.scipy.org/pipermail/scipy-user/attachments/20100130/b3c8ded1/attachment-0001.pl 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filter_demo.png
Type: image/png
Size: 69967 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/scipy-user/attachments/20100130/b3c8ded1/attachment-0001.png 

More information about the SciPy-User mailing list