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

Add plot_phase_spectrum().

parent 84db1c85
Branches
No related tags found
1 merge request!419Resolve RTSD-265
...@@ -137,7 +137,7 @@ def plot_iir_filter_analysis(b, a, fs=1.0, whole=False, Ntime=100, step=False, l ...@@ -137,7 +137,7 @@ def plot_iir_filter_analysis(b, a, fs=1.0, whole=False, Ntime=100, step=False, l
return z, p, k return z, p, k
def plot_spectra(fn, HF, fs=1.0, fLim=None, dbLim=None): def plot_spectra(fn, HF, fs=1.0, fLim=None, dbLim=None, aLim=None):
"""Plot spectra for power, magnitude, phase, real, imag """Plot spectra for power, magnitude, phase, real, imag
Input: Input:
...@@ -189,6 +189,34 @@ def plot_spectra(fn, HF, fs=1.0, fLim=None, dbLim=None): ...@@ -189,6 +189,34 @@ def plot_spectra(fn, HF, fs=1.0, fLim=None, dbLim=None):
plt.xlabel(flabel) plt.xlabel(flabel)
if fLim: if fLim:
plt.xlim(fLim) plt.xlim(fLim)
if aLim:
plt.ylim(aLim)
plt.grid(True)
def plot_phase_spectrum(fn, HF, fmt='r', fs=1.0, fLim=None, aLim=None):
"""Plot phase spectrum
Use fLim and aLim to zoom in, to see slope in pass band. Note that -pi =
pi.
Input:
. fn: normalized frequency axis for HF (fs = 1)
. HF: spectrum, e.g. frequency transfer function HF = DTFT(h)
. fmt: curve format string
. fs: sample frequency in Hz
"""
f = fn * fs # scale fn by fs
flabel = 'Frequency [fs = %f]' % fs
plt.plot(f, np.unwrap(np.angle(HF)), fmt)
plt.title('Phase spectrum')
plt.ylabel('Pase [rad]')
plt.xlabel(flabel)
if fLim:
plt.xlim(fLim)
if aLim:
plt.ylim(aLim)
plt.grid(True) plt.grid(True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment