{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Displays"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2017-05-24T14:54:00.311461Z",
     "start_time": "2017-05-24T14:53:57.229814Z"
    }
   },
   "outputs": [],
   "source": [
    "from triflow import Model, Simulation\n",
    "import numpy as np\n",
    "\n",
    "model = Model(\"dxxU\", \"U\")\n",
    "parameters = dict(periodic=False)\n",
    "\n",
    "x = np.linspace(0, 10, 50, endpoint=True)\n",
    "U = x ** 2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## displays objects\n",
    "\n",
    "The displays are objects with a `__call__` method. They can be add to a simulation with the `Simulation.add_display` method, or just called at every step during the simulation.\n",
    "\n",
    "A \"null\" display will be written as"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2017-05-24T14:54:00.321066Z",
     "start_time": "2017-05-24T14:54:00.314358Z"
    }
   },
   "outputs": [],
   "source": [
    "class NullDisplay():\n",
    "    def __init__(self, simul):\n",
    "        pass\n",
    "\n",
    "    def __call__(self, t, fields):\n",
    "        pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "this display will not change the simulation behavior.\n",
    "\n",
    "A very simple display could be a one printing the time after each step"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2017-05-24T14:54:00.328931Z",
     "start_time": "2017-05-24T14:54:00.323425Z"
    }
   },
   "outputs": [],
   "source": [
    "class TimeDisplay():\n",
    "    def __init__(self, simul):\n",
    "        pass\n",
    "\n",
    "    def __call__(self, t, fields):\n",
    "        print(f\"simulation time: {t:g}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And can be used with"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2017-05-24T14:54:03.312884Z",
     "start_time": "2017-05-24T14:54:00.331077Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "simulation time: 0\n",
      "simulation time: 10\n",
      "simulation time: 20\n",
      "simulation time: 30\n",
      "simulation time: 40\n"
     ]
    }
   ],
   "source": [
    "t = 0\n",
    "fields = model.fields_template(x=x, U=U)\n",
    "simul = Simulation(model, t, fields, parameters,\n",
    "                   dt=10, tmax=35, tol=1E-1)\n",
    "\n",
    "display = TimeDisplay(simul)\n",
    "\n",
    "display(t, fields)\n",
    "for t, fields in simul:\n",
    "    display(t, fields)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "or"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2017-05-24T14:54:06.076597Z",
     "start_time": "2017-05-24T14:54:03.314858Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "simulation time: 0\n",
      "simulation time: 10\n",
      "simulation time: 20\n",
      "simulation time: 30\n",
      "simulation time: 40\n"
     ]
    }
   ],
   "source": [
    "t = 0\n",
    "fields = model.fields_template(x=x, U=U)\n",
    "simul = Simulation(model, t, fields, parameters,\n",
    "                   dt=10, tmax=35, tol=1E-1)\n",
    "\n",
    "simul.add_display(TimeDisplay)\n",
    "\n",
    "for t, fields in simul:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## built-in displays\n",
    "\n",
    "### bokeh displays\n",
    "\n",
    "#### field display\n",
    "\n",
    "This display allow a real-time plot in a jupyter notebook. The `keys` argument allow to choose which fields will be plotted. All fields are plotted on specific figure, and the `line_kwargs` and `fig_kwargs` allow us to customize each bokeh figure and line."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2017-05-24T14:54:14.994372Z",
     "start_time": "2017-05-24T14:54:06.079570Z"
    },
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <a href=\"http://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
       "        <span id=\"c3dd74ea-6c81-4712-9ca8-4f667b37ba8c\">Loading BokehJS ...</span>\n",
       "    </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "(function(global) {\n",
       "  function now() {\n",
       "    return new Date();\n",
       "  }\n",
       "\n",
       "  var force = true;\n",
       "\n",
       "  if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "    window._bokeh_onload_callbacks = [];\n",
       "    window._bokeh_is_loading = undefined;\n",
       "  }\n",
       "\n",
       "\n",
       "  \n",
       "  if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "    window._bokeh_timeout = Date.now() + 5000;\n",
       "    window._bokeh_failed_load = false;\n",
       "  }\n",
       "\n",
       "  var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "     \"<div style='background-color: #fdd'>\\n\"+\n",
       "     \"<p>\\n\"+\n",
       "     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "     \"</p>\\n\"+\n",
       "     \"<ul>\\n\"+\n",
       "     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "     \"</ul>\\n\"+\n",
       "     \"<code>\\n\"+\n",
       "     \"from bokeh.resources import INLINE\\n\"+\n",
       "     \"output_notebook(resources=INLINE)\\n\"+\n",
       "     \"</code>\\n\"+\n",
       "     \"</div>\"}};\n",
       "\n",
       "  function display_loaded() {\n",
       "    if (window.Bokeh !== undefined) {\n",
       "      var el = document.getElementById(\"c3dd74ea-6c81-4712-9ca8-4f667b37ba8c\");\n",
       "      el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n",
       "    } else if (Date.now() < window._bokeh_timeout) {\n",
       "      setTimeout(display_loaded, 100)\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function run_callbacks() {\n",
       "    window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "    delete window._bokeh_onload_callbacks\n",
       "    console.info(\"Bokeh: all callbacks have finished\");\n",
       "  }\n",
       "\n",
       "  function load_libs(js_urls, callback) {\n",
       "    window._bokeh_onload_callbacks.push(callback);\n",
       "    if (window._bokeh_is_loading > 0) {\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "      return null;\n",
       "    }\n",
       "    if (js_urls == null || js_urls.length === 0) {\n",
       "      run_callbacks();\n",
       "      return null;\n",
       "    }\n",
       "    console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "    window._bokeh_is_loading = js_urls.length;\n",
       "    for (var i = 0; i < js_urls.length; i++) {\n",
       "      var url = js_urls[i];\n",
       "      var s = document.createElement('script');\n",
       "      s.src = url;\n",
       "      s.async = false;\n",
       "      s.onreadystatechange = s.onload = function() {\n",
       "        window._bokeh_is_loading--;\n",
       "        if (window._bokeh_is_loading === 0) {\n",
       "          console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "          run_callbacks()\n",
       "        }\n",
       "      };\n",
       "      s.onerror = function() {\n",
       "        console.warn(\"failed to load library \" + url);\n",
       "      };\n",
       "      console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "      document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "  };var element = document.getElementById(\"c3dd74ea-6c81-4712-9ca8-4f667b37ba8c\");\n",
       "  if (element == null) {\n",
       "    console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'c3dd74ea-6c81-4712-9ca8-4f667b37ba8c' but no matching script tag was found. \")\n",
       "    return false;\n",
       "  }\n",
       "\n",
       "  var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.js\"];\n",
       "\n",
       "  var inline_js = [\n",
       "    function(Bokeh) {\n",
       "      Bokeh.set_log_level(\"info\");\n",
       "    },\n",
       "    \n",
       "    function(Bokeh) {\n",
       "      \n",
       "    },\n",
       "    \n",
       "    function(Bokeh) {\n",
       "      \n",
       "      document.getElementById(\"c3dd74ea-6c81-4712-9ca8-4f667b37ba8c\").textContent = \"BokehJS is loading...\";\n",
       "    },\n",
       "    function(Bokeh) {\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.css\");\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.css\");\n",
       "    }\n",
       "  ];\n",
       "\n",
       "  function run_inline_js() {\n",
       "    \n",
       "    if ((window.Bokeh !== undefined) || (force === true)) {\n",
       "      for (var i = 0; i < inline_js.length; i++) {\n",
       "        inline_js[i](window.Bokeh);\n",
       "      }if (force === true) {\n",
       "        display_loaded();\n",
       "      }} else if (Date.now() < window._bokeh_timeout) {\n",
       "      setTimeout(run_inline_js, 100);\n",
       "    } else if (!window._bokeh_failed_load) {\n",
       "      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "      window._bokeh_failed_load = true;\n",
       "    } else if (force !== true) {\n",
       "      var cell = $(document.getElementById(\"c3dd74ea-6c81-4712-9ca8-4f667b37ba8c\")).parents('.cell').data().cell;\n",
       "      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "    }\n",
       "\n",
       "  }\n",
       "\n",
       "  if (window._bokeh_is_loading === 0) {\n",
       "    console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "    run_inline_js();\n",
       "  } else {\n",
       "    load_libs(js_urls, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "      run_inline_js();\n",
       "    });\n",
       "  }\n",
       "}(this));"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <div class=\"bk-plotdiv\" id=\"77a4e18b-b83c-4954-b84c-2ec09ed157c0\"></div>\n",
       "    </div>\n",
       "<script type=\"text/javascript\">\n",
       "  \n",
       "  (function(global) {\n",
       "    function now() {\n",
       "      return new Date();\n",
       "    }\n",
       "  \n",
       "    var force = false;\n",
       "  \n",
       "    if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "      window._bokeh_onload_callbacks = [];\n",
       "      window._bokeh_is_loading = undefined;\n",
       "    }\n",
       "  \n",
       "  \n",
       "    \n",
       "    if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "      window._bokeh_timeout = Date.now() + 0;\n",
       "      window._bokeh_failed_load = false;\n",
       "    }\n",
       "  \n",
       "    var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "       \"<div style='background-color: #fdd'>\\n\"+\n",
       "       \"<p>\\n\"+\n",
       "       \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "       \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "       \"</p>\\n\"+\n",
       "       \"<ul>\\n\"+\n",
       "       \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "       \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "       \"</ul>\\n\"+\n",
       "       \"<code>\\n\"+\n",
       "       \"from bokeh.resources import INLINE\\n\"+\n",
       "       \"output_notebook(resources=INLINE)\\n\"+\n",
       "       \"</code>\\n\"+\n",
       "       \"</div>\"}};\n",
       "  \n",
       "    function display_loaded() {\n",
       "      if (window.Bokeh !== undefined) {\n",
       "        var el = document.getElementById(\"77a4e18b-b83c-4954-b84c-2ec09ed157c0\");\n",
       "        el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n",
       "      } else if (Date.now() < window._bokeh_timeout) {\n",
       "        setTimeout(display_loaded, 100)\n",
       "      }\n",
       "    }if ((window.Jupyter !== undefined) && Jupyter.notebook.kernel) {\n",
       "      comm_manager = Jupyter.notebook.kernel.comm_manager\n",
       "      comm_manager.register_target(\"d03fd1f1-98f5-4ad9-8d06-95adf75270f7\", function () {});\n",
       "    }\n",
       "  \n",
       "    function run_callbacks() {\n",
       "      window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "      delete window._bokeh_onload_callbacks\n",
       "      console.info(\"Bokeh: all callbacks have finished\");\n",
       "    }\n",
       "  \n",
       "    function load_libs(js_urls, callback) {\n",
       "      window._bokeh_onload_callbacks.push(callback);\n",
       "      if (window._bokeh_is_loading > 0) {\n",
       "        console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "        return null;\n",
       "      }\n",
       "      if (js_urls == null || js_urls.length === 0) {\n",
       "        run_callbacks();\n",
       "        return null;\n",
       "      }\n",
       "      console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "      window._bokeh_is_loading = js_urls.length;\n",
       "      for (var i = 0; i < js_urls.length; i++) {\n",
       "        var url = js_urls[i];\n",
       "        var s = document.createElement('script');\n",
       "        s.src = url;\n",
       "        s.async = false;\n",
       "        s.onreadystatechange = s.onload = function() {\n",
       "          window._bokeh_is_loading--;\n",
       "          if (window._bokeh_is_loading === 0) {\n",
       "            console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "            run_callbacks()\n",
       "          }\n",
       "        };\n",
       "        s.onerror = function() {\n",
       "          console.warn(\"failed to load library \" + url);\n",
       "        };\n",
       "        console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "        document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "      }\n",
       "    };var element = document.getElementById(\"77a4e18b-b83c-4954-b84c-2ec09ed157c0\");\n",
       "    if (element == null) {\n",
       "      console.log(\"Bokeh: ERROR: autoload.js configured with elementid '77a4e18b-b83c-4954-b84c-2ec09ed157c0' but no matching script tag was found. \")\n",
       "      return false;\n",
       "    }\n",
       "  \n",
       "    var js_urls = [];\n",
       "  \n",
       "    var inline_js = [\n",
       "      function(Bokeh) {\n",
       "        (function() {\n",
       "          var fn = function() {\n",
       "            var docs_json = {\"20f88a27-96bd-4fed-9c68-898b5137847a\":{\"roots\":{\"references\":[{\"attributes\":{\"data_source\":{\"id\":\"fd3dc4e6-cf35-4e58-a320-20d3b7e57d53\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"72ffeb42-6cd9-48b4-9df3-2096dca7129e\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"542c7f84-ce0b-47b2-9cdd-449572d212f5\",\"type\":\"Line\"},\"selection_glyph\":null},\"id\":\"8041dd8b-d49c-4b3d-9c73-18cddee4907b\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"plot\":{\"id\":\"e648073a-256c-48ea-b087-d0b11cbf4a92\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"b82943d9-e133-4063-ba5b-9b7157240442\",\"type\":\"BasicTicker\"}},\"id\":\"d3faaa11-2914-4bc9-9657-15b43ada3c91\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"8e8a9a97-a04e-44be-be5c-6b5d48594a9a\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"e648073a-256c-48ea-b087-d0b11cbf4a92\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"e22d22a5-abd1-49c2-9387-83269b209c67\",\"type\":\"BasicTicker\"}},\"id\":\"e6096599-6553-493b-a09c-d479aac7a4de\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"e22d22a5-abd1-49c2-9387-83269b209c67\",\"type\":\"BasicTicker\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"e648073a-256c-48ea-b087-d0b11cbf4a92\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"e22d22a5-abd1-49c2-9387-83269b209c67\",\"type\":\"BasicTicker\"}},\"id\":\"caafca55-a418-4142-be72-e95ff7778ee1\",\"type\":\"Grid\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"8bb863bb-6a22-4951-b7ab-309575999daa\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"line_alpha\":{\"value\":0.8},\"line_color\":{\"value\":\"darkred\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"U\"}},\"id\":\"d69e519e-115c-44ec-a21e-0ce4d5e42918\",\"type\":\"Line\"},{\"attributes\":{\"plot\":{\"id\":\"e648073a-256c-48ea-b087-d0b11cbf4a92\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"0adb4b22-37a4-4a60-95ad-6f2d3ddf3c4d\",\"type\":\"PanTool\"},{\"attributes\":{\"below\":[{\"id\":\"219ab5a1-a646-48af-ba34-219b78ad74cc\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"e6096599-6553-493b-a09c-d479aac7a4de\",\"type\":\"LinearAxis\"}],\"plot_height\":200,\"renderers\":[{\"id\":\"219ab5a1-a646-48af-ba34-219b78ad74cc\",\"type\":\"LinearAxis\"},{\"id\":\"d3faaa11-2914-4bc9-9657-15b43ada3c91\",\"type\":\"Grid\"},{\"id\":\"e6096599-6553-493b-a09c-d479aac7a4de\",\"type\":\"LinearAxis\"},{\"id\":\"caafca55-a418-4142-be72-e95ff7778ee1\",\"type\":\"Grid\"},{\"id\":\"8bb863bb-6a22-4951-b7ab-309575999daa\",\"type\":\"BoxAnnotation\"},{\"id\":\"b640a41c-d1f3-43f1-85a4-10d8caef69d8\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"032d483f-e795-4b09-a24b-34164979f00d\",\"type\":\"Title\"},\"tool_events\":{\"id\":\"e01fb60d-ff61-4f1b-ab67-adc24aa23b09\",\"type\":\"ToolEvents\"},\"toolbar\":{\"id\":\"3b89e56b-4460-4e4e-8c32-9ed83e74d28d\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"ca2d8f40-ede0-4565-8f7a-c33fd0c3d594\",\"type\":\"Range1d\"},\"y_range\":{\"id\":\"78c2cb1b-ae95-46cd-b7f3-67798aa9a396\",\"type\":\"Range1d\"}},\"id\":\"e648073a-256c-48ea-b087-d0b11cbf4a92\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"plot\":{\"id\":\"e648073a-256c-48ea-b087-d0b11cbf4a92\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"a1191f41-2c67-4700-a347-7b0709d50ecd\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"data_source\":{\"id\":\"fd3dc4e6-cf35-4e58-a320-20d3b7e57d53\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"d69e519e-115c-44ec-a21e-0ce4d5e42918\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"e8820e53-df24-4ed9-9e30-9b3c666fc139\",\"type\":\"Line\"},\"selection_glyph\":null},\"id\":\"b640a41c-d1f3-43f1-85a4-10d8caef69d8\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"overlay\":{\"id\":\"8bb863bb-6a22-4951-b7ab-309575999daa\",\"type\":\"BoxAnnotation\"},\"plot\":{\"id\":\"e648073a-256c-48ea-b087-d0b11cbf4a92\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"db67ace2-34ee-4ade-88c5-92dd3b361617\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"plot\":{\"id\":\"e648073a-256c-48ea-b087-d0b11cbf4a92\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"a71ecefc-cab0-4256-8af2-ec998a19fc96\",\"type\":\"SaveTool\"},{\"attributes\":{\"plot\":{\"id\":\"e648073a-256c-48ea-b087-d0b11cbf4a92\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"9d92e6db-f272-4582-99d7-dfbdf7895ce5\",\"type\":\"ResetTool\"},{\"attributes\":{\"plot\":{\"id\":\"e648073a-256c-48ea-b087-d0b11cbf4a92\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"108c8fd3-2595-4610-832f-e9dc5c9b96fb\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"bd0e6258-9b87-4876-bae4-b7523f1ad467\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"below\":[{\"id\":\"a49a6f5f-be1a-4c6a-aeab-7c4d2fe7a253\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"5076a081-b298-4475-8663-93fb321624ca\",\"type\":\"LinearAxis\"}],\"plot_height\":200,\"renderers\":[{\"id\":\"a49a6f5f-be1a-4c6a-aeab-7c4d2fe7a253\",\"type\":\"LinearAxis\"},{\"id\":\"d1be5a2b-6e1e-4749-9a2c-d29c2d3dc48d\",\"type\":\"Grid\"},{\"id\":\"5076a081-b298-4475-8663-93fb321624ca\",\"type\":\"LinearAxis\"},{\"id\":\"a2fbfb0e-30a1-4912-ac5d-8c266229eaa2\",\"type\":\"Grid\"},{\"id\":\"1a7728ab-ae71-4bd6-8f69-0f3a85261124\",\"type\":\"BoxAnnotation\"},{\"id\":\"8041dd8b-d49c-4b3d-9c73-18cddee4907b\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"219dff78-72a5-40a9-b03a-6f04ef31d221\",\"type\":\"Title\"},\"tool_events\":{\"id\":\"e2676c13-8056-4284-8fe2-a711f12675c6\",\"type\":\"ToolEvents\"},\"toolbar\":{\"id\":\"2e189dab-554e-4728-8835-5f392e5735d4\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"a0e2ca84-08ed-48bb-a5a1-eb745150dc8f\",\"type\":\"DataRange1d\"},\"y_range\":{\"id\":\"ee4335ec-7001-4336-b826-195404978137\",\"type\":\"DataRange1d\"}},\"id\":\"595345e1-2652-40f0-a8c4-a9b979e6877c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"callback\":null},\"id\":\"a0e2ca84-08ed-48bb-a5a1-eb745150dc8f\",\"type\":\"DataRange1d\"},{\"attributes\":{\"plot\":null,\"text\":\"V\"},\"id\":\"219dff78-72a5-40a9-b03a-6f04ef31d221\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"e2676c13-8056-4284-8fe2-a711f12675c6\",\"type\":\"ToolEvents\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"b6821cf9-3ad9-429c-9bda-5e8a5103f4cd\",\"type\":\"PanTool\"},{\"id\":\"51f39243-487e-4231-9101-217d2fe7db0f\",\"type\":\"WheelZoomTool\"},{\"id\":\"ebc9e288-13da-414e-ab09-9ca26e3d3a61\",\"type\":\"BoxZoomTool\"},{\"id\":\"3cc6ff4f-b066-4c84-8748-f86694561d78\",\"type\":\"SaveTool\"},{\"id\":\"2f72553e-4f72-403a-8c84-955326b3fae1\",\"type\":\"ResetTool\"},{\"id\":\"5ab5bc45-bc5c-4d90-b0c4-4c4666e9185d\",\"type\":\"HelpTool\"}]},\"id\":\"2e189dab-554e-4728-8835-5f392e5735d4\",\"type\":\"Toolbar\"},{\"attributes\":{\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"V\"}},\"id\":\"72ffeb42-6cd9-48b4-9df3-2096dca7129e\",\"type\":\"Line\"},{\"attributes\":{\"formatter\":{\"id\":\"bd0e6258-9b87-4876-bae4-b7523f1ad467\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"595345e1-2652-40f0-a8c4-a9b979e6877c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"f7a1b943-2827-4f0b-80a6-223c9813b435\",\"type\":\"BasicTicker\"}},\"id\":\"a49a6f5f-be1a-4c6a-aeab-7c4d2fe7a253\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"00a6ab8a-18a2-4732-b1ad-336c5897f9f0\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"callback\":null},\"id\":\"ee4335ec-7001-4336-b826-195404978137\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"f7a1b943-2827-4f0b-80a6-223c9813b435\",\"type\":\"BasicTicker\"},{\"attributes\":{\"plot\":{\"id\":\"595345e1-2652-40f0-a8c4-a9b979e6877c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"f7a1b943-2827-4f0b-80a6-223c9813b435\",\"type\":\"BasicTicker\"}},\"id\":\"d1be5a2b-6e1e-4749-9a2c-d29c2d3dc48d\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"2e43d14e-fa04-413f-b830-43f7893b711e\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"formatter\":{\"id\":\"00a6ab8a-18a2-4732-b1ad-336c5897f9f0\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"595345e1-2652-40f0-a8c4-a9b979e6877c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"41b2f406-0b2c-4dbb-8d11-c902cc3f5b9b\",\"type\":\"BasicTicker\"}},\"id\":\"5076a081-b298-4475-8663-93fb321624ca\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"41b2f406-0b2c-4dbb-8d11-c902cc3f5b9b\",\"type\":\"BasicTicker\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"595345e1-2652-40f0-a8c4-a9b979e6877c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"41b2f406-0b2c-4dbb-8d11-c902cc3f5b9b\",\"type\":\"BasicTicker\"}},\"id\":\"a2fbfb0e-30a1-4912-ac5d-8c266229eaa2\",\"type\":\"Grid\"},{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"V\"}},\"id\":\"542c7f84-ce0b-47b2-9cdd-449572d212f5\",\"type\":\"Line\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1a7728ab-ae71-4bd6-8f69-0f3a85261124\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"plot\":{\"id\":\"595345e1-2652-40f0-a8c4-a9b979e6877c\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"b6821cf9-3ad9-429c-9bda-5e8a5103f4cd\",\"type\":\"PanTool\"},{\"attributes\":{\"plot\":{\"id\":\"595345e1-2652-40f0-a8c4-a9b979e6877c\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"51f39243-487e-4231-9101-217d2fe7db0f\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"overlay\":{\"id\":\"1a7728ab-ae71-4bd6-8f69-0f3a85261124\",\"type\":\"BoxAnnotation\"},\"plot\":{\"id\":\"595345e1-2652-40f0-a8c4-a9b979e6877c\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"ebc9e288-13da-414e-ab09-9ca26e3d3a61\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"plot\":{\"id\":\"595345e1-2652-40f0-a8c4-a9b979e6877c\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"3cc6ff4f-b066-4c84-8748-f86694561d78\",\"type\":\"SaveTool\"},{\"attributes\":{\"plot\":{\"id\":\"595345e1-2652-40f0-a8c4-a9b979e6877c\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"2f72553e-4f72-403a-8c84-955326b3fae1\",\"type\":\"ResetTool\"},{\"attributes\":{\"plot\":{\"id\":\"595345e1-2652-40f0-a8c4-a9b979e6877c\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"5ab5bc45-bc5c-4d90-b0c4-4c4666e9185d\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"8e8a9a97-a04e-44be-be5c-6b5d48594a9a\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"U\",\"V\",\"x\"],\"data\":{\"U\":{\"__ndarray__\":\"AAAAAAAAAAA266IID1OlPzbroggPU8U/nEi36XD91z8266IID1PlP8JHv77jqPA/nEi36XD99z8VvJyCl1MAQDbroggPUwVAsDHuBh/9CkDCR7++46gQQFoCKjaEKBRAnEi36XD9F0CMGmfZqSccQBW8nIKXUyBAuzCXNgC+IkA266IID1MlQIfrv/jDEihAsDHuBh/9KkCwvS0zIBIuQMJHv77jqDBAl1PwcgpeMkBaAio2hCg0QAZUbAhRCDZAnEi36XD9N0Ae4Ara4wc6QIwaZ9mpJzxA5/fL58JcPkAVvJyCl1NAQKzN1xh3g0FAuzCXNgC+QkA+5drbMgNEQDbroggPU0VAo0LvvJStRkCH67/4wxJIQOHlFLycgklAsDHuBh/9SkD0zkvZSoJMQLC9LTMgEk5A3/2TFJ+sT0DCR7++46hQQE+59rbMgFFAl1PwcgpeUkCaFqzynEBTQFoCKjaEKFRA0hZqPcAVVUAGVGwIUQhWQPS5MJc2AFdAnEi36XD9V0AAAAAAAABZQA==\",\"dtype\":\"float64\",\"shape\":[50]},\"V\":{\"__ndarray__\":\"AAAAAAAAAAA266IID1OlPzbroggPU8U/nEi36XD91z8266IID1PlP8JHv77jqPA/nEi36XD99z8VvJyCl1MAQDbroggPUwVAsDHuBh/9CkDCR7++46gQQFoCKjaEKBRAnEi36XD9F0CMGmfZqSccQBW8nIKXUyBAuzCXNgC+IkA266IID1MlQIfrv/jDEihAsDHuBh/9KkCwvS0zIBIuQMJHv77jqDBAl1PwcgpeMkBaAio2hCg0QAZUbAhRCDZAnEi36XD9N0Ae4Ara4wc6QIwaZ9mpJzxA5/fL58JcPkAVvJyCl1NAQKzN1xh3g0FAuzCXNgC+QkA+5drbMgNEQDbroggPU0VAo0LvvJStRkCH67/4wxJIQOHlFLycgklAsDHuBh/9SkD0zkvZSoJMQLC9LTMgEk5A3/2TFJ+sT0DCR7++46hQQE+59rbMgFFAl1PwcgpeUkCaFqzynEBTQFoCKjaEKFRA0hZqPcAVVUAGVGwIUQhWQPS5MJc2AFdAnEi36XD9V0AAAAAAAABZQA==\",\"dtype\":\"float64\",\"shape\":[50]},\"x\":{\"__ndarray__\":\"AAAAAAAAAACIxvrQWB/KP4jG+tBYH9o/5hS8nIKX4z+IxvrQWB/qPxW8nIKXU/A/5hS8nIKX8z+3bdu2bdv2P4jG+tBYH/o/WR8a60Nj/T8VvJyCl1MAQH5orA+N9QFA5hS8nIKXA0BOwcspeDkFQLdt27Zt2wZAIBrrQ2N9CECIxvrQWB8KQPByCl5OwQtAWR8a60NjDUDCyyl4OQUPQBW8nIKXUxBASZIkSZIkEUB+aKwPjfURQLI+NNaHxhJA5hS8nIKXE0Aa60NjfWgUQE7Byyl4ORVAg5dT8HIKFkC3bdu2bdsWQOtDY31orBdAIBrrQ2N9GEBU8HIKXk4ZQIjG+tBYHxpAvJyCl1PwGkDwcgpeTsEbQCVJkiRJkhxAWR8a60NjHUCN9aGxPjQeQMLLKXg5BR9A9qGxPjTWH0AVvJyCl1MgQC+n4OUUvCBASZIkSZIkIUBjfWisD40hQH5orA+N9SFAmFPwcgpeIkCyPjTWh8YiQMwpeDkFLyNA5hS8nIKXI0AAAAAAAAAkQA==\",\"dtype\":\"float64\",\"shape\":[50]}}},\"id\":\"fd3dc4e6-cf35-4e58-a320-20d3b7e57d53\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"children\":[{\"id\":\"e648073a-256c-48ea-b087-d0b11cbf4a92\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"id\":\"595345e1-2652-40f0-a8c4-a9b979e6877c\",\"subtype\":\"Figure\",\"type\":\"Plot\"}]},\"id\":\"c85b6c45-cd2c-4a1c-84f6-efce692ef370\",\"type\":\"Column\"},{\"attributes\":{\"plot\":null,\"text\":\"U\"},\"id\":\"032d483f-e795-4b09-a24b-34164979f00d\",\"type\":\"Title\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"0adb4b22-37a4-4a60-95ad-6f2d3ddf3c4d\",\"type\":\"PanTool\"},{\"id\":\"a1191f41-2c67-4700-a347-7b0709d50ecd\",\"type\":\"WheelZoomTool\"},{\"id\":\"db67ace2-34ee-4ade-88c5-92dd3b361617\",\"type\":\"BoxZoomTool\"},{\"id\":\"a71ecefc-cab0-4256-8af2-ec998a19fc96\",\"type\":\"SaveTool\"},{\"id\":\"9d92e6db-f272-4582-99d7-dfbdf7895ce5\",\"type\":\"ResetTool\"},{\"id\":\"108c8fd3-2595-4610-832f-e9dc5c9b96fb\",\"type\":\"HelpTool\"}]},\"id\":\"3b89e56b-4460-4e4e-8c32-9ed83e74d28d\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"e01fb60d-ff61-4f1b-ab67-adc24aa23b09\",\"type\":\"ToolEvents\"},{\"attributes\":{\"callback\":null,\"end\":10},\"id\":\"ca2d8f40-ede0-4565-8f7a-c33fd0c3d594\",\"type\":\"Range1d\"},{\"attributes\":{},\"id\":\"b82943d9-e133-4063-ba5b-9b7157240442\",\"type\":\"BasicTicker\"},{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"U\"}},\"id\":\"e8820e53-df24-4ed9-9e30-9b3c666fc139\",\"type\":\"Line\"},{\"attributes\":{\"formatter\":{\"id\":\"2e43d14e-fa04-413f-b830-43f7893b711e\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"e648073a-256c-48ea-b087-d0b11cbf4a92\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"b82943d9-e133-4063-ba5b-9b7157240442\",\"type\":\"BasicTicker\"}},\"id\":\"219ab5a1-a646-48af-ba34-219b78ad74cc\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null,\"end\":100},\"id\":\"78c2cb1b-ae95-46cd-b7f3-67798aa9a396\",\"type\":\"Range1d\"}],\"root_ids\":[\"c85b6c45-cd2c-4a1c-84f6-efce692ef370\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.5\"}};\n",
       "            var render_items = [{\"docid\":\"20f88a27-96bd-4fed-9c68-898b5137847a\",\"elementid\":\"77a4e18b-b83c-4954-b84c-2ec09ed157c0\",\"modelid\":\"c85b6c45-cd2c-4a1c-84f6-efce692ef370\",\"notebook_comms_target\":\"d03fd1f1-98f5-4ad9-8d06-95adf75270f7\"}];\n",
       "            \n",
       "            Bokeh.embed.embed_items(docs_json, render_items);\n",
       "          };\n",
       "          if (document.readyState != \"loading\") fn();\n",
       "          else document.addEventListener(\"DOMContentLoaded\", fn);\n",
       "        })();\n",
       "      },\n",
       "      function(Bokeh) {\n",
       "      }\n",
       "    ];\n",
       "  \n",
       "    function run_inline_js() {\n",
       "      \n",
       "      if ((window.Bokeh !== undefined) || (force === true)) {\n",
       "        for (var i = 0; i < inline_js.length; i++) {\n",
       "          inline_js[i](window.Bokeh);\n",
       "        }if (force === true) {\n",
       "          display_loaded();\n",
       "        }} else if (Date.now() < window._bokeh_timeout) {\n",
       "        setTimeout(run_inline_js, 100);\n",
       "      } else if (!window._bokeh_failed_load) {\n",
       "        console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "        window._bokeh_failed_load = true;\n",
       "      } else if (force !== true) {\n",
       "        var cell = $(document.getElementById(\"77a4e18b-b83c-4954-b84c-2ec09ed157c0\")).parents('.cell').data().cell;\n",
       "        cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "      }\n",
       "  \n",
       "    }\n",
       "  \n",
       "    if (window._bokeh_is_loading === 0) {\n",
       "      console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "      run_inline_js();\n",
       "    } else {\n",
       "      load_libs(js_urls, function() {\n",
       "        console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "        run_inline_js();\n",
       "      });\n",
       "    }\n",
       "  }(this));\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from triflow import Model, Simulation, displays\n",
    "import numpy as np\n",
    "\n",
    "model = Model([\"dxxU\", \"dxxV\"], [\"U\", \"V\"])\n",
    "parameters = dict(periodic=False)\n",
    "\n",
    "x = np.linspace(0, 10, 50, endpoint=True)\n",
    "U = x ** 2\n",
    "V = x ** 2\n",
    "\n",
    "fields = model.fields_template(x=x, U=U, V=V)\n",
    "simul = Simulation(model, 0, fields, parameters,\n",
    "                   dt=1, tmax=50, tol=1E-1)\n",
    "\n",
    "display = displays.bokeh_fields_update(simul, keys=[\"U\", \"V\"],\n",
    "                                       fig_kwargs={\"U\": \n",
    "                                                   {\"width\": 600,\n",
    "                                                    \"height\": 200,\n",
    "                                                    \"x_range\": (0, 10),\n",
    "                                                    \"y_range\": (0, 100)},\n",
    "                                                   \"V\": \n",
    "                                                   {\"width\": 600,\n",
    "                                                    \"height\": 200}},\n",
    "                                       line_kwargs={\"U\": \n",
    "                                                    {\"color\": \"darkred\",\n",
    "                                                     \"line_alpha\": .8}})\n",
    "\n",
    "for t, fields in simul:\n",
    "    display(t, fields)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### probe display\n",
    "\n",
    "The same way, this display give the possibility to plot in real time a probe, a 0D post process data.\n",
    "\n",
    "The probes are given as a dictionary with the name of the probe as key and a callable as value.\n",
    "This callable take `(t, fields)` as argument and return a scalar. Like the fields display, it is possible to customize the bokeh figure and line via two dictionnary."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2017-05-24T14:54:20.712906Z",
     "start_time": "2017-05-24T14:54:15.003525Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <a href=\"http://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
       "        <span id=\"32996f66-b44e-412e-a10e-e3411016da6a\">Loading BokehJS ...</span>\n",
       "    </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "(function(global) {\n",
       "  function now() {\n",
       "    return new Date();\n",
       "  }\n",
       "\n",
       "  var force = true;\n",
       "\n",
       "  if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "    window._bokeh_onload_callbacks = [];\n",
       "    window._bokeh_is_loading = undefined;\n",
       "  }\n",
       "\n",
       "\n",
       "  \n",
       "  if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "    window._bokeh_timeout = Date.now() + 5000;\n",
       "    window._bokeh_failed_load = false;\n",
       "  }\n",
       "\n",
       "  var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "     \"<div style='background-color: #fdd'>\\n\"+\n",
       "     \"<p>\\n\"+\n",
       "     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "     \"</p>\\n\"+\n",
       "     \"<ul>\\n\"+\n",
       "     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "     \"</ul>\\n\"+\n",
       "     \"<code>\\n\"+\n",
       "     \"from bokeh.resources import INLINE\\n\"+\n",
       "     \"output_notebook(resources=INLINE)\\n\"+\n",
       "     \"</code>\\n\"+\n",
       "     \"</div>\"}};\n",
       "\n",
       "  function display_loaded() {\n",
       "    if (window.Bokeh !== undefined) {\n",
       "      var el = document.getElementById(\"32996f66-b44e-412e-a10e-e3411016da6a\");\n",
       "      el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n",
       "    } else if (Date.now() < window._bokeh_timeout) {\n",
       "      setTimeout(display_loaded, 100)\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function run_callbacks() {\n",
       "    window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "    delete window._bokeh_onload_callbacks\n",
       "    console.info(\"Bokeh: all callbacks have finished\");\n",
       "  }\n",
       "\n",
       "  function load_libs(js_urls, callback) {\n",
       "    window._bokeh_onload_callbacks.push(callback);\n",
       "    if (window._bokeh_is_loading > 0) {\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "      return null;\n",
       "    }\n",
       "    if (js_urls == null || js_urls.length === 0) {\n",
       "      run_callbacks();\n",
       "      return null;\n",
       "    }\n",
       "    console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "    window._bokeh_is_loading = js_urls.length;\n",
       "    for (var i = 0; i < js_urls.length; i++) {\n",
       "      var url = js_urls[i];\n",
       "      var s = document.createElement('script');\n",
       "      s.src = url;\n",
       "      s.async = false;\n",
       "      s.onreadystatechange = s.onload = function() {\n",
       "        window._bokeh_is_loading--;\n",
       "        if (window._bokeh_is_loading === 0) {\n",
       "          console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "          run_callbacks()\n",
       "        }\n",
       "      };\n",
       "      s.onerror = function() {\n",
       "        console.warn(\"failed to load library \" + url);\n",
       "      };\n",
       "      console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "      document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "  };var element = document.getElementById(\"32996f66-b44e-412e-a10e-e3411016da6a\");\n",
       "  if (element == null) {\n",
       "    console.log(\"Bokeh: ERROR: autoload.js configured with elementid '32996f66-b44e-412e-a10e-e3411016da6a' but no matching script tag was found. \")\n",
       "    return false;\n",
       "  }\n",
       "\n",
       "  var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.js\"];\n",
       "\n",
       "  var inline_js = [\n",
       "    function(Bokeh) {\n",
       "      Bokeh.set_log_level(\"info\");\n",
       "    },\n",
       "    \n",
       "    function(Bokeh) {\n",
       "      \n",
       "    },\n",
       "    \n",
       "    function(Bokeh) {\n",
       "      \n",
       "      document.getElementById(\"32996f66-b44e-412e-a10e-e3411016da6a\").textContent = \"BokehJS is loading...\";\n",
       "    },\n",
       "    function(Bokeh) {\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.css\");\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.css\");\n",
       "    }\n",
       "  ];\n",
       "\n",
       "  function run_inline_js() {\n",
       "    \n",
       "    if ((window.Bokeh !== undefined) || (force === true)) {\n",
       "      for (var i = 0; i < inline_js.length; i++) {\n",
       "        inline_js[i](window.Bokeh);\n",
       "      }if (force === true) {\n",
       "        display_loaded();\n",
       "      }} else if (Date.now() < window._bokeh_timeout) {\n",
       "      setTimeout(run_inline_js, 100);\n",
       "    } else if (!window._bokeh_failed_load) {\n",
       "      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "      window._bokeh_failed_load = true;\n",
       "    } else if (force !== true) {\n",
       "      var cell = $(document.getElementById(\"32996f66-b44e-412e-a10e-e3411016da6a\")).parents('.cell').data().cell;\n",
       "      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "    }\n",
       "\n",
       "  }\n",
       "\n",
       "  if (window._bokeh_is_loading === 0) {\n",
       "    console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "    run_inline_js();\n",
       "  } else {\n",
       "    load_libs(js_urls, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "      run_inline_js();\n",
       "    });\n",
       "  }\n",
       "}(this));"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <div class=\"bk-plotdiv\" id=\"41e18910-c790-4d3b-9671-534c2e4e3a89\"></div>\n",
       "    </div>\n",
       "<script type=\"text/javascript\">\n",
       "  \n",
       "  (function(global) {\n",
       "    function now() {\n",
       "      return new Date();\n",
       "    }\n",
       "  \n",
       "    var force = false;\n",
       "  \n",
       "    if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "      window._bokeh_onload_callbacks = [];\n",
       "      window._bokeh_is_loading = undefined;\n",
       "    }\n",
       "  \n",
       "  \n",
       "    \n",
       "    if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "      window._bokeh_timeout = Date.now() + 0;\n",
       "      window._bokeh_failed_load = false;\n",
       "    }\n",
       "  \n",
       "    var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "       \"<div style='background-color: #fdd'>\\n\"+\n",
       "       \"<p>\\n\"+\n",
       "       \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "       \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "       \"</p>\\n\"+\n",
       "       \"<ul>\\n\"+\n",
       "       \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "       \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "       \"</ul>\\n\"+\n",
       "       \"<code>\\n\"+\n",
       "       \"from bokeh.resources import INLINE\\n\"+\n",
       "       \"output_notebook(resources=INLINE)\\n\"+\n",
       "       \"</code>\\n\"+\n",
       "       \"</div>\"}};\n",
       "  \n",
       "    function display_loaded() {\n",
       "      if (window.Bokeh !== undefined) {\n",
       "        var el = document.getElementById(\"41e18910-c790-4d3b-9671-534c2e4e3a89\");\n",
       "        el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n",
       "      } else if (Date.now() < window._bokeh_timeout) {\n",
       "        setTimeout(display_loaded, 100)\n",
       "      }\n",
       "    }if ((window.Jupyter !== undefined) && Jupyter.notebook.kernel) {\n",
       "      comm_manager = Jupyter.notebook.kernel.comm_manager\n",
       "      comm_manager.register_target(\"c38c1724-3060-43bf-b2c9-8bfa261e8087\", function () {});\n",
       "    }\n",
       "  \n",
       "    function run_callbacks() {\n",
       "      window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "      delete window._bokeh_onload_callbacks\n",
       "      console.info(\"Bokeh: all callbacks have finished\");\n",
       "    }\n",
       "  \n",
       "    function load_libs(js_urls, callback) {\n",
       "      window._bokeh_onload_callbacks.push(callback);\n",
       "      if (window._bokeh_is_loading > 0) {\n",
       "        console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "        return null;\n",
       "      }\n",
       "      if (js_urls == null || js_urls.length === 0) {\n",
       "        run_callbacks();\n",
       "        return null;\n",
       "      }\n",
       "      console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "      window._bokeh_is_loading = js_urls.length;\n",
       "      for (var i = 0; i < js_urls.length; i++) {\n",
       "        var url = js_urls[i];\n",
       "        var s = document.createElement('script');\n",
       "        s.src = url;\n",
       "        s.async = false;\n",
       "        s.onreadystatechange = s.onload = function() {\n",
       "          window._bokeh_is_loading--;\n",
       "          if (window._bokeh_is_loading === 0) {\n",
       "            console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "            run_callbacks()\n",
       "          }\n",
       "        };\n",
       "        s.onerror = function() {\n",
       "          console.warn(\"failed to load library \" + url);\n",
       "        };\n",
       "        console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "        document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "      }\n",
       "    };var element = document.getElementById(\"41e18910-c790-4d3b-9671-534c2e4e3a89\");\n",
       "    if (element == null) {\n",
       "      console.log(\"Bokeh: ERROR: autoload.js configured with elementid '41e18910-c790-4d3b-9671-534c2e4e3a89' but no matching script tag was found. \")\n",
       "      return false;\n",
       "    }\n",
       "  \n",
       "    var js_urls = [];\n",
       "  \n",
       "    var inline_js = [\n",
       "      function(Bokeh) {\n",
       "        (function() {\n",
       "          var fn = function() {\n",
       "            var docs_json = {\"a185c7ae-2743-4265-b246-db0e58b0bdd0\":{\"roots\":{\"references\":[{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"4aaa4301-b9b6-4e51-9cb6-9485bd29e60d\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"plot\":{\"id\":\"a3e3cbde-08af-416a-a362-e067a73c92ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"5141beeb-db2b-4555-bd05-528bdd286cbc\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"overlay\":{\"id\":\"4aaa4301-b9b6-4e51-9cb6-9485bd29e60d\",\"type\":\"BoxAnnotation\"},\"plot\":{\"id\":\"a3e3cbde-08af-416a-a362-e067a73c92ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"a0d354a2-b337-46f1-8831-1cf2393b8830\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"plot\":{\"id\":\"a3e3cbde-08af-416a-a362-e067a73c92ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"ed2330a7-64ed-414b-b2e8-e56825e3d88d\",\"type\":\"SaveTool\"},{\"attributes\":{\"plot\":{\"id\":\"a3e3cbde-08af-416a-a362-e067a73c92ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"b15ba09a-eef0-456c-a5ef-72afcab05d7a\",\"type\":\"ResetTool\"},{\"attributes\":{\"plot\":{\"id\":\"a3e3cbde-08af-416a-a362-e067a73c92ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"1e7db2ac-72ae-409d-a128-fc831f083ed7\",\"type\":\"HelpTool\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"t\",\"std\"],\"data\":{\"std\":[30.45419424223658],\"t\":[0]}},\"id\":\"080d11a3-cac4-4eba-9c6c-b7eeb55e63a6\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"615b1761-af09-4aa2-8f75-ecf6d32e447e\",\"type\":\"ToolEvents\"},{\"attributes\":{\"callback\":null},\"id\":\"1da7e735-eb3c-4917-9ce9-7218a925fea4\",\"type\":\"DataRange1d\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"a2bebf45-6933-454d-b3d9-7b9388312647\",\"type\":\"PanTool\"},{\"id\":\"5141beeb-db2b-4555-bd05-528bdd286cbc\",\"type\":\"WheelZoomTool\"},{\"id\":\"a0d354a2-b337-46f1-8831-1cf2393b8830\",\"type\":\"BoxZoomTool\"},{\"id\":\"ed2330a7-64ed-414b-b2e8-e56825e3d88d\",\"type\":\"SaveTool\"},{\"id\":\"b15ba09a-eef0-456c-a5ef-72afcab05d7a\",\"type\":\"ResetTool\"},{\"id\":\"1e7db2ac-72ae-409d-a128-fc831f083ed7\",\"type\":\"HelpTool\"}]},\"id\":\"ff689a4c-6b8c-41eb-b591-e6da00e6f5da\",\"type\":\"Toolbar\"},{\"attributes\":{\"children\":[{\"id\":\"a3e3cbde-08af-416a-a362-e067a73c92ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"}]},\"id\":\"3976a794-9788-4e06-bf9b-1e9031f93f96\",\"type\":\"Column\"},{\"attributes\":{\"plot\":null,\"text\":\"std\"},\"id\":\"95d22be9-f238-4d4e-b7f2-fbeb2aef6b55\",\"type\":\"Title\"},{\"attributes\":{\"below\":[{\"id\":\"5c738595-248d-4ce2-aea3-65b34b829be7\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"6485ab7d-6c0b-4bb9-a1b2-d12f2974ef4a\",\"type\":\"LinearAxis\"}],\"plot_height\":200,\"renderers\":[{\"id\":\"5c738595-248d-4ce2-aea3-65b34b829be7\",\"type\":\"LinearAxis\"},{\"id\":\"65708db8-b8e3-449b-a21f-3c382c00f7f1\",\"type\":\"Grid\"},{\"id\":\"6485ab7d-6c0b-4bb9-a1b2-d12f2974ef4a\",\"type\":\"LinearAxis\"},{\"id\":\"d80e255f-b0fa-4f96-9d25-7d4881c0aa03\",\"type\":\"Grid\"},{\"id\":\"4aaa4301-b9b6-4e51-9cb6-9485bd29e60d\",\"type\":\"BoxAnnotation\"},{\"id\":\"3d1434d4-4454-4046-94c0-0ef849d6bbc5\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"95d22be9-f238-4d4e-b7f2-fbeb2aef6b55\",\"type\":\"Title\"},\"tool_events\":{\"id\":\"615b1761-af09-4aa2-8f75-ecf6d32e447e\",\"type\":\"ToolEvents\"},\"toolbar\":{\"id\":\"ff689a4c-6b8c-41eb-b591-e6da00e6f5da\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"1da7e735-eb3c-4917-9ce9-7218a925fea4\",\"type\":\"DataRange1d\"},\"y_range\":{\"id\":\"b2804bf0-069d-4e4a-bb06-18a3f062d3fa\",\"type\":\"DataRange1d\"}},\"id\":\"a3e3cbde-08af-416a-a362-e067a73c92ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"t\"},\"y\":{\"field\":\"std\"}},\"id\":\"f6a80d62-8a02-4e22-94a5-e3425aed43d9\",\"type\":\"Line\"},{\"attributes\":{\"formatter\":{\"id\":\"a62de500-17cf-463b-9d92-6292ad1dbae1\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"a3e3cbde-08af-416a-a362-e067a73c92ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"70604062-9499-40d8-9a0f-17d327c88e7d\",\"type\":\"BasicTicker\"}},\"id\":\"5c738595-248d-4ce2-aea3-65b34b829be7\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null},\"id\":\"b2804bf0-069d-4e4a-bb06-18a3f062d3fa\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"70604062-9499-40d8-9a0f-17d327c88e7d\",\"type\":\"BasicTicker\"},{\"attributes\":{\"plot\":{\"id\":\"a3e3cbde-08af-416a-a362-e067a73c92ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"70604062-9499-40d8-9a0f-17d327c88e7d\",\"type\":\"BasicTicker\"}},\"id\":\"65708db8-b8e3-449b-a21f-3c382c00f7f1\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"1f11a8cb-c7df-45bb-b7f0-9916705ae5cb\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"a3e3cbde-08af-416a-a362-e067a73c92ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"ac3c7b88-e197-4471-a00a-a46fbbbc19a7\",\"type\":\"BasicTicker\"}},\"id\":\"6485ab7d-6c0b-4bb9-a1b2-d12f2974ef4a\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"ac3c7b88-e197-4471-a00a-a46fbbbc19a7\",\"type\":\"BasicTicker\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"a3e3cbde-08af-416a-a362-e067a73c92ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"ac3c7b88-e197-4471-a00a-a46fbbbc19a7\",\"type\":\"BasicTicker\"}},\"id\":\"d80e255f-b0fa-4f96-9d25-7d4881c0aa03\",\"type\":\"Grid\"},{\"attributes\":{\"data_source\":{\"id\":\"080d11a3-cac4-4eba-9c6c-b7eeb55e63a6\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"3b660c67-b70e-4d5f-9f80-2b224898a3ca\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"f6a80d62-8a02-4e22-94a5-e3425aed43d9\",\"type\":\"Line\"},\"selection_glyph\":null},\"id\":\"3d1434d4-4454-4046-94c0-0ef849d6bbc5\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"t\"},\"y\":{\"field\":\"std\"}},\"id\":\"3b660c67-b70e-4d5f-9f80-2b224898a3ca\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1f11a8cb-c7df-45bb-b7f0-9916705ae5cb\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"a62de500-17cf-463b-9d92-6292ad1dbae1\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"plot\":{\"id\":\"a3e3cbde-08af-416a-a362-e067a73c92ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"a2bebf45-6933-454d-b3d9-7b9388312647\",\"type\":\"PanTool\"}],\"root_ids\":[\"3976a794-9788-4e06-bf9b-1e9031f93f96\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.5\"}};\n",
       "            var render_items = [{\"docid\":\"a185c7ae-2743-4265-b246-db0e58b0bdd0\",\"elementid\":\"41e18910-c790-4d3b-9671-534c2e4e3a89\",\"modelid\":\"3976a794-9788-4e06-bf9b-1e9031f93f96\",\"notebook_comms_target\":\"c38c1724-3060-43bf-b2c9-8bfa261e8087\"}];\n",
       "            \n",
       "            Bokeh.embed.embed_items(docs_json, render_items);\n",
       "          };\n",
       "          if (document.readyState != \"loading\") fn();\n",
       "          else document.addEventListener(\"DOMContentLoaded\", fn);\n",
       "        })();\n",
       "      },\n",
       "      function(Bokeh) {\n",
       "      }\n",
       "    ];\n",
       "  \n",
       "    function run_inline_js() {\n",
       "      \n",
       "      if ((window.Bokeh !== undefined) || (force === true)) {\n",
       "        for (var i = 0; i < inline_js.length; i++) {\n",
       "          inline_js[i](window.Bokeh);\n",
       "        }if (force === true) {\n",
       "          display_loaded();\n",
       "        }} else if (Date.now() < window._bokeh_timeout) {\n",
       "        setTimeout(run_inline_js, 100);\n",
       "      } else if (!window._bokeh_failed_load) {\n",
       "        console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "        window._bokeh_failed_load = true;\n",
       "      } else if (force !== true) {\n",
       "        var cell = $(document.getElementById(\"41e18910-c790-4d3b-9671-534c2e4e3a89\")).parents('.cell').data().cell;\n",
       "        cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "      }\n",
       "  \n",
       "    }\n",
       "  \n",
       "    if (window._bokeh_is_loading === 0) {\n",
       "      console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "      run_inline_js();\n",
       "    } else {\n",
       "      load_libs(js_urls, function() {\n",
       "        console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "        run_inline_js();\n",
       "      });\n",
       "    }\n",
       "  }(this));\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from triflow import Model, Simulation, displays\n",
    "import numpy as np\n",
    "\n",
    "model = Model(\"dxxU\", \"U\")\n",
    "parameters = dict(periodic=False)\n",
    "\n",
    "x = np.linspace(0, 10, 50, endpoint=True)\n",
    "U = x ** 2\n",
    "\n",
    "fields = model.fields_template(x=x, U=U)\n",
    "simul = Simulation(model, 0, fields, parameters,\n",
    "                   dt=1, tmax=50, tol=1E-1)\n",
    "\n",
    "def std_probe(t, fields):\n",
    "    return np.std(fields.U)\n",
    "\n",
    "display = displays.bokeh_probes_update(simul,\n",
    "                                       {\"std\": std_probe},\n",
    "                                       fig_kwargs={'std': {\"width\": 600,\n",
    "                                                           \"height\": 200}})\n",
    "\n",
    "for t, fields in simul:\n",
    "    display(t, fields)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  },
  "toc": {
   "colors": {
    "hover_highlight": "#DAA520",
    "running_highlight": "#FF0000",
    "selected_highlight": "#FFD700"
   },
   "moveMenuLeft": true,
   "nav_menu": {
    "height": "123px",
    "width": "252px"
   },
   "navigate_menu": true,
   "number_sections": true,
   "sideBar": true,
   "threshold": 4,
   "toc_cell": false,
   "toc_section_display": "block",
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
