-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue/get india data #127
Open
rachel-labri-tipton
wants to merge
16
commits into
main
Choose a base branch
from
issue/get-india-data
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Issue/get india data #127
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
59e28f3
add jupyter notebook for india
rachel-labri-tipton 5d704b3
add india notebook
rachel-labri-tipton 84773df
india notebook pulling data
rachel-labri-tipton 295d78f
get system_ids for india
rachel-labri-tipton 60ad2ef
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d9d0ad1
add updated get_india_data
rachel-labri-tipton b7b2916
add updated PVOutput class
rachel-labri-tipton 9f17bb8
add updated fetch_pv_timeseries script
rachel-labri-tipton ad41667
updates after resolved merge conflicts
rachel-labri-tipton f3837e1
comment out call to get_statistic_route because unavailable
rachel-labri-tipton ec8cdbf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d44b86c
remove ocf-research account data
rachel-labri-tipton 7693349
Merge branch 'issue/get-india-data' of https://github.com/openclimate…
rachel-labri-tipton 7afeb06
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 386fe5e
add Gant chart of data availability
rachel-labri-tipton acac46b
Merge branch 'issue/get-india-data' of https://github.com/openclimate…
rachel-labri-tipton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Get metadata for all systems in a country \n", | ||
"\n", | ||
"#### (excluding AU, US, NL, UK and DE) \n", | ||
"\n", | ||
"- Makes a request to the Get Country System Service - World.\n", | ||
"- For more information on this route, [see pvoutput.org API documentation](https://pvoutput.org/help/data_services.html#get-country-system-service). \n", | ||
"\n", | ||
"- The request being run by this notebook looks like this: ```https://pvoutput.org/data/r2/getcountrysystem.jsp?c={country_code}&from={start_id_range}&to={end_id_range}```, where ```country_code``` is the code for the country found in the docs and ```from``` and ```to``` are a range queried for system ids. \n", | ||
"\n", | ||
"- NB: The maximum range of the \"from\" and \"to\" parameters is 20000.\n", | ||
"\n", | ||
"**2023-11-06**" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Setup" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import sys\n", | ||
"import pandas as pd\n", | ||
"\n", | ||
"sys.path.append(\"..\")\n", | ||
"from pvoutput.pvoutput import PVOutput" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# set up pvoutput environment variables \n", | ||
"# API_KEY is the key provided via the pvoutput.org account used\n", | ||
"# SYSTEM_ID is the system_id connected to your account on pvoutput.org\n", | ||
"api_key = \"API_KEY\"\n", | ||
"system_id = \"SYSTEM_ID\"\n", | ||
"data_service_url = \"https://pvoutput.org\"\n", | ||
"country_code=\"COUNTRY_CODE\" # get from pvoutput.org, e.g. \"in\" for India\n", | ||
"pv = PVOutput(api_key=api_key, system_id=system_id, data_service_url=data_service_url)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 26, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# set up a directory locally to store data \n", | ||
"CACHE_DIR = \"../examples/pv_data\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Create csv file with metadata from country systems. \n", | ||
"\n", | ||
"Could be useful to check the Get Country System Service [documentation](https://pvoutput.org/help/data_services.html#get-country-system-service) for data specifications." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# set up a list of ranges to check for system ids and metadat\n", | ||
"start_id_range = list(range(1, 120000, 20000))\n", | ||
"end_id_range = list(range(20000, 140000, 20000))\n", | ||
"\n", | ||
"# get system metadata for a country\n", | ||
"def get_system_metadata_by_country(start_id_range=start_id_range, end_id_range=end_id_range):\n", | ||
" frames = []\n", | ||
" i=0\n", | ||
" while i < len(start_id_range) and i < len(end_id_range):\n", | ||
" df = pv.get_metadata_for_country(country_code={country_code}, start_id_range=start_id_range[i], end_id_range=end_id_range[i], use_data_service=True)\n", | ||
" frames.append(df)\n", | ||
" i+=1\n", | ||
" df= pd.concat(frames)\n", | ||
" df.to_csv(f\"{CACHE_DIR}/example.csv\", index=False)\n", | ||
" return df\n", | ||
"\n", | ||
"get_system_metadata_by_country(start_id_range=start_id_range, end_id_range=end_id_range)\n", | ||
"\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "pvoutput-venv", | ||
"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.10.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to put this back in, and add a comment saying,
if you dont have access to XXX API route, then comment this bit out
Or something like that