Skip to content
Snippets Groups Projects

Resolve RTSD-265

Merged Eric Kooistra requested to merge RTSD-265 into master
1 file
+ 29
1
Compare changes
  • Side-by-side
  • Inline
@@ -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
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
Input:
@@ -189,6 +189,34 @@ def plot_spectra(fn, HF, fs=1.0, fLim=None, dbLim=None):
plt.xlabel(flabel)
if 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)
Loading