Minimum_and_maximum_phase_responses.gif


Summary

Description
English: Shows the phase responses of a minimum and maximum phase responses when is a monomial with . Both filters have the same gain response. Top : Minimum phase filter. Bottom : Maximum phase filter. Left : Nyquist diagram. Right : Phase responses
Date
Source Own work
Author fdeloche

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

Generation code

Minimumphase.py

# coding: utf-8
'''Generate an animation showing the phase response for a minimum and maximum phase system'''
__author__      = "fdeloche"

# In[1]:

get_ipython().magic(u'matplotlib inline')
import sys
import numpy as np
import matplotlib.pyplot as pl
from matplotlib.animation import FuncAnimation

# In[2]:

createGif=True
pl.rc('xtick', labelsize=20)
pl.rc('ytick', labelsize=20)
pl.rc('font', weight='bold')

# In[3]:

fig, ((ax1, ax2), (ax3, ax4)) = pl.subplots(2, 2, figsize=(15, 15))
#fig.set_tight_layout(True)
a_x = 0.8
a_y=0.

m=1000

A = a_x + 1j*a_y
a_mod = np.abs(A)
Ainv = 1./A
a_xbis = np.real(Ainv)
a_ybis = -np.imag(Ainv)
# r^2 =  

x_lim_a = -0.3
x_lim_b = 1.9
y_lim = 1.1

t = np.linspace(0, 1, num=m)

ax1.scatter(0, 0, linewidth=6, color='blue')
ax1.scatter(1, 0, linewidth=4, color='blue')
ax1.set_xlim([x_lim_a, x_lim_b])
ax1.set_ylim([-y_lim, y_lim])

ax1.set_title('$1-az^{-1}$', fontsize=35)

ax1.plot(t, np.zeros(m), color='blue', linewidth=4)
ax1.plot(1+a_mod*np.cos(2*np.pi*t), a_mod*np.sin(2*np.pi*t), color='black')
ax1.axis('off')
ax1.text(-0.2, 0.1, "$(0, 0)$", fontsize=30, color='blue')
ax1.text(1-0.1, 0.1, "$(1, 0)$", fontsize=30, color='blue')



ax3.set_title('$\overline{a}(1-\overline{a}^{\ -1}z^{-1})$', fontsize=35)
ax3.scatter(0, 0, linewidth=6, color='blue')
ax3.scatter(np.abs(A), 0, linewidth=4, color='blue')
ax3.set_xlim([x_lim_a, x_lim_b])
ax3.set_ylim([-y_lim, y_lim])

ax3.plot(t*np.abs(A), np.zeros(m), color='blue', linewidth=4)
ax3.plot(np.abs(A)+np.cos(2*np.pi*t), np.sin(2*np.pi*t), color='black')
ax3.axis('off')
ax3.text(-0.1, 0.1, "$(0, 0)$", fontsize=30, color='blue')
ax3.text(-0.1+np.abs(A), 0.1, "$(\overline{a}, 0)$", fontsize=30, color='blue')

Z = np.cos(2*np.pi*t) - 1j*np.sin(2*np.pi*t)
G = np.angle(1-A*Z)

ax2.set_title('Phase response', fontsize=25)
ax2.plot(2*np.pi*t, G, color='blue', linewidth=2)
ax2.plot(2*np.pi*t, 0*t, color='black')

G2 = np.angle(1-np.conj(Ainv)*Z)

#ax4.set_title('Phase response', fontsize=25)
ax4.plot(2*np.pi*t, G2, color='blue', linewidth=2)
ax4.plot(2*np.pi*t, 0*t, color='black')


ax2.set_ylim([-np.pi, np.pi])

ax4.set_ylim([-np.pi, np.pi])

ax2.set_xlim([0, 6.283])

ax4.set_xlim([0, 6.283])

'''
ax2.spines["top"].set_visible(False)
ax2.spines["right"].set_visible(False)

ax4.spines["top"].set_visible(False)
ax4.spines["right"].set_visible(False)
'''

# In[4]:

line1, = ax1.plot(1-np.abs(A)*t*1, t*0, color='blue', linewidth=4)
line2, = ax3.plot(np.abs(A)-t*1, t*0, color='blue', linewidth=4)
line3, = ax1.plot((1-np.abs(A))*t*1, t*0, color='red', linewidth=4)
line4, = ax3.plot((np.abs(A)-1)*t, t*0, color='red', linewidth=4)

point1 = ax1.scatter(1-np.abs(A), 0, linewidth=5, color='red')
point2 = ax3.scatter(np.abs(A)-1, 0, linewidth=5, color='red')

line5, = ax2.plot(0*t, G[0]*t, color='red', linewidth=4)
line6, = ax4.plot(0*t, G2[0]*t, color='red', linewidth=4)

point3 = ax2.scatter(0, G[0], color='red', linewidth=5)
point4 = ax4.scatter(0, G2[0], color='red', linewidth=5)

# In[5]:

n_frames = 55
def update(i):
    t0 = i*1./n_frames
    B = [a_mod*np.cos(2*np.pi*t0), -a_mod*np.sin(2*np.pi*t0)]
    line1.set_xdata(1-t*B[0])
    line1.set_ydata(-t*B[1])
    C = [np.cos(2*np.pi*t0), -np.sin(2*np.pi*t0)]
    line2.set_xdata(np.abs(A)-t*C[0])
    line2.set_ydata(-t*C[1])
    
    line3.set_xdata((1-B[0])*t)
    line3.set_ydata(-t*B[1])
    line4.set_xdata((np.abs(A)-C[0])*t)
    line4.set_ydata(-t*C[1])
    
    point1.set_offsets((1-B[0], -B[1]))
    point2.set_offsets((np.abs(A)-C[0], -C[1]))
    
    line5.set_xdata(2*np.pi*t0+0*t)
    line6.set_xdata(2*np.pi*t0+0*t)

    Z0 = np.cos(2*np.pi*t0) - 1j*np.sin(2*np.pi*t0)
    G0 = np.angle(1-A*Z0)
    G20 = np.angle(1-np.conj(Ainv)*Z0)
    
    line5.set_ydata(G0*t)
    line6.set_ydata(G20*t)
    
    point3.set_offsets((2*np.pi*t0, G0))
    
    point4.set_offsets((2*np.pi*t0, G20))
    return line1, line2, line3, line4, point1, point2, line5, line6, point3, point4

# In[ ]:

anim = FuncAnimation(fig, update, frames=np.arange(0,n_frames), interval=50, blit=True)
if(createGif):
    anim.save('result.gif', dpi=30, writer='imagemagick')
else:
    pl.show()

# In[ ]:

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

21 September 2016