{ "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", "