{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction: Using Watt Time to Find Energy Sources\n", "\n", "The purpose of this notebook is to explore the Watt Time API to find what kind of electricity we are currently using. The Watt Time API allows us to see a breakdown of the energy generation for a given location." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:02:52.063494Z", "start_time": "2018-12-19T02:02:50.485580Z" } }, "outputs": [], "source": [ "# Standard Data Science Helpers\n", "import numpy as np\n", "import pandas as pd\n", "import scipy\n", "\n", "import featuretools as ft\n", "\n", "# Graphic libraries\n", "import matplotlib as plt\n", "%matplotlib inline\n", "plt.style.use('fivethirtyeight');plt.rcParams['font.size']=18\n", "import seaborn as sns\n", "\n", "# Extra options\n", "pd.options.display.max_rows = 10\n", "# Show all code cells outputs\n", "from IPython.core.interactiveshell import InteractiveShell\n", "InteractiveShell.ast_node_interactivity = 'all'\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get Location\n", "\n", "This code is from Stack Overflow: " ] }, { "cell_type": "code", "execution_count": 40, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:40:36.678067Z", "start_time": "2018-12-19T02:40:36.674077Z" } }, "outputs": [], "source": [ "from IPython.display import HTML" ] }, { "cell_type": "code", "execution_count": 60, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:44:35.725236Z", "start_time": "2018-12-19T02:44:35.722217Z" } }, "outputs": [], "source": [ "info = open('C:/users/willk/OneDrive/Desktop/watt_time_api.txt', 'r').read()\n", "u, p = info.split(',')" ] }, { "cell_type": "code", "execution_count": 113, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T03:02:56.053230Z", "start_time": "2018-12-19T03:02:55.782820Z" } }, "outputs": [], "source": [ "from requests.auth import HTTPBasicAuth\n", "\n", "values = \"\"\"{\n", " \"username\": \"willkoehrsen\",\n", " \"password\": \"introduction\",\n", " \"email\": \"wjk68@case.edu\",\n", " \"org\": \"Cortex Intel\"\n", " }\"\"\"\n", " \n", "headers = {\n", " \"Content-Type\": \"application/json\"\n", "}\n", "\n", "r = requests.post('https://api2.watttime.org/v2/login', \n", " headers={'username': u, 'password': p},\n", " auth = ('token', 'bb4d607fc7e94417718f6a70a92c72def85ffbe4'))\n", "\n", "# import ast\n", "# token = ast.literal_eval(r.text.strip())['token']" ] }, { "cell_type": "code", "execution_count": 114, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T03:02:56.549311Z", "start_time": "2018-12-19T03:02:56.544322Z" } }, "outputs": [ { "data": { "text/plain": [ "'{\"message\":\"Authorization header requires \\'Credential\\' parameter. Authorization header requires \\'Signature\\' parameter. Authorization header requires \\'SignedHeaders\\' parameter. Authorization header requires existence of either a \\'X-Amz-Date\\' or a \\'Date\\' header. Authorization=Basic dG9rZW46YmI0ZDYwN2ZjN2U5NDQxNzcxOGY2YTcwYTkyYzcyZGVmODVmZmJlNA==\"}'" ] }, "execution_count": 114, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r.text" ] }, { "cell_type": "code", "execution_count": 105, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T03:01:07.620967Z", "start_time": "2018-12-19T03:01:07.615984Z" } }, "outputs": [ { "data": { "text/plain": [ "'P@*7XDxq6q84rJboRxK4Al&iw4Wi&w^!u*Twj82H3GyR'" ] }, "execution_count": 105, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p" ] }, { "cell_type": "code", "execution_count": 69, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:47:24.074745Z", "start_time": "2018-12-19T02:46:53.810735Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\t\n", "\t \n", "\t\t\n", "\t\t\n", "\t\tApplication Error\n", "\t\t\n", "\t \n", "\t \n", "\t\t\n", "\t \n", "\t" ], "text/plain": [ "" ] }, "execution_count": 69, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r = requests.get('https://api.watttime.org/api/v1/datapoints/', \n", " headers={'Authorization': f'Token {token}'})\n", "\n", "HTML(r.text)" ] }, { "cell_type": "code", "execution_count": 88, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:57:03.861257Z", "start_time": "2018-12-19T02:57:03.856273Z" } }, "outputs": [], "source": [ "def get_location_ba(longitude, latitude):\n", " loc = {'type': 'Point', 'coordinates': [longitude, latitude]}\n", " return requests.get(f'https://api.watttime.org/api/v1/balancing_authorities/?loc={loc}')" ] }, { "cell_type": "code", "execution_count": 89, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:57:04.915637Z", "start_time": "2018-12-19T02:57:04.094645Z" } }, "outputs": [ { "data": { "text/plain": [ "'[{\"name\":\"PJM Interconnection\",\"ba_type\":\"ISO\",\"url\":\"https://api.watttime.org/api/v1/balancing_authorities/PJM/\",\"abbrev\":\"PJM\",\"link\":\"http://www.pjm.com/\",\"notes\":\"Data updates every 5 minutes.\",\"states\":[\"DE\",\"DC\",\"IL\",\"IN\",\"KY\",\"MD\",\"MI\",\"NJ\",\"NC\",\"OH\",\"PA\",\"VA\",\"WV\",\"WI\"]}]'" ] }, "execution_count": 89, "metadata": {}, "output_type": "execute_result" } ], "source": [ "get_location_ba(g.latlng[1], g.latlng[0]).text" ] }, { "cell_type": "code", "execution_count": 82, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:52:57.553712Z", "start_time": "2018-12-19T02:52:27.239692Z" } }, "outputs": [ { "data": { "text/plain": [ "'\\n\\t\\n\\t \\n\\t\\t\\n\\t\\t\\n\\t\\tApplication Error\\n\\t\\t\\n\\t \\n\\t \\n\\t\\t\\n\\t \\n\\t'" ] }, "execution_count": 82, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r = requests.get('http://api.watttime.org/api/v1/datapoints/?ba=MISO&market=RT5M&page=2&page_size=2')\n", "r.text" ] }, { "cell_type": "code", "execution_count": 87, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:56:52.765183Z", "start_time": "2018-12-19T02:56:22.412606Z" } }, "outputs": [ { "data": { "text/plain": [ "'\\n\\t\\n\\t \\n\\t\\t\\n\\t\\t\\n\\t\\tApplication Error\\n\\t\\t\\n\\t \\n\\t \\n\\t\\t\\n\\t \\n\\t'" ] }, "execution_count": 87, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r = requests.get('http://api.watttime.org/api/v1/datapoints/?ba=PJM&page=2&page_size=2',\n", " headers={'Authorization': f'Token {token}'})\n", "r.text" ] }, { "cell_type": "code", "execution_count": 72, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:48:17.433127Z", "start_time": "2018-12-19T02:48:17.001984Z" } }, "outputs": [ { "data": { "text/plain": [ "'[{\"name\":\"California Independent System Operator\",\"ba_type\":\"ISO\",\"url\":\"https://api.watttime.org/api/v1/balancing_authorities/CAISO/\",\"abbrev\":\"CAISO\",\"link\":\"http://oasis.caiso.com/\",\"notes\":\" \",\"states\":[\"CA\"]}]'" ] }, "execution_count": 72, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r = requests.get('https://api.watttime.org/api/v1/balancing_authorities/?loc={\"type\":\"Point\",\"coordinates\":[-122.272778,37.871667]}')\n", "r.text" ] }, { "cell_type": "code", "execution_count": 62, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:44:38.224209Z", "start_time": "2018-12-19T02:44:38.218240Z" } }, "outputs": [ { "data": { "text/html": [ "{\"token\":\"bb4d607fc7e94417718f6a70a92c72def85ffbe4\"}" ], "text/plain": [ "" ] }, "execution_count": 62, "metadata": {}, "output_type": "execute_result" } ], "source": [ "HTML(r.text.strip())" ] }, { "cell_type": "code", "execution_count": 63, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:44:58.130465Z", "start_time": "2018-12-19T02:44:58.126475Z" } }, "outputs": [ { "data": { "text/plain": [ "'{\"token\":\"bb4d607fc7e94417718f6a70a92c72def85ffbe4\"}'" ] }, "execution_count": 63, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r.text" ] }, { "cell_type": "code", "execution_count": 49, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:41:54.770362Z", "start_time": "2018-12-19T02:41:54.767369Z" } }, "outputs": [], "source": [ "values = \"\"\"\n", " {\n", " \"username\": \"freddo\",\n", " \"password\": \"the_frog\",\n", " \"email\": \"freddo@frog.com\",\n", " \"org\": \"fred's world\"\n", " }\n", "\"\"\"" ] }, { "cell_type": "code", "execution_count": 44, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:41:14.165841Z", "start_time": "2018-12-19T02:41:13.835797Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "ERROR: The request could not be satisfied\n", "\n", "

403 ERROR

\n", "

The request could not be satisfied.

\n", "
\n", "Bad request.\n", "\n", "
\n", "
\n", "
\n",
       "Generated by cloudfront (CloudFront)\n",
       "Request ID: LeDj5M7pr28h-aiQyKEVaViQ_jDkLWqfjPBNp6tFKWPCFHBO_PCQkw==\n",
       "
\n", "
\n", "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "values = {'password': p, 'username': u}\n", "\n", "r = requests.get('https://api2.watttime.org/v2/login', data=values, headers=headers)\n", "HTML(r.text.strip())" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:02:52.665886Z", "start_time": "2018-12-19T02:02:52.113361Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[40.6518, -74.3229]\n" ] } ], "source": [ "import geocoder\n", "g = geocoder.ip('me')\n", "print(g.latlng)" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:20:52.931935Z", "start_time": "2018-12-19T02:20:52.510546Z" } }, "outputs": [ { "data": { "text/plain": [ "'{\"message\":\"Unauthorized\"}'" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import requests\n", "\n", "headers = {'username': u, 'password': p}\n", "request = requests.get(f'https://api2.watttime.org/v2/login/', auth=(u, p))\n", "request.text" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:19:54.015754Z", "start_time": "2018-12-19T02:19:54.009776Z" } }, "outputs": [ { "data": { "text/plain": [ "{'username': 'willkoehrsen',\n", " 'password': '1c2e11d259fb27888978871d63cebc770ecfe72d'}" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "headers" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T01:49:49.414162Z", "start_time": "2018-12-19T01:49:49.409175Z" } }, "outputs": [], "source": [ "g.latlng" ] }, { "cell_type": "code", "execution_count": 59, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:43:48.064861Z", "start_time": "2018-12-19T02:43:48.052895Z" } }, "outputs": [], "source": [ "info = open('C:/Users/willk/OneDrive/Desktop/watt_time_api.txt', 'r').read()\n", "u, p = info.split(',')" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:02:57.850787Z", "start_time": "2018-12-19T02:02:57.828845Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Django cache unavailable to WattTime API client, falling back to local memory cache.\n" ] } ], "source": [ "from watttime_client.client import WattTimeAPI\n", "client = WattTimeAPI(token=p)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:03:02.791737Z", "start_time": "2018-12-19T02:03:01.777644Z" } }, "outputs": [ { "ename": "JSONDecodeError", "evalue": "Expecting value: line 4 column 1 (char 3)", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mJSONDecodeError\u001b[0m Traceback (most recent call last)", "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mpytz\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mtimestamp\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpytz\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mutc\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlocalize\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdatetime\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m2015\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m6\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m12\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m30\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[0mvalue\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mclient\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_impact_at\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtimestamp\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'CAISO'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\watttime_client\\client.py\u001b[0m in \u001b[0;36mget_impact_at\u001b[1;34m(self, ts, ba, market)\u001b[0m\n\u001b[0;32m 93\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 94\u001b[0m \u001b[1;31m# if got here, no good data in cache, so fetch it\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 95\u001b[1;33m \u001b[0mtimes\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvalues\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfetch\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mts\u001b[0m \u001b[1;33m-\u001b[0m \u001b[0mtimedelta\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mhours\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m4\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mts\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mtimedelta\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mhours\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m4\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mba\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmarket\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 96\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 97\u001b[0m \u001b[1;31m# best value is latest time before or equal to ts\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\watttime_client\\client.py\u001b[0m in \u001b[0;36mfetch\u001b[1;34m(self, start_at, end_at, ba, market, **kwargs)\u001b[0m\n\u001b[0;32m 49\u001b[0m result = requests.get('https://api.watttime.org/api/v2/marginal/',\n\u001b[0;32m 50\u001b[0m params=params, headers=self.auth_header)\n\u001b[1;32m---> 51\u001b[1;33m \u001b[0mdata\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjson\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'results'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 52\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 53\u001b[0m \u001b[0mn_pages\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\requests\\models.py\u001b[0m in \u001b[0;36mjson\u001b[1;34m(self, **kwargs)\u001b[0m\n\u001b[0;32m 890\u001b[0m \u001b[1;31m# used.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 891\u001b[0m \u001b[1;32mpass\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 892\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mcomplexjson\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloads\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtext\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 893\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 894\u001b[0m \u001b[1;33m@\u001b[0m\u001b[0mproperty\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32m~\\Anaconda3\\lib\\json\\__init__.py\u001b[0m in \u001b[0;36mloads\u001b[1;34m(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)\u001b[0m\n\u001b[0;32m 352\u001b[0m \u001b[0mparse_int\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mparse_float\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m \u001b[1;32mand\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 353\u001b[0m parse_constant is None and object_pairs_hook is None and not kw):\n\u001b[1;32m--> 354\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0m_default_decoder\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 355\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mcls\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 356\u001b[0m \u001b[0mcls\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mJSONDecoder\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32m~\\Anaconda3\\lib\\json\\decoder.py\u001b[0m in \u001b[0;36mdecode\u001b[1;34m(self, s, _w)\u001b[0m\n\u001b[0;32m 337\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 338\u001b[0m \"\"\"\n\u001b[1;32m--> 339\u001b[1;33m \u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mraw_decode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0midx\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0m_w\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 340\u001b[0m \u001b[0mend\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0m_w\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 341\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mend\u001b[0m \u001b[1;33m!=\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32m~\\Anaconda3\\lib\\json\\decoder.py\u001b[0m in \u001b[0;36mraw_decode\u001b[1;34m(self, s, idx)\u001b[0m\n\u001b[0;32m 355\u001b[0m \u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mscan_once\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0midx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 356\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mStopIteration\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 357\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mJSONDecodeError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Expecting value\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0ms\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 358\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;31mJSONDecodeError\u001b[0m: Expecting value: line 4 column 1 (char 3)" ] } ], "source": [ "from datetime import datetime\n", "import pytz\n", "timestamp = pytz.utc.localize(datetime(2015, 6, 1, 12, 30))\n", "value = client.get_impact_at(timestamp, 'CAISO')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2018-12-19T02:00:12.598727Z", "start_time": "2018-12-19T02:00:12.583768Z" } }, "outputs": [], "source": [ "client.get_impact_between()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.5" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }