{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The notebook is available via [nbviewer](http://nbviewer.jupyter.org/github/locie/triflow/blob/master/examples/notebooks/displays.ipynb), and we recommend to download and launch it as it contains interactive and jupyter-specific display."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Displays"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2017-05-24T15:05:18.000349Z",
     "start_time": "2017-05-24T15:05:15.737286Z"
    }
   },
   "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-24T15:05:18.007850Z",
     "start_time": "2017-05-24T15:05:18.002361Z"
    }
   },
   "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-24T15:05:18.043315Z",
     "start_time": "2017-05-24T15:05:18.009495Z"
    }
   },
   "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-24T15:05:20.179311Z",
     "start_time": "2017-05-24T15:05:18.044832Z"
    }
   },
   "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-24T15:05:22.400955Z",
     "start_time": "2017-05-24T15:05:20.180966Z"
    }
   },
   "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-24T15:05:27.332053Z",
     "start_time": "2017-05-24T15:05:22.403010Z"
    },
    "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=\"351e5754-9124-4b27-b717-79d6573fd193\">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(\"351e5754-9124-4b27-b717-79d6573fd193\");\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(\"351e5754-9124-4b27-b717-79d6573fd193\");\n",
       "  if (element == null) {\n",
       "    console.log(\"Bokeh: ERROR: autoload.js configured with elementid '351e5754-9124-4b27-b717-79d6573fd193' 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(\"351e5754-9124-4b27-b717-79d6573fd193\").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(\"351e5754-9124-4b27-b717-79d6573fd193\")).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=\"09f90f2c-7c60-4a7a-8288-242a8d516cdc\"></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(\"09f90f2c-7c60-4a7a-8288-242a8d516cdc\");\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(\"99b21966-53a1-4698-8940-b8649d2b7531\", 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(\"09f90f2c-7c60-4a7a-8288-242a8d516cdc\");\n",
       "    if (element == null) {\n",
       "      console.log(\"Bokeh: ERROR: autoload.js configured with elementid '09f90f2c-7c60-4a7a-8288-242a8d516cdc' 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 = {\"d68ec165-a2f5-463e-ba5e-b5edc27cc049\":{\"roots\":{\"references\":[{\"attributes\":{\"formatter\":{\"id\":\"31d9e19b-89c0-473c-81e3-987540bae00a\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"8779039a-b7f2-4617-a81f-113f618dbbab\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"d4e1f5b6-493c-433a-b634-d65fb52951f2\",\"type\":\"BasicTicker\"}},\"id\":\"913bc49c-6109-4308-af51-30b50bea1179\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"d4e1f5b6-493c-433a-b634-d65fb52951f2\",\"type\":\"BasicTicker\"},{\"attributes\":{\"plot\":{\"id\":\"8779039a-b7f2-4617-a81f-113f618dbbab\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"d4e1f5b6-493c-433a-b634-d65fb52951f2\",\"type\":\"BasicTicker\"}},\"id\":\"d65336f8-e6f3-4bf7-a96f-d3e78a339822\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"ff2bc6e1-28d1-4be2-aebd-e18fbb0afdd4\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"8779039a-b7f2-4617-a81f-113f618dbbab\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"c0a4ede1-859e-4dcf-8bd1-7cd7f619cb5b\",\"type\":\"BasicTicker\"}},\"id\":\"c55e302b-1a62-4bf4-8096-ac55ca179be3\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"c0a4ede1-859e-4dcf-8bd1-7cd7f619cb5b\",\"type\":\"BasicTicker\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"8779039a-b7f2-4617-a81f-113f618dbbab\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"c0a4ede1-859e-4dcf-8bd1-7cd7f619cb5b\",\"type\":\"BasicTicker\"}},\"id\":\"1c7b7d27-1224-4c61-9d79-b99050363592\",\"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\":\"940f4c85-27d5-4149-9629-3734ab4a5f52\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"below\":[{\"id\":\"913bc49c-6109-4308-af51-30b50bea1179\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"c55e302b-1a62-4bf4-8096-ac55ca179be3\",\"type\":\"LinearAxis\"}],\"plot_height\":200,\"renderers\":[{\"id\":\"913bc49c-6109-4308-af51-30b50bea1179\",\"type\":\"LinearAxis\"},{\"id\":\"d65336f8-e6f3-4bf7-a96f-d3e78a339822\",\"type\":\"Grid\"},{\"id\":\"c55e302b-1a62-4bf4-8096-ac55ca179be3\",\"type\":\"LinearAxis\"},{\"id\":\"1c7b7d27-1224-4c61-9d79-b99050363592\",\"type\":\"Grid\"},{\"id\":\"940f4c85-27d5-4149-9629-3734ab4a5f52\",\"type\":\"BoxAnnotation\"},{\"id\":\"96e06174-61e1-4ce0-a400-ee44943bb50e\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"d4212891-9116-40e7-858a-e883e058da4b\",\"type\":\"Title\"},\"tool_events\":{\"id\":\"47698b4e-42d4-459a-9b46-02c65d623951\",\"type\":\"ToolEvents\"},\"toolbar\":{\"id\":\"162d00a8-b1b3-4bc2-8c2c-35e023b54600\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"e70814e7-5d19-46cb-b58f-409ecc7655f5\",\"type\":\"Range1d\"},\"y_range\":{\"id\":\"977b124f-0179-4414-9fd0-b53b3f7b291e\",\"type\":\"Range1d\"}},\"id\":\"8779039a-b7f2-4617-a81f-113f618dbbab\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"plot\":{\"id\":\"8779039a-b7f2-4617-a81f-113f618dbbab\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"858978ea-aa22-4bf8-bb8e-e628e4bdb05a\",\"type\":\"PanTool\"},{\"attributes\":{\"data_source\":{\"id\":\"50551f29-41df-4a2a-9b99-4d0f0bde9760\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"2fb8b7dd-446a-4930-a8b6-86913f263147\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"af05ff4b-878b-4043-922a-f8b9ac1214de\",\"type\":\"Line\"},\"selection_glyph\":null},\"id\":\"96e06174-61e1-4ce0-a400-ee44943bb50e\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"line_alpha\":{\"value\":0.8},\"line_color\":{\"value\":\"darkred\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"U\"}},\"id\":\"2fb8b7dd-446a-4930-a8b6-86913f263147\",\"type\":\"Line\"},{\"attributes\":{\"plot\":{\"id\":\"8779039a-b7f2-4617-a81f-113f618dbbab\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"0ad780cf-f45f-40b8-a5ce-1674035aeb69\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"overlay\":{\"id\":\"940f4c85-27d5-4149-9629-3734ab4a5f52\",\"type\":\"BoxAnnotation\"},\"plot\":{\"id\":\"8779039a-b7f2-4617-a81f-113f618dbbab\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"5a5796cd-2fc3-41c8-864a-3a3b175c126f\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"31d9e19b-89c0-473c-81e3-987540bae00a\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"plot\":{\"id\":\"8779039a-b7f2-4617-a81f-113f618dbbab\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"1bc1b890-10ae-4724-ba95-f72197399c77\",\"type\":\"SaveTool\"},{\"attributes\":{\"plot\":{\"id\":\"8779039a-b7f2-4617-a81f-113f618dbbab\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"3607ceaf-8c71-4f4f-b43d-9e4c97636ed2\",\"type\":\"ResetTool\"},{\"attributes\":{\"plot\":{\"id\":\"8779039a-b7f2-4617-a81f-113f618dbbab\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"5e54059f-4f80-4f1b-8046-b033837085f5\",\"type\":\"HelpTool\"},{\"attributes\":{\"data_source\":{\"id\":\"50551f29-41df-4a2a-9b99-4d0f0bde9760\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"9ccb294d-8da6-4080-a473-9a6d04185fac\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"cf5f4633-95a1-4f10-b7df-bd647822dc17\",\"type\":\"Line\"},\"selection_glyph\":null},\"id\":\"54b60126-b86f-403b-86b6-b002453c7bb4\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"plot\":null,\"text\":\"V\"},\"id\":\"c530fc42-06b2-43df-8ced-c364eb01e2fa\",\"type\":\"Title\"},{\"attributes\":{\"below\":[{\"id\":\"2d674846-39e4-4184-b1bd-2f59ee94c7cf\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"b1fb45a8-3ffa-414c-9eb5-7a6c85c6db7f\",\"type\":\"LinearAxis\"}],\"plot_height\":200,\"renderers\":[{\"id\":\"2d674846-39e4-4184-b1bd-2f59ee94c7cf\",\"type\":\"LinearAxis\"},{\"id\":\"7cb382c1-d2a7-44b4-bdbd-ad8315aa9f45\",\"type\":\"Grid\"},{\"id\":\"b1fb45a8-3ffa-414c-9eb5-7a6c85c6db7f\",\"type\":\"LinearAxis\"},{\"id\":\"5f4ffe65-74cd-49a8-97ad-d1b8b557da6b\",\"type\":\"Grid\"},{\"id\":\"215cf61b-6985-46a9-8681-5782f286b91c\",\"type\":\"BoxAnnotation\"},{\"id\":\"54b60126-b86f-403b-86b6-b002453c7bb4\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"c530fc42-06b2-43df-8ced-c364eb01e2fa\",\"type\":\"Title\"},\"tool_events\":{\"id\":\"699212ea-acd4-4bec-bc4a-3636a8ea115c\",\"type\":\"ToolEvents\"},\"toolbar\":{\"id\":\"1bcd5278-cf6b-4eba-8c26-74e98a9a4273\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"cf0e21c0-f161-4055-894b-34265b71273f\",\"type\":\"DataRange1d\"},\"y_range\":{\"id\":\"87958242-b181-48c3-9aca-9df907761147\",\"type\":\"DataRange1d\"}},\"id\":\"3e9ef460-d6b7-4daa-8777-ccf3884b127f\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"callback\":null},\"id\":\"cf0e21c0-f161-4055-894b-34265b71273f\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"699212ea-acd4-4bec-bc4a-3636a8ea115c\",\"type\":\"ToolEvents\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"cf467efb-e4d3-4660-ac24-defca50372c3\",\"type\":\"PanTool\"},{\"id\":\"a0d8603c-94f9-41a7-810f-db9b566ed6b0\",\"type\":\"WheelZoomTool\"},{\"id\":\"28ccdba5-bf87-460e-bb63-9ea684cd408e\",\"type\":\"BoxZoomTool\"},{\"id\":\"40254ddb-728f-43c6-809a-f62689fd96cb\",\"type\":\"SaveTool\"},{\"id\":\"c4e2e39f-b45a-4e03-871b-2a9cbc9f56e1\",\"type\":\"ResetTool\"},{\"id\":\"d790569d-2463-4143-a00c-1cb8cea88a0a\",\"type\":\"HelpTool\"}]},\"id\":\"1bcd5278-cf6b-4eba-8c26-74e98a9a4273\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"208888c2-5aa0-49a0-bfcb-3292334f8df0\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"V\"}},\"id\":\"9ccb294d-8da6-4080-a473-9a6d04185fac\",\"type\":\"Line\"},{\"attributes\":{\"formatter\":{\"id\":\"208888c2-5aa0-49a0-bfcb-3292334f8df0\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"3e9ef460-d6b7-4daa-8777-ccf3884b127f\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"ea967fff-1968-4a6b-a6bd-df43af9b00a0\",\"type\":\"BasicTicker\"}},\"id\":\"2d674846-39e4-4184-b1bd-2f59ee94c7cf\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null},\"id\":\"87958242-b181-48c3-9aca-9df907761147\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"ea967fff-1968-4a6b-a6bd-df43af9b00a0\",\"type\":\"BasicTicker\"},{\"attributes\":{\"plot\":{\"id\":\"3e9ef460-d6b7-4daa-8777-ccf3884b127f\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"ea967fff-1968-4a6b-a6bd-df43af9b00a0\",\"type\":\"BasicTicker\"}},\"id\":\"7cb382c1-d2a7-44b4-bdbd-ad8315aa9f45\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"ff2bc6e1-28d1-4be2-aebd-e18fbb0afdd4\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"formatter\":{\"id\":\"a05243c3-5166-4528-ab42-4a94a977bc42\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"3e9ef460-d6b7-4daa-8777-ccf3884b127f\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"801da0a5-78ed-48d2-84a3-b68e51e6bf84\",\"type\":\"BasicTicker\"}},\"id\":\"b1fb45a8-3ffa-414c-9eb5-7a6c85c6db7f\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"801da0a5-78ed-48d2-84a3-b68e51e6bf84\",\"type\":\"BasicTicker\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"3e9ef460-d6b7-4daa-8777-ccf3884b127f\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"801da0a5-78ed-48d2-84a3-b68e51e6bf84\",\"type\":\"BasicTicker\"}},\"id\":\"5f4ffe65-74cd-49a8-97ad-d1b8b557da6b\",\"type\":\"Grid\"},{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"V\"}},\"id\":\"cf5f4633-95a1-4f10-b7df-bd647822dc17\",\"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\":\"215cf61b-6985-46a9-8681-5782f286b91c\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"plot\":{\"id\":\"3e9ef460-d6b7-4daa-8777-ccf3884b127f\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"cf467efb-e4d3-4660-ac24-defca50372c3\",\"type\":\"PanTool\"},{\"attributes\":{\"plot\":{\"id\":\"3e9ef460-d6b7-4daa-8777-ccf3884b127f\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"a0d8603c-94f9-41a7-810f-db9b566ed6b0\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"overlay\":{\"id\":\"215cf61b-6985-46a9-8681-5782f286b91c\",\"type\":\"BoxAnnotation\"},\"plot\":{\"id\":\"3e9ef460-d6b7-4daa-8777-ccf3884b127f\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"28ccdba5-bf87-460e-bb63-9ea684cd408e\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"plot\":{\"id\":\"3e9ef460-d6b7-4daa-8777-ccf3884b127f\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"40254ddb-728f-43c6-809a-f62689fd96cb\",\"type\":\"SaveTool\"},{\"attributes\":{\"plot\":{\"id\":\"3e9ef460-d6b7-4daa-8777-ccf3884b127f\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"c4e2e39f-b45a-4e03-871b-2a9cbc9f56e1\",\"type\":\"ResetTool\"},{\"attributes\":{\"plot\":{\"id\":\"3e9ef460-d6b7-4daa-8777-ccf3884b127f\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"d790569d-2463-4143-a00c-1cb8cea88a0a\",\"type\":\"HelpTool\"},{\"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\":\"50551f29-41df-4a2a-9b99-4d0f0bde9760\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"a05243c3-5166-4528-ab42-4a94a977bc42\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"children\":[{\"id\":\"8779039a-b7f2-4617-a81f-113f618dbbab\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"id\":\"3e9ef460-d6b7-4daa-8777-ccf3884b127f\",\"subtype\":\"Figure\",\"type\":\"Plot\"}]},\"id\":\"b80783b1-7beb-4a1d-b7cd-05942d084279\",\"type\":\"Column\"},{\"attributes\":{\"plot\":null,\"text\":\"U\"},\"id\":\"d4212891-9116-40e7-858a-e883e058da4b\",\"type\":\"Title\"},{\"attributes\":{\"callback\":null,\"end\":10},\"id\":\"e70814e7-5d19-46cb-b58f-409ecc7655f5\",\"type\":\"Range1d\"},{\"attributes\":{},\"id\":\"47698b4e-42d4-459a-9b46-02c65d623951\",\"type\":\"ToolEvents\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"858978ea-aa22-4bf8-bb8e-e628e4bdb05a\",\"type\":\"PanTool\"},{\"id\":\"0ad780cf-f45f-40b8-a5ce-1674035aeb69\",\"type\":\"WheelZoomTool\"},{\"id\":\"5a5796cd-2fc3-41c8-864a-3a3b175c126f\",\"type\":\"BoxZoomTool\"},{\"id\":\"1bc1b890-10ae-4724-ba95-f72197399c77\",\"type\":\"SaveTool\"},{\"id\":\"3607ceaf-8c71-4f4f-b43d-9e4c97636ed2\",\"type\":\"ResetTool\"},{\"id\":\"5e54059f-4f80-4f1b-8046-b033837085f5\",\"type\":\"HelpTool\"}]},\"id\":\"162d00a8-b1b3-4bc2-8c2c-35e023b54600\",\"type\":\"Toolbar\"},{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"U\"}},\"id\":\"af05ff4b-878b-4043-922a-f8b9ac1214de\",\"type\":\"Line\"},{\"attributes\":{\"callback\":null,\"end\":100},\"id\":\"977b124f-0179-4414-9fd0-b53b3f7b291e\",\"type\":\"Range1d\"}],\"root_ids\":[\"b80783b1-7beb-4a1d-b7cd-05942d084279\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.5\"}};\n",
       "            var render_items = [{\"docid\":\"d68ec165-a2f5-463e-ba5e-b5edc27cc049\",\"elementid\":\"09f90f2c-7c60-4a7a-8288-242a8d516cdc\",\"modelid\":\"b80783b1-7beb-4a1d-b7cd-05942d084279\",\"notebook_comms_target\":\"99b21966-53a1-4698-8940-b8649d2b7531\"}];\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(\"09f90f2c-7c60-4a7a-8288-242a8d516cdc\")).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-24T15:05:31.858689Z",
     "start_time": "2017-05-24T15:05:27.333503Z"
    }
   },
   "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=\"ab45356c-9da8-4630-9743-41aac47d19a7\">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(\"ab45356c-9da8-4630-9743-41aac47d19a7\");\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(\"ab45356c-9da8-4630-9743-41aac47d19a7\");\n",
       "  if (element == null) {\n",
       "    console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'ab45356c-9da8-4630-9743-41aac47d19a7' 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(\"ab45356c-9da8-4630-9743-41aac47d19a7\").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(\"ab45356c-9da8-4630-9743-41aac47d19a7\")).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=\"42bc7508-3f95-40c0-b57c-c475a8947bcf\"></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(\"42bc7508-3f95-40c0-b57c-c475a8947bcf\");\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(\"43177667-b8ff-40ef-b6cc-09d26ecf01f6\", 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(\"42bc7508-3f95-40c0-b57c-c475a8947bcf\");\n",
       "    if (element == null) {\n",
       "      console.log(\"Bokeh: ERROR: autoload.js configured with elementid '42bc7508-3f95-40c0-b57c-c475a8947bcf' 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 = {\"b0cc6d3a-2948-4098-a8b3-11349c2beff2\":{\"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\":\"1fd6bd86-a0ef-4aab-b40b-551a4c0a9657\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"plot\":{\"id\":\"5d15f6ab-52c0-4ff7-93f3-a85cefe55870\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"6ce04140-5d6c-4aff-8a2b-4cb11dfc0bd1\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"f9d83732-a595-458d-a9c8-5bb4ba6c58c5\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"plot\":{\"id\":\"5d15f6ab-52c0-4ff7-93f3-a85cefe55870\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"5462abbb-9216-475d-97ef-06f01a8c6bc1\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"overlay\":{\"id\":\"1fd6bd86-a0ef-4aab-b40b-551a4c0a9657\",\"type\":\"BoxAnnotation\"},\"plot\":{\"id\":\"5d15f6ab-52c0-4ff7-93f3-a85cefe55870\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"f23172ef-1f8e-4d32-92e2-7e5d525cb884\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"plot\":{\"id\":\"5d15f6ab-52c0-4ff7-93f3-a85cefe55870\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"6aa916da-79df-42eb-acb6-2c57a33d4ca0\",\"type\":\"SaveTool\"},{\"attributes\":{\"plot\":{\"id\":\"5d15f6ab-52c0-4ff7-93f3-a85cefe55870\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"24df9a77-06c5-469e-9743-7af6f5bd2965\",\"type\":\"ResetTool\"},{\"attributes\":{\"plot\":{\"id\":\"5d15f6ab-52c0-4ff7-93f3-a85cefe55870\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"f59e5b87-e648-4b61-b875-af79f3b4b6d9\",\"type\":\"HelpTool\"},{\"attributes\":{\"children\":[{\"id\":\"5d15f6ab-52c0-4ff7-93f3-a85cefe55870\",\"subtype\":\"Figure\",\"type\":\"Plot\"}]},\"id\":\"d80618e8-4cfa-41ba-8d3e-a3337677916e\",\"type\":\"Column\"},{\"attributes\":{},\"id\":\"3c98a72d-fe00-40aa-9f6e-b4453d61462d\",\"type\":\"ToolEvents\"},{\"attributes\":{\"callback\":null},\"id\":\"74f1cbd6-35eb-4e0d-b653-4ec64031f7b8\",\"type\":\"DataRange1d\"},{\"attributes\":{\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"t\"},\"y\":{\"field\":\"std\"}},\"id\":\"6fd062d6-3a0d-4083-a973-61702e1b20d8\",\"type\":\"Line\"},{\"attributes\":{\"formatter\":{\"id\":\"f9d83732-a595-458d-a9c8-5bb4ba6c58c5\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"5d15f6ab-52c0-4ff7-93f3-a85cefe55870\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1f168011-c9c0-47e3-b35b-5fd9cf64aee4\",\"type\":\"BasicTicker\"}},\"id\":\"2f5f5939-4721-4183-a536-085598df0944\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null},\"id\":\"a1605995-c661-4a44-9415-bde43033436e\",\"type\":\"DataRange1d\"},{\"attributes\":{\"below\":[{\"id\":\"2f5f5939-4721-4183-a536-085598df0944\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"65cb3299-978f-4dd3-8dc3-a4a47feeeb1a\",\"type\":\"LinearAxis\"}],\"plot_height\":200,\"renderers\":[{\"id\":\"2f5f5939-4721-4183-a536-085598df0944\",\"type\":\"LinearAxis\"},{\"id\":\"7009d731-341a-4c00-b71c-1cd5c03a4d95\",\"type\":\"Grid\"},{\"id\":\"65cb3299-978f-4dd3-8dc3-a4a47feeeb1a\",\"type\":\"LinearAxis\"},{\"id\":\"02ffc4de-06fc-4e1e-91d1-bd58e8ba86d7\",\"type\":\"Grid\"},{\"id\":\"1fd6bd86-a0ef-4aab-b40b-551a4c0a9657\",\"type\":\"BoxAnnotation\"},{\"id\":\"0d4e4763-eb5e-480d-af37-537c093884ea\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"42e487f2-c7e4-4665-9102-95f24541f24f\",\"type\":\"Title\"},\"tool_events\":{\"id\":\"3c98a72d-fe00-40aa-9f6e-b4453d61462d\",\"type\":\"ToolEvents\"},\"toolbar\":{\"id\":\"d82061ee-429f-4899-be34-de2780b3a2f2\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"74f1cbd6-35eb-4e0d-b653-4ec64031f7b8\",\"type\":\"DataRange1d\"},\"y_range\":{\"id\":\"a1605995-c661-4a44-9415-bde43033436e\",\"type\":\"DataRange1d\"}},\"id\":\"5d15f6ab-52c0-4ff7-93f3-a85cefe55870\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1f168011-c9c0-47e3-b35b-5fd9cf64aee4\",\"type\":\"BasicTicker\"},{\"attributes\":{\"data_source\":{\"id\":\"a92f8832-1c25-4dea-b352-983c70dabae7\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"6fd062d6-3a0d-4083-a973-61702e1b20d8\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"9ae59cc8-ec82-458e-912d-85d5b878bd8a\",\"type\":\"Line\"},\"selection_glyph\":null},\"id\":\"0d4e4763-eb5e-480d-af37-537c093884ea\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"plot\":{\"id\":\"5d15f6ab-52c0-4ff7-93f3-a85cefe55870\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1f168011-c9c0-47e3-b35b-5fd9cf64aee4\",\"type\":\"BasicTicker\"}},\"id\":\"7009d731-341a-4c00-b71c-1cd5c03a4d95\",\"type\":\"Grid\"},{\"attributes\":{\"plot\":null,\"text\":\"std\"},\"id\":\"42e487f2-c7e4-4665-9102-95f24541f24f\",\"type\":\"Title\"},{\"attributes\":{\"formatter\":{\"id\":\"c465be21-c78b-4543-ab5f-a9b75f72bc26\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"5d15f6ab-52c0-4ff7-93f3-a85cefe55870\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"19eb217e-8221-45bc-84d5-667ed457c7aa\",\"type\":\"BasicTicker\"}},\"id\":\"65cb3299-978f-4dd3-8dc3-a4a47feeeb1a\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"t\",\"std\"],\"data\":{\"std\":[30.45419424223658],\"t\":[0]}},\"id\":\"a92f8832-1c25-4dea-b352-983c70dabae7\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"19eb217e-8221-45bc-84d5-667ed457c7aa\",\"type\":\"BasicTicker\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"6ce04140-5d6c-4aff-8a2b-4cb11dfc0bd1\",\"type\":\"PanTool\"},{\"id\":\"5462abbb-9216-475d-97ef-06f01a8c6bc1\",\"type\":\"WheelZoomTool\"},{\"id\":\"f23172ef-1f8e-4d32-92e2-7e5d525cb884\",\"type\":\"BoxZoomTool\"},{\"id\":\"6aa916da-79df-42eb-acb6-2c57a33d4ca0\",\"type\":\"SaveTool\"},{\"id\":\"24df9a77-06c5-469e-9743-7af6f5bd2965\",\"type\":\"ResetTool\"},{\"id\":\"f59e5b87-e648-4b61-b875-af79f3b4b6d9\",\"type\":\"HelpTool\"}]},\"id\":\"d82061ee-429f-4899-be34-de2780b3a2f2\",\"type\":\"Toolbar\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"5d15f6ab-52c0-4ff7-93f3-a85cefe55870\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"19eb217e-8221-45bc-84d5-667ed457c7aa\",\"type\":\"BasicTicker\"}},\"id\":\"02ffc4de-06fc-4e1e-91d1-bd58e8ba86d7\",\"type\":\"Grid\"},{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"t\"},\"y\":{\"field\":\"std\"}},\"id\":\"9ae59cc8-ec82-458e-912d-85d5b878bd8a\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"c465be21-c78b-4543-ab5f-a9b75f72bc26\",\"type\":\"BasicTickFormatter\"}],\"root_ids\":[\"d80618e8-4cfa-41ba-8d3e-a3337677916e\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.5\"}};\n",
       "            var render_items = [{\"docid\":\"b0cc6d3a-2948-4098-a8b3-11349c2beff2\",\"elementid\":\"42bc7508-3f95-40c0-b57c-c475a8947bcf\",\"modelid\":\"d80618e8-4cfa-41ba-8d3e-a3337677916e\",\"notebook_comms_target\":\"43177667-b8ff-40ef-b6cc-09d26ecf01f6\"}];\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(\"42bc7508-3f95-40c0-b57c-c475a8947bcf\")).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
}
