JuliaDSP / DSP.jl

Filter design, periodograms, window functions, and other digital signal processing functionality
https://docs.juliadsp.org/dev/
Other
373 stars 106 forks source link

API for automatic filter order selection #69

Open simonster opened 9 years ago

simonster commented 9 years ago

At present we design filters as:

digitalfilter(Lowpass(freq), Butterworth(order))
digitalfilter(Bandpass(freq1, freq2), Butterworth(order))

or equivalent, i.e., we specify filters in terms of the cutoff frequency, order, and optional filter parameters (for Chebyshev and Elliptic filters). It would be nice if we could also specify filters in terms of the cutoff frequency, stopband frequency, passband ripple, and stopband attenuation. We could have something like:

digitalfilter(Lowpass(0.2; Rp=1, Ws=0.5, Rs=90), Butterworth())
digitalfilter(Highpass(0.5; Rp=1, Ws=0.2, Rs=90), Butterworth())

Then for bandpass filters we'd pass Ws and (optionally) Rs as tuples:

digitalfilter(Bandpass(0.2, 0.3; Rp=1,
                       Ws=(0.1, 0.5), Rs=(60, 90)),
              Butterworth())

And for bandstop filters, we'd specify the passband frequencies Wp instead of Ws:

digitalfilter(Bandstop(0.2, 0.3; Rp=(.5, 1),
                       Wp=(0.1, 0.4), Rs=90),
              Butterworth())

This seems a bit complex, but I haven't thought of anything better yet.

jfsantos commented 9 years ago

I think this looks good. Scipy has buttord, ellipord, cheb1ord, cheb2ord, and ellipord implementations that we could use as a reference. Should we pass Butterworth as a type instead of an instance of a type in this case? We could also just check for a defined order in digitalfilter and use the corresponding function in case the instance of the filter prototype has no order defined.

rob-luke commented 9 years ago

Has any progress been made on filter order estimation? If not, I will have some time in a few weeks to make a start.

jfsantos commented 9 years ago

As far as I know nobody is working on this, so feel free to propose something :)