Skip to content

Commit

Permalink
Butterworth, Elliptic, and Chebyshev I/II Filter Order Estimation (#453)
Browse files Browse the repository at this point in the history
* Adding filter order routines.

* Adding test cases for `cheb1ord` and `ellipord`

* Adding `cheb2ord` test cases.

* Adding `cheb2ord` docstrings

* Adding order estimation routines to the docs.

* Adding argument error and `brent` test cases.
  • Loading branch information
jsmithnh09 committed Jul 1, 2022
1 parent a717bcc commit 4f6390b
Show file tree
Hide file tree
Showing 5 changed files with 704 additions and 2 deletions.
21 changes: 20 additions & 1 deletion docs/src/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ or [`Bandstop`](@ref) and includes the edges of the bands.
The design method is [`Butterworth`](@ref), [`Chebyshev1`](@ref), [`Chebyshev2`](@ref),
[`Elliptic`](@ref), or [`FIRWindow`](@ref), and includes any
necessary parameters for the method that affect the shape of the response,
such as filter order, ripple, and attenuation.
such as filter order, ripple, and attenuation. [Filter order estimation methods](@ref order-est-methods)
are available in [`buttord`](@ref), [`cheb1ord`](@ref), [`cheb2ord`](@ref),
and [`ellipord`](@ref) if the corner frequencies for different IIR filter types are known.

```@docs
analogfilter
Expand Down Expand Up @@ -119,6 +121,15 @@ Chebyshev2
Elliptic
```

### [IIR filter order estimation methods](@id order-est-methods)

```@docs
buttord
cheb1ord
cheb2ord
ellipord
```

#### FIR filter design methods

```@docs
Expand Down Expand Up @@ -180,3 +191,11 @@ responsetype = Lowpass(5; fs=50)
designmethod = FIRWindow(hanning(64))
filt(digitalfilter(responsetype, designmethod), x)
```

Estimate a Lowpass Elliptic filter order with a normalized
passband cutoff frequency of 0.2, a stopband cutoff frequency of 0.4,
3 dB of passband ripple, and 40 dB attenuation in the stopband:

```julia
(N, ωn) = ellipord(0.2, 0.4, 3, 40)
```
8 changes: 8 additions & 0 deletions src/Filters/Filters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ using Polynomials: LaurentPolynomial, Polynomial, coeffs, derivative, fromroots,
import Base: *
using LinearAlgebra: I, mul!, rmul!
using Statistics: middle
using SpecialFunctions: ellipk
import ..DSP: filt, filt!, optimalfftfiltlength, os_fft_complexity, SMALL_FILT_CUTOFF
import Compat
using FFTW
Expand Down Expand Up @@ -44,6 +45,13 @@ export FilterType,
FIRWindow,
resample_filter

include("filt_order.jl")
export buttord,
ellipord,
cheb1ord,
cheb2ord


include("response.jl")
export freqresp,
phaseresp,
Expand Down

0 comments on commit 4f6390b

Please sign in to comment.