[SciPy-User] firwin behavior

Warren Weckesser warren.weckesser@enthought....
Wed Aug 10 09:39:11 CDT 2011


On Wed, Aug 10, 2011 at 8:14 AM, Jeff Alstott <jeffalstott@gmail.com> wrote:
> firwin is producing unreasonable filters for me, and I'm not sure if I'm
> misusing the code or if there is a bug. Like so:
>
> In [5]: from scipy.signal import firwin
>
> In [6]: ny = 500
>
> In [7]: f21f80= firwin(21, [1/ny, 80/ny]); plot(f21f80);
> savefig('FIR21_filter80.png')
>
> Produces the attached file.
>
> In contrast, Matlab:
>
> Trial>> ny = 500
>
> ny =
>
>    500
>
> Trial>> [f20f80] = fir1(20, [1/ny, 80/ny]); figure; plot(f20f80)
>
> Produces the other attached file. Quite different! The filter produced by
> the scipy function, if used with lfilter (or if taken to Matlab to use as a
> filter), produces a nonsense filtering, with many high frequency artifacts.
>
> Any thoughts? This is in python3, if that matters.


By default, firwin creates a filter that passes DC (i.e. the zero
frequency).  To get a filter like the one produced by matlab, add the
keyword argument pass_zero=False.

Warren


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


More information about the SciPy-User mailing list