Skip to content

Commit

Permalink
add india notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-labri-tipton committed Oct 23, 2023
1 parent 59e28f3 commit 5d704b3
Showing 1 changed file with 105 additions and 5 deletions.
110 changes: 105 additions & 5 deletions examples/get_india_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"import requests\n",
"import pandas as pd\n",
"import geopandas as gpd\n",
"from matplotlib import pyplot as plt\n",
Expand All @@ -35,19 +36,118 @@
{
"cell_type": "markdown",
"metadata": {},
"source": []
"source": [
"### Sites to get data from:\n",
"\n",
"Jaycee: 85738; BMT: 56151; 25 FM Grid Tie: 87410; FlinEnergy Infini 5k: 78186; Ind Moz: 10045; Little Tree: 90559; Solar 183: 60294"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"api_key = \"3f784ff6cfa27c44436f88da0c429b410687ad14\"\n",
"system_id = \"68732\"\n",
"date = \"20230801\"\n",
"site_id = \"\"\n",
"data_service_url = \"https://pvoutput.org/data/r2/getsystemstatus.jsp\"\n",
"# pv = PVOutput(api_key, system_id, data_service_url=data_service_url)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": []
"source": [
"CACHE_DIR = \"/tmp\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Working curl request\n",
"\n",
"curl -H \"X-Pvoutput-Apikey: 3f784ff6cfa27c44436f88da0c429b410687ad14\" -H \"X-Pvoutput-SystemId: 68732\" https://pvoutput.org/data/r2/getsystemstatus.jsp\\?dt\\=20230801\\&sid1\\=87410"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "invalid syntax (2245105558.py, line 3)",
"output_type": "error",
"traceback": [
"\u001b[0;36m Cell \u001b[0;32mIn[38], line 3\u001b[0;36m\u001b[0m\n\u001b[0;31m curl -H \"X-Pvoutput-Apikey: 3f784ff6cfa27c44436f88da0c429b410687ad14\" -H \"X-Pvoutput-SystemId: 68732\" https://pvoutput.org/data/r2/getsystemstatus.jsp\\?dt\\=20230801\\&sid1\\=87410\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
]
}
],
"source": [
"# Get the data from PVOutput\n",
"# sites = [85738, 56151, 87410, 78186, 100451, 90559, 60294]\n",
"request = curl -H \"X-Pvoutput-Apikey: 3f784ff6cfa27c44436f88da0c429b410687ad14\" -H \"X-Pvoutput-SystemId: 68732\" https://pvoutput.org/data/r2/getsystemstatus.jsp\\?dt\\=20230801\\&sid1\\=87410\n",
"dfs = []\n",
"url = \"https://pvoutput.org/data/r2/getsystemstatus.jsp\\?dt\\=20230801\\&sid1\\=87410\"\n",
"headers = {api_key, system_id}\n",
"r = requests.get(url, headers=headers)\n"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"ename": "JSONDecodeError",
"evalue": "Expecting value: line 1 column 1 (char 0)",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mJSONDecodeError\u001b[0m Traceback (most recent call last)",
"File \u001b[0;32m~/anaconda3/envs/pvoutput-venv/lib/python3.10/site-packages/requests/models.py:971\u001b[0m, in \u001b[0;36mResponse.json\u001b[0;34m(self, **kwargs)\u001b[0m\n\u001b[1;32m 970\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--> 971\u001b[0m \u001b[39mreturn\u001b[39;00m complexjson\u001b[39m.\u001b[39;49mloads(\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mtext, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m 972\u001b[0m \u001b[39mexcept\u001b[39;00m JSONDecodeError \u001b[39mas\u001b[39;00m e:\n\u001b[1;32m 973\u001b[0m \u001b[39m# Catch JSON-related errors and raise as requests.JSONDecodeError\u001b[39;00m\n\u001b[1;32m 974\u001b[0m \u001b[39m# This aliases json.JSONDecodeError and simplejson.JSONDecodeError\u001b[39;00m\n",
"File \u001b[0;32m~/anaconda3/envs/pvoutput-venv/lib/python3.10/json/__init__.py:346\u001b[0m, in \u001b[0;36mloads\u001b[0;34m(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)\u001b[0m\n\u001b[1;32m 343\u001b[0m \u001b[39mif\u001b[39;00m (\u001b[39mcls\u001b[39m \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m object_hook \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m\n\u001b[1;32m 344\u001b[0m parse_int \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m parse_float \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m\n\u001b[1;32m 345\u001b[0m parse_constant \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m object_pairs_hook \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m \u001b[39mnot\u001b[39;00m kw):\n\u001b[0;32m--> 346\u001b[0m \u001b[39mreturn\u001b[39;00m _default_decoder\u001b[39m.\u001b[39;49mdecode(s)\n\u001b[1;32m 347\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mcls\u001b[39m \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n",
"File \u001b[0;32m~/anaconda3/envs/pvoutput-venv/lib/python3.10/json/decoder.py:337\u001b[0m, in \u001b[0;36mJSONDecoder.decode\u001b[0;34m(self, s, _w)\u001b[0m\n\u001b[1;32m 333\u001b[0m \u001b[39m\u001b[39m\u001b[39m\"\"\"Return the Python representation of ``s`` (a ``str`` instance\u001b[39;00m\n\u001b[1;32m 334\u001b[0m \u001b[39mcontaining a JSON document).\u001b[39;00m\n\u001b[1;32m 335\u001b[0m \n\u001b[1;32m 336\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[0;32m--> 337\u001b[0m obj, end \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mraw_decode(s, idx\u001b[39m=\u001b[39;49m_w(s, \u001b[39m0\u001b[39;49m)\u001b[39m.\u001b[39;49mend())\n\u001b[1;32m 338\u001b[0m end \u001b[39m=\u001b[39m _w(s, end)\u001b[39m.\u001b[39mend()\n",
"File \u001b[0;32m~/anaconda3/envs/pvoutput-venv/lib/python3.10/json/decoder.py:355\u001b[0m, in \u001b[0;36mJSONDecoder.raw_decode\u001b[0;34m(self, s, idx)\u001b[0m\n\u001b[1;32m 354\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mStopIteration\u001b[39;00m \u001b[39mas\u001b[39;00m err:\n\u001b[0;32m--> 355\u001b[0m \u001b[39mraise\u001b[39;00m JSONDecodeError(\u001b[39m\"\u001b[39m\u001b[39mExpecting value\u001b[39m\u001b[39m\"\u001b[39m, s, err\u001b[39m.\u001b[39mvalue) \u001b[39mfrom\u001b[39;00m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m 356\u001b[0m \u001b[39mreturn\u001b[39;00m obj, end\n",
"\u001b[0;31mJSONDecodeError\u001b[0m: Expecting value: line 1 column 1 (char 0)",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[0;31mJSONDecodeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/Users/dragonflyiterations/Desktop/open-climate-fix/pvoutput/pvoutput/examples/get_india_data.ipynb Cell 9\u001b[0m line \u001b[0;36m3\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/dragonflyiterations/Desktop/open-climate-fix/pvoutput/pvoutput/examples/get_india_data.ipynb#X13sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m r\u001b[39m.\u001b[39mstatus_code\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/dragonflyiterations/Desktop/open-climate-fix/pvoutput/pvoutput/examples/get_india_data.ipynb#X13sZmlsZQ%3D%3D?line=1'>2</a>\u001b[0m r\u001b[39m.\u001b[39mtext\n\u001b[0;32m----> <a href='vscode-notebook-cell:/Users/dragonflyiterations/Desktop/open-climate-fix/pvoutput/pvoutput/examples/get_india_data.ipynb#X13sZmlsZQ%3D%3D?line=2'>3</a>\u001b[0m r\u001b[39m.\u001b[39;49mjson()\n",
"File \u001b[0;32m~/anaconda3/envs/pvoutput-venv/lib/python3.10/site-packages/requests/models.py:975\u001b[0m, in \u001b[0;36mResponse.json\u001b[0;34m(self, **kwargs)\u001b[0m\n\u001b[1;32m 971\u001b[0m \u001b[39mreturn\u001b[39;00m complexjson\u001b[39m.\u001b[39mloads(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mtext, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs)\n\u001b[1;32m 972\u001b[0m \u001b[39mexcept\u001b[39;00m JSONDecodeError \u001b[39mas\u001b[39;00m e:\n\u001b[1;32m 973\u001b[0m \u001b[39m# Catch JSON-related errors and raise as requests.JSONDecodeError\u001b[39;00m\n\u001b[1;32m 974\u001b[0m \u001b[39m# This aliases json.JSONDecodeError and simplejson.JSONDecodeError\u001b[39;00m\n\u001b[0;32m--> 975\u001b[0m \u001b[39mraise\u001b[39;00m RequestsJSONDecodeError(e\u001b[39m.\u001b[39mmsg, e\u001b[39m.\u001b[39mdoc, e\u001b[39m.\u001b[39mpos)\n",
"\u001b[0;31mJSONDecodeError\u001b[0m: Expecting value: line 1 column 1 (char 0)"
]
}
],
"source": [
"r.status_code\n",
"r.text\n",
"r.json()\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "pvoutput-venv",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 5d704b3

Please sign in to comment.