Skip to content
Snippets Groups Projects
Commit f5310b94 authored by Eric Kooistra's avatar Eric Kooistra
Browse files

IIR analysis.

parent acc83764
No related branches found
No related tags found
1 merge request!374Add plot_iir_filter_analysis() based on LTF-IIR-allgemein.ipynbcode from...
%% Cell type:markdown id:6e0a005d tags:
# Try IIR filter
Author: Eric Kooistra, dec 2023
Purpose:
* Practise DSP [1].
* Uses code from [2] to plot IIR filter analysis results
References:
1. dsp_study_erko, summary of DSP books
2. https://github.com/chipmuenk/dsp/blob/main/notebooks/02_LTF/LTF-IIR-allgemein.ipynb
%% Cell type:code id:3563bc63 tags:
``` python
import numpy as np
import matplotlib.pyplot as plt
from scipy import signal
```
%% Cell type:code id:f820b0ac tags:
``` python
import dsp
```
%% Cell type:code id:a131b5b6 tags:
``` python
import importlib
importlib.reload(dsp)
```
%% Output
<module 'dsp' from '/dop466_0/kooistra/git/hdl/applications/lofar2/model/pfb_os/dsp.py'>
%% Cell type:code id:e38f8974 tags:
``` python
# Fixed constants:
fs = 1
Ts = 1 / fs
fNyquist = fs / 2
```
%% Cell type:code id:ea2b5233 tags:
``` python
alpha = 0.9
b = [1]
# b = [1, 0, 0] # z^2 + 0
a = [1, -alpha] # z - 0.9; Add., 1 Verzögerung
#a = [1, +alpha] # z + 0.9; Subtr., 1 Verz.
#a = [1, 0, -alpha] # z^2 - 0.9; Add., 2 Verz.
#a = [1, 0, +alpha] # z^2 - 0.9; Subtr., 2 Verz.
```
%% Cell type:code id:92a4c9d4 tags:
``` python
# Code example from [2] to plot H(z)
show = ['zplane', 'power spectrum', 'phase spectrum', 'time response']
whole = False
z, p, k = dsp.plot_iir_filter_analysis(b, a, fs=1, whole=whole, Ntime=100, step=False, show=show)
```
%% Output
Zeros, poles and gain from b, a coefficients:
. poles:
p = 0.9
. gain: k = 1.000
Coefficients back from z, p, k:
b = 1.0
a = [ 1. -0.9]
%% Cell type:code id:c262342b tags:
``` python
```
%% Cell type:code id:edb4d589 tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment