{ "cells": [ { "cell_type": "code", "execution_count": 92, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from __future__ import division\n", "from numpy import cos, pi\n", "import numpy as np\n", "\n", "def eady_qy_series(N,z):\n", " ''' Galerkin approximatin to Eady's \n", " basic state U = z + 1 \n", " N is the number of baroclinic modes '''\n", "\n", " n = np.arange(N)\n", " Z = np.array( np.matrix(2*n+1).T*np.matrix(z) )\n", "\n", " return 4.*cos(pi*Z).sum(axis=0)" ] }, { "cell_type": "code", "execution_count": 99, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "plt.rcParams.update({'font.size': 25, 'legend.handlelength' : 1.25})\n", "import seaborn as sns\n", "sns.set(style=\"darkgrid\")\n", "sns.set_context(\"notebook\", font_scale=2, rc={\"lines.linewidth\": 4.})\n", "\n", "\n", "z = np.linspace(-1.,0,300) \n", "U_exact = z + 1.\n", "\n", "N = np.arange(200)\n", "Qy_g = np.zeros((z.size,N.size))\n", "\n", "for i in range(N.size):\n", " Qy_g[:,i] = eady_qy_series(N[i],z)" ] }, { "cell_type": "code", "execution_count": 100, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from JSAnimation.IPython_display import display_animation\n", "from matplotlib import animation" ] }, { "cell_type": "code", "execution_count": 101, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", " Once \n", " Loop \n", " Reflect \n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 101, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fig = plt.figure(figsize=(7,7))\n", "ax = plt.axes(xlim=(Qy_g[:,-1].min(),Qy_g[:,-1].max()), ylim=(-1.025,0.025))\n", "line = ax.plot([], [], color='#003366', ls='-', lw=2.5,alpha=.5)[0]\n", "number = ax.text(.9*Qy_g[:,-1].min(),-.075,'n = 0')\n", "\n", "\n", "ax.spines['left'].set_position('center')\n", "ax.spines['bottom'].set_position('center')\n", "\n", "def animate(n):\n", " line.set_data(Qy_g[:,n],z)\n", " number.set_text('n = '+str(2*n+1))\n", "\n", "\n", "animation.FuncAnimation(fig, animate,\n", " frames=N.size, interval=100)" ] }, { "cell_type": "code", "execution_count": 89, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "u'n = 0[ 1 3 5 7 9 11 13 15 17 19]'" ] }, "execution_count": 89, "metadata": {}, "output_type": "execute_result" } ], "source": [] }, { "cell_type": "code", "execution_count": 75, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 75, "metadata": {}, "output_type": "execute_result" } ], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.9" } }, "nbformat": 4, "nbformat_minor": 0 }