IRC-SPHERE/HyperStream

View on GitHub
examples/tutorial_04.ipynb

Summary

Maintainability
Test Coverage
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img style=\"float: right;\" src=\"images/hyperstream.svg\">\n",
    "\n",
    "# HyperStream Tutorial 4: Real-time streams\n",
    "\n",
    "In this tutorial, we show how to create a new plugin that collects real-time data ussing a publicly available API. In this case, we use the [Environment Agency flood-monitoring API][1].\n",
    "\n",
    "## Creating a plugin tool to use the API\n",
    "\n",
    "### 1. Create a folder in plugins\n",
    "\n",
    "First of all, we need to create a new folder to contain the new tool. The new folder needs to be in the folder __plugins__, in this example __plugins/example/tools/environment_data_gov_uk/__. Also, we need to create an **\\__init\\__.py** file in every subfolder.\n",
    "\n",
    "    plugins/\n",
    "        |- __init__.py\n",
    "        |- example/\n",
    "            |- __init__.py\n",
    "            |- tools/\n",
    "                |- __init__.py\n",
    "                |- environment_data_gov_uk\n",
    "                    |- __init__.py\n",
    "                    |- 2017-06-21_v0.0.1.py\n",
    "\n",
    "### 2. Write the plugin in Python\n",
    "\n",
    "As we have seen in a previous tutorial, we can create a new plugin in Python, in this case the code of the plugin **./plugins/example/tools/environment_data_gov_uk/2017-06-21_v0.0.1.py** uses the API to query only one of the water readings for the specified interval of time:\n",
    "\n",
    "```Python\n",
    "from datetime import datetime\n",
    "from datetime import datetime, timedelta\n",
    "\n",
    "from hyperstream import Tool, StreamInstance, StreamInstanceCollection\n",
    "from hyperstream.utils import check_input_stream_count\n",
    "from hyperstream.utils import UTC\n",
    "\n",
    "from dateutil.parser import parse\n",
    "\n",
    "import urllib\n",
    "import urllib2\n",
    "import json\n",
    "\n",
    "# this uses Environment Agency flood and river level data from the real-time\n",
    "# data API (Beta)\n",
    "# For questions on the APIs please contact data.info@environment-agency.gov.uk,\n",
    "# a forum for announcements and discussion is under consideration.\n",
    "class EnvironmentDataGovUk(Tool):\n",
    "    def __init__(self, station):\n",
    "        self.station = station\n",
    "        super(EnvironmentDataGovUk, self).__init__()\n",
    "\n",
    "    @check_input_stream_count(0)\n",
    "    def _execute(self, sources, alignment_stream, interval):\n",
    "        startdate = interval[0].strftime(\"%Y-%m-%d\")\n",
    "        enddate = interval[1].strftime(\"%Y-%m-%d\")\n",
    "\n",
    "        url = \"https://environment.data.gov.uk/flood-monitoring/id/stations/{}/readings\".format(self.station)\n",
    "        values = {'startdate' : startdate,\n",
    "                  'enddate' : enddate}\n",
    "        url_parameters = urllib.urlencode(values)\n",
    "\n",
    "        full_url = url + '?' + url_parameters\n",
    "        response = urllib2.urlopen(full_url)\n",
    "        data = json.load(response)\n",
    "\n",
    "        for item in data['items']:\n",
    "            dt = parse(item.get('dateTime'))\n",
    "            if dt in interval:\n",
    "                value = float(item.get('value'))\n",
    "                yield StreamInstance(dt, value)\n",
    "\n",
    "```\n",
    "\n",
    "### 3. Add HyperStream configuration\n",
    "\n",
    "Now, it is necessary to add information about this plugin into the **hyperstream_config.json**. In particular, we need to add the following information in the plugin section:\n",
    "\n",
    "- channel_id_prefix: This is to create Channels (explained in another tutorial).\n",
    "- channel_names: A list of available Channels\n",
    "- path: path to the new plugin\n",
    "- has_tools: If the new plugin has tools\n",
    "- has_assets: If it contains folders or files that are needed by the plugin\n",
    "\n",
    "Next, we have an example of an configuration file with the new plugin:\n",
    "\n",
    "```json\n",
    "{\n",
    "    \"mongo\": {\n",
    "        \"host\": \"localhost\",\n",
    "        \"port\": 27017,\n",
    "        \"tz_aware\": true,\n",
    "        \"db\": \"hyperstream\"\n",
    "    },\n",
    "    \"plugins\": [{\n",
    "        \"channel_id_prefix\": \"example\",\n",
    "        \"channel_names\": [],\n",
    "        \"path\": \"plugins/example\",\n",
    "        \"has_tools\": true,\n",
    "        \"has_assets\": false\n",
    "    }],\n",
    "    \"online_engine\": {\n",
    "        \"interval\": {\n",
    "            \"start\": -60,\n",
    "            \"end\": -10\n",
    "        },\n",
    "        \"sleep\": 5,\n",
    "        \"iterations\": 100\n",
    "    }\n",
    "}\n",
    "\n",
    "```\n",
    "\n",
    "\n",
    "### Aknowledge\n",
    "\n",
    "    this uses Environment Agency flood and river level data from the real-time data API (Beta)\n",
    "    \n",
    "[1]: https://environment.data.gov.uk/flood-monitoring/doc/reference#introduction"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPython 2.7.6\n",
      "IPython 5.3.0\n",
      "\n",
      "hyperstream 0.3.0-beta\n",
      "\n",
      "compiler   : GCC 4.8.4\n",
      "system     : Linux\n",
      "release    : 3.19.0-80-generic\n",
      "machine    : x86_64\n",
      "processor  : x86_64\n",
      "CPU cores  : 4\n",
      "interpreter: 64bit\n",
      "Git hash   : f0e911526041b91fe7999a8968c80618d410e741\n"
     ]
    }
   ],
   "source": [
    "%load_ext watermark\n",
    "\n",
    "import sys\n",
    "from datetime import datetime\n",
    "from datetime import datetime, timedelta\n",
    "\n",
    "sys.path.append(\"../\") # Add parent dir in the Path\n",
    "\n",
    "from hyperstream import HyperStream, StreamId\n",
    "from hyperstream import TimeInterval\n",
    "from hyperstream.utils import UTC\n",
    "\n",
    "from utils import plot_high_chart\n",
    "\n",
    "%watermark -v -m -p hyperstream -g"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Select the water Station\n",
    "\n",
    "For our example, we will query a water station called Bristol Avon Little Avon Axe and North Somerset St. This station has the station number 531118. It is possible to select another station by changing the station_number; a list of 50 other possible stations can be found following [this link][2].\n",
    "\n",
    "[2]: https://environment.data.gov.uk/flood-monitoring/id/stations?_limit=50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "station_number = \"531118\"\n",
    "station_name = \"Bristol Avon Little Avon Axe and North Somerset St\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Tool and Stream\n",
    "\n",
    "First we will create a Stream to store the data and an instance of the new tool."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "HyperStream version 0.3.0-beta, connected to mongodb://localhost:27017/hyperstream, session id <no session>\n"
     ]
    }
   ],
   "source": [
    "hs = HyperStream(loglevel=20)\n",
    "print hs\n",
    "\n",
    "environment_stream = hs.channel_manager.memory.get_or_create_stream(\"environment\")\n",
    "environment_tool = hs.plugins.example.tools.environment_data_gov_uk(station=station_number)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Execute the tool\n",
    "\n",
    "Now we will specify an interval of time for which we want the water levels. In this particular case we will ask for the last 7 days. Then, we can execute the tool for the specified interval of time. The result will be stored in the specified Stream."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "now = datetime.utcnow().replace(tzinfo=UTC)\n",
    "before = (now - timedelta(weeks=1)).replace(tzinfo=UTC)\n",
    "ti = TimeInterval(before, now)\n",
    "\n",
    "environment_tool.execute(sources=[], sink=environment_stream, interval=ti)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Visualization\n",
    "\n",
    "Now we can visualize all the data stored in the stream"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <html>\n",
       "        <head>\n",
       "        <title>Bristol Avon Little Avon Axe and North Somerset St</title>\n",
       "           <!--<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js\"></script>-->\n",
       "           <!--<script src=\"https://code.highcharts.com/stock/highstock.js\"></script>-->\n",
       "           <!--<script src=\"https://code.highcharts.com/stock/modules/exporting.js\"></script>-->\n",
       "           <script src=\"./scripts/jquery.min.js\"></script>\n",
       "           <script src=\"./scripts/highstock.js\"></script>\n",
       "           <script src=\"./scripts/exporting.js\"></script>\n",
       "        </head>\n",
       "        <body>\n",
       "\n",
       "        <div id=\"container5436\" style=\"width: 800px; height: 600px; margin: 125 auto\"></div>\n",
       "\n",
       "        <script language=\"JavaScript\">\n",
       "               var data = [[1500048900000.0, 0.031], [1500049800000.0, 0.032], [1500050700000.0, 0.031], [1500051600000.0, 0.031], [1500052500000.0, 0.032], [1500053400000.0, 0.032], [1500054300000.0, 0.032], [1500055200000.0, 0.032], [1500056100000.0, 0.032], [1500057000000.0, 0.033], [1500057900000.0, 0.033], [1500058800000.0, 0.033], [1500059700000.0, 0.032], [1500060600000.0, 0.032], [1500061500000.0, 0.033], [1500062400000.0, 0.033], [1500063300000.0, 0.034], [1500064200000.0, 0.034], [1500065100000.0, 0.033], [1500066000000.0, 0.034], [1500066900000.0, 0.033], [1500067800000.0, 0.034], [1500068700000.0, 0.034], [1500069600000.0, 0.034], [1500070500000.0, 0.033], [1500071400000.0, 0.033], [1500072300000.0, 0.033], [1500073200000.0, 0.034], [1500074100000.0, 0.034], [1500075000000.0, 0.034], [1500075900000.0, 0.034], [1500076800000.0, 0.034], [1500077700000.0, 0.034], [1500078600000.0, 0.034], [1500079500000.0, 0.034], [1500080400000.0, 0.034], [1500081300000.0, 0.034], [1500082200000.0, 0.034], [1500083100000.0, 0.034], [1500084000000.0, 0.033], [1500084900000.0, 0.034], [1500085800000.0, 0.034], [1500086700000.0, 0.034], [1500087600000.0, 0.034], [1500088500000.0, 0.034], [1500089400000.0, 0.034], [1500090300000.0, 0.034], [1500091200000.0, 0.034], [1500092100000.0, 0.034], [1500093000000.0, 0.034], [1500093900000.0, 0.034], [1500094800000.0, 0.034], [1500095700000.0, 0.034], [1500096600000.0, 0.033], [1500097500000.0, 0.034], [1500098400000.0, 0.033], [1500099300000.0, 0.034], [1500100200000.0, 0.033], [1500101100000.0, 0.033], [1500102000000.0, 0.033], [1500102900000.0, 0.034], [1500103800000.0, 0.033], [1500104700000.0, 0.033], [1500105600000.0, 0.033], [1500106500000.0, 0.033], [1500107400000.0, 0.032], [1500108300000.0, 0.033], [1500109200000.0, 0.032], [1500110100000.0, 0.032], [1500111000000.0, 0.032], [1500111900000.0, 0.033], [1500112800000.0, 0.032], [1500113700000.0, 0.032], [1500114600000.0, 0.033], [1500115500000.0, 0.032], [1500116400000.0, 0.033], [1500117300000.0, 0.032], [1500118200000.0, 0.032], [1500119100000.0, 0.032], [1500120000000.0, 0.032], [1500120900000.0, 0.032], [1500121800000.0, 0.032], [1500122700000.0, 0.032], [1500123600000.0, 0.033], [1500124500000.0, 0.032], [1500125400000.0, 0.032], [1500126300000.0, 0.032], [1500127200000.0, 0.032], [1500128100000.0, 0.032], [1500129000000.0, 0.032], [1500129900000.0, 0.032], [1500130800000.0, 0.032], [1500131700000.0, 0.032], [1500132600000.0, 0.032], [1500133500000.0, 0.032], [1500134400000.0, 0.033], [1500135300000.0, 0.033], [1500136200000.0, 0.032], [1500137100000.0, 0.032], [1500138000000.0, 0.033], [1500138900000.0, 0.033], [1500139800000.0, 0.033], [1500140700000.0, 0.033], [1500141600000.0, 0.033], [1500142500000.0, 0.033], [1500143400000.0, 0.033], [1500144300000.0, 0.033], [1500145200000.0, 0.032], [1500146100000.0, 0.032], [1500147000000.0, 0.032], [1500147900000.0, 0.033], [1500148800000.0, 0.033], [1500149700000.0, 0.033], [1500150600000.0, 0.033], [1500151500000.0, 0.033], [1500152400000.0, 0.032], [1500153300000.0, 0.034], [1500154200000.0, 0.033], [1500155100000.0, 0.033], [1500156000000.0, 0.033], [1500156900000.0, 0.033], [1500157800000.0, 0.032], [1500158700000.0, 0.032], [1500159600000.0, 0.033], [1500160500000.0, 0.033], [1500161400000.0, 0.033], [1500162300000.0, 0.032], [1500163200000.0, 0.035], [1500164100000.0, 0.034], [1500165000000.0, 0.034], [1500165900000.0, 0.034], [1500166800000.0, 0.033], [1500167700000.0, 0.034], [1500168600000.0, 0.034], [1500169500000.0, 0.034], [1500170400000.0, 0.034], [1500171300000.0, 0.033], [1500172200000.0, 0.034], [1500173100000.0, 0.034], [1500174000000.0, 0.033], [1500174900000.0, 0.033], [1500175800000.0, 0.033], [1500176700000.0, 0.033], [1500177600000.0, 0.033], [1500178500000.0, 0.032], [1500179400000.0, 0.032], [1500180300000.0, 0.032], [1500181200000.0, 0.032], [1500182100000.0, 0.032], [1500183000000.0, 0.032], [1500183900000.0, 0.033], [1500184800000.0, 0.032], [1500185700000.0, 0.032], [1500186600000.0, 0.032], [1500187500000.0, 0.032], [1500188400000.0, 0.031], [1500189300000.0, 0.032], [1500190200000.0, 0.032], [1500191100000.0, 0.032], [1500192000000.0, 0.032], [1500192900000.0, 0.03], [1500193800000.0, 0.031], [1500194700000.0, 0.03], [1500195600000.0, 0.03], [1500196500000.0, 0.031], [1500197400000.0, 0.031], [1500198300000.0, 0.031], [1500199200000.0, 0.031], [1500200100000.0, 0.032], [1500201000000.0, 0.031], [1500201900000.0, 0.032], [1500202800000.0, 0.032], [1500203700000.0, 0.033], [1500204600000.0, 0.032], [1500205500000.0, 0.033], [1500206400000.0, 0.033], [1500207300000.0, 0.032], [1500208200000.0, 0.032], [1500209100000.0, 0.032], [1500210000000.0, 0.032], [1500210900000.0, 0.031], [1500211800000.0, 0.032], [1500212700000.0, 0.032], [1500213600000.0, 0.031], [1500214500000.0, 0.03], [1500215400000.0, 0.031], [1500216300000.0, 0.032], [1500217200000.0, 0.032], [1500218100000.0, 0.032], [1500219000000.0, 0.031], [1500219900000.0, 0.031], [1500220800000.0, 0.031], [1500221700000.0, 0.032], [1500222600000.0, 0.032], [1500223500000.0, 0.032], [1500224400000.0, 0.032], [1500225300000.0, 0.032], [1500226200000.0, 0.032], [1500227100000.0, 0.032], [1500228000000.0, 0.033], [1500228900000.0, 0.031], [1500229800000.0, 0.032], [1500230700000.0, 0.032], [1500231600000.0, 0.032], [1500232500000.0, 0.032], [1500233400000.0, 0.032], [1500234300000.0, 0.029], [1500235200000.0, 0.033], [1500236100000.0, 0.032], [1500237000000.0, 0.031], [1500237900000.0, 0.032], [1500238800000.0, 0.033], [1500239700000.0, 0.033], [1500240600000.0, 0.033], [1500241500000.0, 0.032], [1500242400000.0, 0.032], [1500243300000.0, 0.034], [1500244200000.0, 0.033], [1500245100000.0, 0.033], [1500246000000.0, 0.033], [1500246900000.0, 0.034], [1500247800000.0, 0.033], [1500248700000.0, 0.034], [1500249600000.0, 0.035], [1500250500000.0, 0.034], [1500251400000.0, 0.034], [1500252300000.0, 0.034], [1500253200000.0, 0.034], [1500254100000.0, 0.034], [1500255000000.0, 0.034], [1500255900000.0, 0.034], [1500256800000.0, 0.034], [1500257700000.0, 0.034], [1500258600000.0, 0.034], [1500259500000.0, 0.034], [1500260400000.0, 0.035], [1500261300000.0, 0.035], [1500262200000.0, 0.034], [1500263100000.0, 0.034], [1500264000000.0, 0.035], [1500264900000.0, 0.034], [1500265800000.0, 0.034], [1500266700000.0, 0.035], [1500267600000.0, 0.035], [1500268500000.0, 0.035], [1500269400000.0, 0.034], [1500270300000.0, 0.034], [1500271200000.0, 0.034], [1500272100000.0, 0.034], [1500273000000.0, 0.034], [1500273900000.0, 0.034], [1500274800000.0, 0.034], [1500275700000.0, 0.033], [1500276600000.0, 0.032], [1500277500000.0, 0.031], [1500278400000.0, 0.031], [1500279300000.0, 0.031], [1500280200000.0, 0.031], [1500281100000.0, 0.031], [1500282000000.0, 0.031], [1500282900000.0, 0.031], [1500283800000.0, 0.031], [1500284700000.0, 0.031], [1500285600000.0, 0.032], [1500286500000.0, 0.031], [1500287400000.0, 0.032], [1500288300000.0, 0.031], [1500289200000.0, 0.031], [1500290100000.0, 0.031], [1500291000000.0, 0.031], [1500291900000.0, 0.031], [1500292800000.0, 0.031], [1500293700000.0, 0.031], [1500294600000.0, 0.032], [1500295500000.0, 0.031], [1500296400000.0, 0.031], [1500297300000.0, 0.032], [1500298200000.0, 0.031], [1500299100000.0, 0.031], [1500300000000.0, 0.032], [1500300900000.0, 0.031], [1500301800000.0, 0.031], [1500302700000.0, 0.031], [1500303600000.0, 0.031], [1500304500000.0, 0.03], [1500305400000.0, 0.032], [1500306300000.0, 0.032], [1500307200000.0, 0.031], [1500308100000.0, 0.031], [1500309000000.0, 0.031], [1500309900000.0, 0.031], [1500310800000.0, 0.031], [1500311700000.0, 0.032], [1500312600000.0, 0.032], [1500313500000.0, 0.032], [1500314400000.0, 0.033], [1500315300000.0, 0.032], [1500316200000.0, 0.033], [1500317100000.0, 0.033], [1500318000000.0, 0.033], [1500318900000.0, 0.033], [1500319800000.0, 0.033], [1500320700000.0, 0.033], [1500321600000.0, 0.033], [1500322500000.0, 0.033], [1500323400000.0, 0.033], [1500324300000.0, 0.033], [1500325200000.0, 0.033], [1500326100000.0, 0.033], [1500327000000.0, 0.033], [1500327900000.0, 0.034], [1500328800000.0, 0.034], [1500329700000.0, 0.033], [1500330600000.0, 0.034], [1500331500000.0, 0.034], [1500332400000.0, 0.034], [1500333300000.0, 0.034], [1500334200000.0, 0.035], [1500335100000.0, 0.035], [1500336000000.0, 0.035], [1500336900000.0, 0.035], [1500337800000.0, 0.035], [1500338700000.0, 0.035], [1500339600000.0, 0.035], [1500340500000.0, 0.036], [1500341400000.0, 0.035], [1500342300000.0, 0.035], [1500343200000.0, 0.035], [1500344100000.0, 0.035], [1500345000000.0, 0.035], [1500345900000.0, 0.035], [1500346800000.0, 0.032], [1500347700000.0, 0.031], [1500348600000.0, 0.032], [1500349500000.0, 0.032], [1500350400000.0, 0.032], [1500351300000.0, 0.032], [1500352200000.0, 0.033], [1500353100000.0, 0.033], [1500354000000.0, 0.032], [1500354900000.0, 0.032], [1500355800000.0, 0.032], [1500356700000.0, 0.033], [1500357600000.0, 0.032], [1500358500000.0, 0.032], [1500359400000.0, 0.032], [1500360300000.0, 0.031], [1500361200000.0, 0.031], [1500362100000.0, 0.032], [1500363000000.0, 0.03], [1500363900000.0, 0.03], [1500364800000.0, 0.03], [1500365700000.0, 0.03], [1500366600000.0, 0.03], [1500367500000.0, 0.03], [1500368400000.0, 0.029], [1500369300000.0, 0.029], [1500370200000.0, 0.029], [1500371100000.0, 0.029], [1500372000000.0, 0.029], [1500372900000.0, 0.029], [1500374700000.0, 0.029], [1500375600000.0, 0.028], [1500376500000.0, 0.028], [1500377400000.0, 0.027], [1500378300000.0, 0.027], [1500379200000.0, 0.029], [1500380100000.0, 0.029], [1500381000000.0, 0.029], [1500381900000.0, 0.028], [1500382800000.0, 0.029], [1500383700000.0, 0.029], [1500384600000.0, 0.03], [1500387300000.0, 0.029], [1500388200000.0, 0.029], [1500389100000.0, 0.028], [1500390000000.0, 0.029], [1500390900000.0, 0.028], [1500391800000.0, 0.028], [1500392700000.0, 0.029], [1500393600000.0, 0.029], [1500394500000.0, 0.029], [1500395400000.0, 0.029], [1500396300000.0, 0.029], [1500397200000.0, 0.029], [1500399000000.0, 0.028], [1500399900000.0, 0.027], [1500400800000.0, 0.028], [1500402600000.0, 0.029], [1500403500000.0, 0.03], [1500404400000.0, 0.029], [1500405300000.0, 0.03], [1500406200000.0, 0.03], [1500407100000.0, 0.03], [1500408000000.0, 0.03], [1500408900000.0, 0.03], [1500409800000.0, 0.03], [1500410700000.0, 0.03], [1500411600000.0, 0.031], [1500412500000.0, 0.03], [1500413400000.0, 0.03], [1500414300000.0, 0.03], [1500415200000.0, 0.031], [1500416100000.0, 0.031], [1500417000000.0, 0.031], [1500417900000.0, 0.031], [1500418800000.0, 0.031], [1500419700000.0, 0.031], [1500420600000.0, 0.031], [1500421500000.0, 0.031], [1500422400000.0, 0.032], [1500423300000.0, 0.032], [1500424200000.0, 0.032], [1500425100000.0, 0.031], [1500426000000.0, 0.031], [1500426900000.0, 0.031], [1500427800000.0, 0.032], [1500428700000.0, 0.032], [1500429600000.0, 0.032], [1500430500000.0, 0.032], [1500431400000.0, 0.032], [1500432300000.0, 0.032], [1500433200000.0, 0.028], [1500434100000.0, 0.029], [1500435000000.0, 0.029], [1500435900000.0, 0.029], [1500436800000.0, 0.028], [1500437700000.0, 0.03], [1500438600000.0, 0.03], [1500439500000.0, 0.03], [1500440400000.0, 0.03], [1500441300000.0, 0.03], [1500442200000.0, 0.03], [1500443100000.0, 0.03], [1500444000000.0, 0.03]];\n",
       "\n",
       "            Highcharts.stockChart('container5436', {\n",
       "                chart: {\n",
       "                    zoomType: 'x'\n",
       "                },\n",
       "                title: {\n",
       "                    text: 'Bristol Avon Little Avon Axe and North Somerset St'\n",
       "                },\n",
       "                xAxis: {\n",
       "                    type: 'datetime', ordinal: false\n",
       "                },\n",
       "                yAxis: {\n",
       "                    title: {\n",
       "                        text: 'meters'\n",
       "                    }\n",
       "                },\n",
       "                legend: {\n",
       "                    enabled: false\n",
       "                },\n",
       "\n",
       "                series: [{\n",
       "                    type: 'spline',\n",
       "                    name: 'meters',\n",
       "                    data: data\n",
       "                }]\n",
       "            });\n",
       "        </script>\n",
       "\n",
       "        </body>\n",
       "        </html>\n",
       "    "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "my_time, my_data = zip(*[(key.__str__(), value) for key, value in environment_stream.window().items()])\n",
    "\n",
    "plot_high_chart(my_time, my_data, type=\"high_stock\", title=station_name, yax='meters')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}