[SciPy-User] Signal processing 101: creating and applying a bandpass filter

Christopher Felton chris.felton at gmail.com
Thu Dec 8 09:58:08 EST 2011


On 12/7/2011 6:44 PM, Rob Newman wrote:
> Dear SciPy gurus,
>
> I have a list of values that I wish to apply a bandpass filter to. Looking at the docs (http://docs.scipy.org/doc/scipy/reference/signal.html), I can see how to design a filter (http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.butter.html), but I don't see any examples of using your custom designed filter in practice with lists or arrays. Are there any online resources that show step-by-step how to build a filter and apply to a list of values?
>
> For example, here is a Python list:
>
> [1.2711705420245039e-05,
>   -2.7804792241996774e-05,
>   3.6106973477276575e-05,
>   -1.3862942711545279e-05,
>   -4.5308686748537353e-06,
>   3.9977066695205231e-06,
>   -1.4130285261627493e-06,
>   -3.992578793440835e-07,
> <snip>
>   8.7310453451921392e-07,
>   -1.2458364494266352e-06,
>   1.972281982220939e-06,
>   -2.5749765923225825e-06,
>   3.4605357526068371e-06,
>   -7.4952550588555781e-06]
>
> It is 512 in length.
>
> I want to apply a Butterworth-style filter to this data, using a similar format of the string below (or translated to how the SciPy bandpass filtering works):
>
> 0.02_5_0.10_5
>
> where a 0.02Hz to 0.10Hz bandpass filter is applied, with the 5's representing the poles of the filters.
>
> I hope this makes sense. Please let me know if I need to clarify in any way.
>
> Thanks in advance,
> - Rob


You can use lfilter, there is an example on the cookbook page, 
http://www.scipy.org/Cookbook/FIRFilter.

This cookbook page has a good review of the additional methods that can 
be used and which are faster in particular cases, 
http://www.scipy.org/Cookbook/ApplyFIRFilter

Regards,
Chris





More information about the SciPy-User mailing list