In [1]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from ipywidgets import StaticInteract, RangeWidget
In [2]:
A = 1
phase_factor = 0
c = 3e+08
L = 1.5
FSR = c/(2*L)
t = np.arange(-27e-9,27e-9,1e-12)
#go from -27ns to +27ns in steps of 1 ps.
total = 0
Upper = 1.9355e+14 + 3e+04*FSR
# Upper frequency limit : c / lambda+%(80comb modes * FSR )
f = np.arange(1.9355e14,Upper,FSR)

def plot(i):
    fig, ax = plt.subplots(figsize=(6, 6),
                           subplot_kw={'axisbg':'#EEEEEE',
                                       'axisbelow':True})
    ax.grid(color='w', linewidth=2, linestyle='solid')
    temp = 0
    j = 0
    while j < i:
        temp += np.cos(2*np.pi*f[j]*t)
        j += 1
    ax.plot(t,temp/max(temp), lw=5, alpha=0.4)
    #ax.set_xlim(-50, 50)
    #ax.set_ylim(0, 1)
    return fig
In [3]:
StaticInteract(plot,i=RangeWidget(1, 5, 1))
Out[3]:
i:
In []:
 
In [4]:
A = 1
phase_factor = 0
c = 3e+08
L = 1.5
FSR = c/(2*L)
t = np.arange(-27e-9,27e-9,1e-12)
#go from -27ns to +27ns in steps of 1 ps.
total = 0
Upper = 1.9355e+14 + 3e+04*FSR
# Upper frequency limit : c / lambda+%(80comb modes * FSR )
f = np.arange(1.9355e14,Upper,FSR)

def plot(i):
    fig, (ax0, ax1) = plt.subplots(1, 2, figsize=(6, 6),
                           subplot_kw={'axisbg':'#EEEEEE',
                                       'axisbelow':True})
    temp = 0
    j = 0
    while j < i:
        temp += np.cos(2*np.pi*f[j]*t)
        j += 1
    ax0.plot(t,temp/max(temp), lw=2, alpha=0.4)
    ax1.plot(t,(temp/max(temp))**2, lw=2, alpha=0.4)
    return fig
In [5]:
StaticInteract(plot,i=RangeWidget(1, 5, 1))
Out[5]:
i:
In []:
 
In [6]:
A = 1
phase_factor = 0
c = 3e+08
L = 1.5
FSR = c/(2*L)
x = np.arange(0,6,1e-02)
#go from -27ns to +27ns in steps of 1 ps.
total = 0
Upper = 1.9355e+14 + 3e+04*FSR
# Upper frequency limit : c / lambda+%(80comb modes * FSR )
f = np.arange(1.9355e14,Upper,FSR)
#x = np.linspace(0,np.pi/2.,21)

def plot(t):
    fig, ax = plt.subplots(figsize=(4, 3),
                           subplot_kw={'axisbg':'#EEEEEE',
                                       'axisbelow':True})
    ax.grid(color='w', linewidth=2, linestyle='solid')
    temp = 0
    j = 0
    while j < 5:
        temp += np.cos(2*np.pi*f[j]*(x/c -t*1e-08))
        j += 1
    ax.plot(x,temp**2/max(temp**2), lw=5, alpha=0.4)
    #ax.set_xlim(-50, 50)
    #ax.set_ylim(0, 1)
    return fig
In [7]:
StaticInteract(plot,t=RangeWidget(0.5, 2.5, 0.25))
Out[7]:
t:
In []: