{
 "metadata": {
  "name": "",
  "signature": "sha256:3ce2a8e0bdcc84611faaaf758db7c8be7ea3a48efdd0a21aa574d2c1f296937a"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "raw",
     "metadata": {},
     "source": [
      "This IPython Notebook contains simple examples of the line function. \n",
      "\n",
      "To clear all previously rendered cell outputs, select from the menu:\n",
      "\n",
      "    Cell -> All Output -> Clear"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "from scipy.integrate import odeint"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from bokeh.plotting import *"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "sigma = 10\n",
      "rho = 28\n",
      "beta = 8.0/3\n",
      "theta = 3 * np.pi / 4"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def lorenz(xyz, t):\n",
      "    x, y, z = xyz\n",
      "    x_dot = sigma * (y - x)\n",
      "    y_dot = x * rho - x * z - y\n",
      "    z_dot = x * y - beta* z\n",
      "    return [x_dot, y_dot, z_dot]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "initial = (-10, -7, 35)\n",
      "t = np.arange(0, 100, 0.001)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "solution = odeint(lorenz, initial, t)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "x = solution[:, 0]\n",
      "y = solution[:, 1]\n",
      "z = solution[:, 2]\n",
      "xprime = np.cos(theta) * x - np.sin(theta) * y"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "colors = [\"#C6DBEF\", \"#9ECAE1\", \"#6BAED6\", \"#4292C6\", \"#2171B5\", \"#08519C\", \"#08306B\",]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "output_notebook()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "multi_line(np.array_split(xprime, 7), np.array_split(z, 7),\n",
      "           line_color=colors, line_alpha=0.8, line_width=1.5,\n",
      "           tools=\"pan,wheel_zoom,box_zoom,reset,resize\", title=\"lorenz example\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "show()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}