[SciPy-Dev] SciPy roadmap does not address limitations of current filter-related code

Warren Weckesser warren.weckesser at gmail.com
Fri Aug 11 04:11:46 EDT 2017


On Sun, Aug 6, 2017 at 1:10 PM, Phillip Feldman <phillip.m.feldman at gmail.com
> wrote:

> Some of us in the engineering community are unhappy with the SciPy
> roadmap. From our perspective, the main deficiency of scipy.signal is that
> the filtering functionality is of limited practical utility. We would like
> to see the following:
>
> (1) support for lowpass, bandpass, and bandstop FIR filter design, with
> the user specifying (a) the passband ripple, (b) the minimum stopband
> rejection, and (c) the design method, with this last being optional. Rather
> than forcing the user to specify the order of the filter, which requires
> many iterations to determine the minimum filter order that will do the job,
> we'd like to see the code automatically determine the minimum filter order
> that can meet the user's specs.
>
> (2) support for fixed-binary-point arithmetic.
>
> (3) support for filtering and the design of filters that use
> fixed-binary-point arithmetic.
>
> Such changes would be a big step in the direction of making
> Python+NumPy+SciPy a viable alternative to Matlab + the Matlab Signal
> Processing Toolbox.
>
> As an aside, I'd like to comment on the documentation for
> `scipy.signal.kaiserord`, which says the following:
>
> scipy.signal.kaiserord(ripple, width)[source]
>
> <snip> ripple : float
>
> Positive number specifying maximum ripple in passband (dB) and minimum
> ripple in stopband.
>
> When designing a lowpass digital filter, one normally specifies the
> maximum ripple in the passband and the minimum rejection in the stopband.
> With this function, there is no way to specify how much rejection one gets
> in the stopband, and the filter design code is also apparently trying to
> limit stopband ripple, which is something that no engineer would care
> about. The documentation can't just be badly worded, because there would
> have to be another parameter to specify the stopband rejection.
>
>

Phillip,

It looks like the explanation of the 'ripple' argument of the function
'kaiserord' needs some work.  You may be familiar with the following, but
for anyone else following along, here's a summary of 'kaiserord'.

The function 'kaiserord' implements the empirical FIR filter design
formulas developed by Kaiser in the late 60's and early 70's.  The
reference that I have handy is Sections 7.5.3 and 7.6 of the text
"Discrete-Time Signal Processing" (3rd ed.) by Oppenheim and Schafer.

It is true that in this method, there is only one parameter that controls
the passband ripple *and* the stopband rejection.  Let delta be the
attenuation (not in dB) in the stop band.  In the Kaiser method, delta also
determines the ripple of the gain in the pass band: it varies between
1-delta and 1+delta. The stop band rejection in dB is A =
-20*log10(delta).  This value (in dB) is the first argument of 'kaiserord'.

Kaiser developed an expression for beta, the Kaiser window parameter, that
depends on A, and also a formula for the filter order M in terms of A and
w, where w is the transition width between the pass and stop bands.

The Kaiser window design method, then, is to determine the order M and
Kaiser window parameter beta using Kaiser's formula (implemented in
`scipy.signal.kaiserord`), and then design the filter using the window
method with a Kaiser window (using, for example, `scipy.signal.firwin`):

    numtaps, beta = kaiserord(A, w)
    taps = firwin(numtaps, cutoff, window=('kaiser', beta), [other args as
needed])

Adding a good example to the docstring of 'kaiserord()' is on the SciPy
to-do list (https://github.com/scipy/scipy/issues/7168).  In the meantime,
I have attached a self-contained script that demonstrates the Kaiser method
for a lowpass filter.  It generates the attached plot.

Best regards,

Warren



> Phillip
> --
> Dr. Phillip M. Feldman
>
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at python.org
> https://mail.python.org/mailman/listinfo/scipy-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20170811/c1068816/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kaiser_lowpass_filter_design.py
Type: text/x-python-script
Size: 2739 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20170811/c1068816/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kaiser_lowpass_filter.png
Type: image/png
Size: 120208 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20170811/c1068816/attachment-0001.png>


More information about the SciPy-Dev mailing list