{ "metadata": { "name": "", "signature": "sha256:da77871482e70a864cbe193386aab62b793fd07f2bb219e31e2acb888c8d220a" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "from ipywidgets import StaticInteract, RangeWidget" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "A = 1\n", "phase_factor = 0\n", "c = 3e+08\n", "L = 1.5\n", "FSR = c/(2*L)\n", "t = np.arange(-27e-9,27e-9,1e-12)\n", "#go from -27ns to +27ns in steps of 1 ps.\n", "total = 0\n", "Upper = 1.9355e+14 + 3e+04*FSR\n", "# Upper frequency limit : c / lambda+%(80comb modes * FSR )\n", "f = np.arange(1.9355e14,Upper,FSR)\n", "\n", "def plot(i):\n", " fig, ax = plt.subplots(figsize=(6, 6),\n", " subplot_kw={'axisbg':'#EEEEEE',\n", " 'axisbelow':True})\n", " ax.grid(color='w', linewidth=2, linestyle='solid')\n", " temp = 0\n", " j = 0\n", " while j < i:\n", " temp += np.cos(2*np.pi*f[j]*t)\n", " j += 1\n", " ax.plot(t,temp/max(temp), lw=5, alpha=0.4)\n", " #ax.set_xlim(-50, 50)\n", " #ax.set_ylim(0, 1)\n", " return fig" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "StaticInteract(plot,i=RangeWidget(1, 5, 1))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", " \n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " i: \n", "
\n", " " ], "metadata": {}, "output_type": "pyout", "prompt_number": 3, "text": [ "" ] } ], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "A = 1\n", "phase_factor = 0\n", "c = 3e+08\n", "L = 1.5\n", "FSR = c/(2*L)\n", "t = np.arange(-27e-9,27e-9,1e-12)\n", "#go from -27ns to +27ns in steps of 1 ps.\n", "total = 0\n", "Upper = 1.9355e+14 + 3e+04*FSR\n", "# Upper frequency limit : c / lambda+%(80comb modes * FSR )\n", "f = np.arange(1.9355e14,Upper,FSR)\n", "\n", "def plot(i):\n", " fig, (ax0, ax1) = plt.subplots(1, 2, figsize=(6, 6),\n", " subplot_kw={'axisbg':'#EEEEEE',\n", " 'axisbelow':True})\n", " temp = 0\n", " j = 0\n", " while j < i:\n", " temp += np.cos(2*np.pi*f[j]*t)\n", " j += 1\n", " ax0.plot(t,temp/max(temp), lw=2, alpha=0.4)\n", " ax1.plot(t,(temp/max(temp))**2, lw=2, alpha=0.4)\n", " return fig" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 4 }, { "cell_type": "code", "collapsed": false, "input": [ "StaticInteract(plot,i=RangeWidget(1, 5, 1))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", " \n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " i: \n", "
\n", " " ], "metadata": {}, "output_type": "pyout", "prompt_number": 5, "text": [ "" ] } ], "prompt_number": 5 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "A = 1\n", "phase_factor = 0\n", "c = 3e+08\n", "L = 1.5\n", "FSR = c/(2*L)\n", "x = np.arange(0,6,1e-02)\n", "#go from -27ns to +27ns in steps of 1 ps.\n", "total = 0\n", "Upper = 1.9355e+14 + 3e+04*FSR\n", "# Upper frequency limit : c / lambda+%(80comb modes * FSR )\n", "f = np.arange(1.9355e14,Upper,FSR)\n", "#x = np.linspace(0,np.pi/2.,21)\n", "\n", "def plot(t):\n", " fig, ax = plt.subplots(figsize=(4, 3),\n", " subplot_kw={'axisbg':'#EEEEEE',\n", " 'axisbelow':True})\n", " ax.grid(color='w', linewidth=2, linestyle='solid')\n", " temp = 0\n", " j = 0\n", " while j < 5:\n", " temp += np.cos(2*np.pi*f[j]*(x/c -t*1e-08))\n", " j += 1\n", " ax.plot(x,temp**2/max(temp**2), lw=5, alpha=0.4)\n", " #ax.set_xlim(-50, 50)\n", " #ax.set_ylim(0, 1)\n", " return fig" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 6 }, { "cell_type": "code", "collapsed": false, "input": [ "StaticInteract(plot,t=RangeWidget(0.5, 2.5, 0.25))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", " \n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " t: \n", "
\n", " " ], "metadata": {}, "output_type": "pyout", "prompt_number": 7, "text": [ "" ] } ], "prompt_number": 7 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }