import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from ipywidgets import StaticInteract, RangeWidget, RadioWidget
$\phi_0$ - the zeroth order phase or the absolute phase $$E(t) = E_0 exp[-(t/\tau_G)^2]exp[i(\omega_0 t+\phi_0)]$$
def plot(a,b):
fig, ax = plt.subplots(figsize=(5, 5),
subplot_kw={'axisbg':'#EEEEEE',
'axisbelow':True})
ax.grid(color='w', linewidth=2, linestyle='solid')
t = np.linspace(-2*np.pi,2*np.pi,100)
ax.plot(t,np.exp(-t**2/4)*np.sin(t*a+b), lw=2, alpha=0.4, label=a)
ax.set_xlim(-2*np.pi, +2*np.pi)
ax.legend(loc='upper right')
# ax.set_ylim(-2.5, 2.5)
return fig
StaticInteract(plot,a=RangeWidget(1., 5., 2.), b=RangeWidget(0, +2., 0.5))
def plot(a,b):
fig, (ax0, ax1) = plt.subplots(1, 2, figsize=(6, 6),
subplot_kw={'axisbg':'#EEEEEE',
'axisbelow':True})
#ax.grid(color='w', linewidth=2, linestyle='solid')
t = np.linspace(-2*np.pi,2*np.pi,100)
ax0.plot(t,np.exp(-t**2/4)*np.sin(t*b+a*t**0), lw=2, alpha=0.4, label=a)
ax0.set_xlim(-2*np.pi, +2*np.pi)
ax0.legend(loc='upper right')
#ax1.plot(t,a*t**2, lw=2, alpha=0.4, label=a)
ax1.plot(t,(np.exp(-t**2/4)**2*np.sin(t*b+a*t**0))**2, lw=2, alpha=0.4, label=a)
# ax1.set_xlim(-2*np.pi, +2*np.pi)
ax1.set_xlim(-4, 4)
ax2=ax1.twinx() #ax1.legend(loc='upper right')
ax2.plot(t,a*t**0)
return fig
StaticInteract(plot,a=RangeWidget(-2., +2., 0.5),b=RangeWidget(1., 5., 2.))
/usr/lib/pymodules/python2.7/matplotlib/pyplot.py:412: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_num_figures`). max_open_warning, RuntimeWarning)
$\phi_1$ - the first order phase, a shift in time $$E(t) = E_0 exp[-(t/\tau_G)^2]exp[i(\omega_0 t+\alpha t)]$$
def plot(a):
fig, ax = plt.subplots(figsize=(5, 5),
subplot_kw={'axisbg':'#EEEEEE',
'axisbelow':True})
ax.grid(color='w', linewidth=2, linestyle='solid')
t = np.linspace(-2*np.pi,2*np.pi,100)
ax.plot(t,np.exp(-t**2/4)*np.sin(t+a*t), lw=2, alpha=0.4, label=a)
ax.set_xlim(-2*np.pi, +2*np.pi)
ax.legend(loc='upper right')
# ax.set_ylim(-2.5, 2.5)
return fig
StaticInteract(plot,a=RangeWidget(1., 10., 2.))
def plot(a,b):
fig, (ax0, ax1) = plt.subplots(1, 2, figsize=(6, 6),
subplot_kw={'axisbg':'#EEEEEE',
'axisbelow':True})
#ax.grid(color='w', linewidth=2, linestyle='solid')
t = np.linspace(-2*np.pi,2*np.pi,100)
ax0.plot(t,np.exp(-t**2/4)*np.sin(t*b+a*t**1), lw=2, alpha=0.4, label=a)
ax0.set_xlim(-2*np.pi, +2*np.pi)
ax0.legend(loc='upper right')
#ax1.plot(t,a*t**2, lw=2, alpha=0.4, label=a)
ax1.plot(t,(np.exp(-t**2/4)**2*np.sin(t*b+a*t**1))**2, lw=2, alpha=0.4, label=a)
# ax1.set_xlim(-2*np.pi, +2*np.pi)
ax1.set_xlim(-4, 4)
ax2=ax1.twinx() #ax1.legend(loc='upper right')
ax2.plot(t,a*t**1)
return fig
StaticInteract(plot,a=RangeWidget(-2., +2., 0.5),b=RangeWidget(1., 5., 2.))
$\phi_2$ - the second order phase, linear chirp $$E(t) = E_0 exp[-(t/\tau_G)^2]exp[i(\omega_0 t+\beta t^2)]$$
def plot(a):
fig, ax = plt.subplots(figsize=(5, 5),
subplot_kw={'axisbg':'#EEEEEE',
'axisbelow':True})
ax.grid(color='w', linewidth=2, linestyle='solid')
t = np.linspace(-2*np.pi,2*np.pi,100)
ax.plot(t,np.exp(-t**2/4)*np.sin(t*10+a*t**2), lw=2, alpha=0.4, label=a)
ax.set_xlim(-2*np.pi, +2*np.pi)
ax.legend(loc='upper right')
# ax.set_ylim(-2.5, 2.5)
return fig
StaticInteract(plot,a=RangeWidget(-2., +2., 0.5))
def plot(a):
fig, (ax0, ax1) = plt.subplots(1, 2, figsize=(6, 6),
subplot_kw={'axisbg':'#EEEEEE',
'axisbelow':True})
#ax.grid(color='w', linewidth=2, linestyle='solid')
t = np.linspace(-2*np.pi,2*np.pi,100)
ax0.plot(t,np.exp(-t**2/4)*np.sin(t*10+a*t**2), lw=2, alpha=0.4, label=a)
ax0.set_xlim(-2*np.pi, +2*np.pi)
ax0.legend(loc='upper right')
#ax1.plot(t,a*t**2, lw=2, alpha=0.4, label=a)
ax1.plot(t,(np.exp(-t**2/4)**2*np.sin(t*10+a*t**2))**2, lw=2, alpha=0.4, label=a)
# ax1.set_xlim(-2*np.pi, +2*np.pi)
ax1.set_xlim(-4, 4)
ax2=ax1.twinx() #ax1.legend(loc='upper right')
ax2.plot(t,a*t**2)
return fig
StaticInteract(plot,a=RangeWidget(-2., +2., 0.5))
matplotlib example code for plotting multiple vertical axes - link
$\phi_3$ - the third order phase, quadratic chirp $$E(t) = E_0 exp[-(t/\tau_G)^2]exp[i(\omega_0 t+\gamma t^3)]$$
def plot(a):
fig, ax = plt.subplots(figsize=(7, 7),
subplot_kw={'axisbg':'#EEEEEE',
'axisbelow':True})
ax.grid(color='w', linewidth=2, linestyle='solid')
t = np.linspace(-10*np.pi,10*np.pi,250)
ax.plot(t,np.exp(-(t**2)/100)*np.sin(t*2+a*t**3), lw=2, alpha=0.4, label=a)
ax.set_xlim(0, +10.5*np.pi)
ax.legend(loc='upper right')
# ax.set_ylim(-2.5, 2.5)
return fig
StaticInteract(plot,a=RangeWidget(0.03, 0.1, 1./100))#, 1./100))
def plot(a):
fig, ax = plt.subplots(figsize=(5, 5),
subplot_kw={'axisbg':'#EEEEEE',
'axisbelow':True})
ax.grid(color='w', linewidth=2, linestyle='solid')
t = np.linspace(-10*np.pi,10*np.pi,500)
ax.plot(t,np.exp(-t**2/100)*np.sin(t+a*t**4), lw=2, alpha=0.4, label=a)
#ax.set_xlim(-2*np.pi, +2*np.pi)
ax.legend(loc='upper right')
# ax.set_ylim(-2.5, 2.5)
return fig
StaticInteract(plot,a=RangeWidget(0.45,0.55, 1./100))
t = np.linspace(-2*np.pi,2*np.pi,250)
plt.plot(t,np.exp(-t**2/10)*np.sin(t*2*np.pi/3+50*t**4))
[<matplotlib.lines.Line2D at 0xb0190d6c>]
link for matplotlib subplot demo codes
where $\phi_1 = \frac{d\phi}{d\omega}\lvert_{\omega=\omega_0}, \phi_2 = \frac{d^2\phi}{d\omega^2}\lvert_{\omega=\omega_0}$
We have defined $\phi_1$ is group delay and $\phi_2$ is group delay dispersion