Skip to content
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

Use SAM to calculate power output #22

Merged
merged 52 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
b92f715
docs: Remove documented code
rouille Nov 7, 2018
0d54276
Rename file
rouille Nov 7, 2018
e940248
docs: Update documentation
rouille Nov 7, 2018
49ab73a
New file
rouille Nov 8, 2018
b6dab03
docs: Improve docstring
rouille Nov 8, 2018
689a2e4
fix: correct test on zone
rouille Nov 8, 2018
936144d
Rename file
rouille Nov 8, 2018
f3c4fd5
chore: Update __all__
rouille Nov 8, 2018
93f722b
fix: Correct leap year mismatch
rouille Nov 8, 2018
3a73c0e
style: Improve syntax
rouille Nov 9, 2018
aaba33d
Create file
rouille Nov 9, 2018
8f41ce9
chore: Add package required by SAM
rouille Nov 9, 2018
2051c24
docs: Add paragraph in Power Output Calculation section on SAM
rouille Nov 9, 2018
1996734
docs: Change main title
rouille Nov 9, 2018
90c356b
docs: Change main title
rouille Nov 9, 2018
2cb0d01
docs: Correct typos
rouille Nov 9, 2018
c828a7f
fix: Set capacity in kW as required in documentation
rouille Nov 9, 2018
30d027d
docs: Update docstring
rouille Nov 9, 2018
7ffa762
feat: Add argument to function retrieve_data
rouille Nov 9, 2018
bd3e653
docs: Add link to the API key signup page
rouille Nov 9, 2018
f656ca8
docs: Add link to API key sign up page
rouille Nov 9, 2018
dad5bef
fix: Correct link to notebook
rouille Nov 9, 2018
0057291
fix: Remove relative path
rouille Nov 13, 2018
4b2d383
feat: Change occurence of sleeping time
rouille Nov 13, 2018
8eecae8
fix: Use interconnect field to assign coefficients
rouille Nov 16, 2018
f8a4f02
Remove file
rouille Dec 19, 2018
bc21fcb
fix: Correct __all__
rouille Dec 19, 2018
76e6a11
docs: Update doc_string
rouille Dec 19, 2018
3fa0b51
style: Format titles for sphinx compatibility
rouille Dec 19, 2018
5183ef6
docs: Coreect typo
rouille Dec 19, 2018
4a2620e
docs: Improve text and format
rouille Dec 19, 2018
9f2b8f3
docs: Add param entry
rouille Dec 20, 2018
d56653d
Rename file
rouille Dec 21, 2018
ff8633d
docs: Correct typo
rouille Dec 21, 2018
345b94c
docs: Reorganize documentation
rouille Dec 21, 2018
ed83f64
docs: Update links to notebooks
rouille Dec 21, 2018
53a9ea7
fix: Remove standard library packages and add links to git repository
rouille Dec 21, 2018
fbe0b44
docs: Add section WesternInterconnectNetwork in Setup/Installation
rouille Dec 21, 2018
59436e8
Remove file
rouille Dec 21, 2018
8f0f717
Rename file
rouille Dec 21, 2018
f8b31e2
Merge branch 'fixCallToScenarioList' into sam
rouille Dec 26, 2018
5654654
fix: Add matlab
rouille Dec 26, 2018
4583981
fix: Use absolute path
rouille Dec 26, 2018
f72ae5d
Remove file
rouille Dec 26, 2018
f45fa33
fix: Use absolute path
rouille Dec 26, 2018
df3c123
docs: Add rminder on updating PYTONPATH.
rouille Dec 26, 2018
e4aaa48
docs: Correct typos
rouille Dec 26, 2018
21e1321
fix: Remove Texas case in SAM
rouille Dec 27, 2018
0aee632
fix: Add package to list
rouille Dec 27, 2018
a3bbf14
docs: Use list instead of table
rouille Dec 28, 2018
6bc6ea1
fix: Use absolute path to referred notebooks
rouille Jan 2, 2019
88edbc3
fix: Move EIA to eia
rouille Jan 9, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 81 additions & 107 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
"from dateutil.parser import parse\n",
"\n",
"import os\n",
"import sys\n",
"sys.path.append(\"..\")\n",
"\n",
"import get_eia_data"
"from prereise.gather.demanddata.eia import get_eia_data"
]
},
{
Expand Down Expand Up @@ -183,7 +181,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.6.7rc2"
}
},
"nbformat": 4,
Expand Down
Empty file.
31 changes: 17 additions & 14 deletions prereise/gather/demanddata/EIA/get_eia_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ def from_download(tok, start_date, end_date, offset_days, series_list):
"""Downloads and assemble dataset of demand data per balancing authority \
for desired date range.

:param string tok: token obtained by registering with EIA.
:param str tok: token obtained by registering with EIA.
:param timestamp start: start date.
:param timestamp end: end data.
:param list series_list: list of demand series names provided by EIA, \
e.g., ['EBA.AVA-ALL.D.H', 'EBA.AZPS-ALL.D.H'].
:param int offset_days: number of business days for data to stabilize.
:return: data frame indexed with hourly UTC time and BA series \
name for column names.
:return: (*pandas*) -- data frame indexed with hourly UTC time and BA \
series name for column names.
"""

timespan = pd.date_range(start_date,
Expand All @@ -44,12 +44,12 @@ def from_excel(directory, series_list, start_date, end_date):
"""Assembles EIA balancing authority (BA) data from pre-downloaded Excel \
spreadsheets. The spreadsheets contain data from July 2015 to present.

:param string directory: location of Excel files.
:param str directory: location of Excel files.
:param list series_list: list of BA initials, e.g., ['PSE',BPAT','CISO'].
:param timestamp start_date: desired start of dataset.
:param timestamp end_date: desired end of dataset.
:return: data frame indexed with hourly UTC time and BA series \
name for column names.
:return: (*pandas*) -- data frame indexed with hourly UTC time and BA \
series name for column names.
"""
timespan = pd.date_range(start_date, end_date, freq='H')
df_all = pd.DataFrame(index=timespan)
Expand All @@ -70,14 +70,15 @@ def from_excel(directory, series_list, start_date, end_date):


class EIAgov(object):
"""Copied from `this link <https://quantcorner.wordpress.com/\
2014/11/18/downloading-eias-data-with-python/>`_.

:param str token: EIA token.
:param list series: id code(s) of the series to be downloaded.

"""

def __init__(self, token, series):
"""Initialises the EIAgov class. Copied from \
`https://quantcorner.wordpress.com/2014/11/18/downloading-eias-data-with-python/`

:param string token: EIA token
:param list series: id code(s) of the series to be downloaded
"""

self.token = token
self.series = series

Expand Down Expand Up @@ -107,7 +108,9 @@ def raw(self, ser):
print('Reason: ', e.reason)

def get_data(self):
"""Convert json files into pandas DataFrame
"""Converts json files into data frame.

:return: (*pandas*) -- data frame.
"""

date_ = self.raw(self.series[0])
Expand Down
2 changes: 1 addition & 1 deletion prereise/gather/demanddata/EIA/test/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__all__= ["test_EIAdownload", "test_from_excel"]
__all__= ["test_eia_download", "test_from_excel"]
19 changes: 8 additions & 11 deletions prereise/gather/demanddata/EIA/test/test_eia_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,18 @@
import pandas as pd
import pytest

from .. import get_eia_data
from prereise.gather.demanddata.eia import get_eia_data


@pytest.mark.skip(reason="Need API key")
def test_eia_download():
'''
Check pandas DataFrame assembled from data download \
by API call from EIA. Test checks that the correct \
number of files are downloaded and correct number of \
columns are created.

Token string can be obtained by registering in
https://www.eia.gov/opendata/

'''
"""Check data frame assembled from data download by API call from \
EIA. Test checks that the correct number of files are downloaded and \
correct number of columns are created.

Token string can be obtained by registering \
`here <https://www.eia.gov/opendata/>`_.
"""
print(
'A API key is required for the API download. The key '
'can be obtained by a user by registering at '
Expand Down
12 changes: 5 additions & 7 deletions prereise/gather/demanddata/EIA/test/test_from_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
import pandas as pd
import pytest

from .. import get_eia_data
from prereise.gather.demanddata.eia import get_eia_data


def test_from_excel():
'''
Test pandas DataFrame assembled from Excel spreadsheets \
manually downloaded from EIA. Test checks that correct \
number of columns are created.

'''
"""Tests data frame assembled from Excel spreadsheets manually \
downloaded from EIA. Test checks that correct number of columns are \
created.
"""

dir1 = os.path.join(os.path.dirname(__file__), 'data')

Expand Down
58 changes: 29 additions & 29 deletions prereise/gather/solardata/ga_wind/demo/ga_wind_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,16 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from westernintnet.westernintnet import WesternIntNet\n",
"import sys\n",
"\n",
"sys.path.append(\"../\")\n",
"\n",
"import ga_wind\n",
"from matplotlib import pyplot\n",
"from helpers import to_reise"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Solar Plants in Network"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\program files\\python\\python36\\lib\\site-packages\\matplotlib\\__init__.py:886: MatplotlibDeprecationWarning: \n",
"examples.directory is deprecated; in the future, examples will be found relative to the 'datapath' directory.\n",
" \"found relative to the 'datapath' directory.\".format(key))\n"
]
},
{
"name": "stdout",
"output_type": "stream",
Expand All @@ -56,16 +42,30 @@
"Loading branches\n",
"Loading resources\n",
"Loading net_generation\n",
"Load solar data\n",
"Load wind data\n",
"Load hydro data\n",
"Load demand data\n",
"Done loading\n"
]
}
],
"source": [
"grid = WesternIntNet()\n",
"from westernintnet.westernintnet import win_data as grid\n",
"from prereise.gather.solardata.ga_wind import ga_wind, helpers\n",
"\n",
"from matplotlib import pyplot"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Solar Plants in Network"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"solar_plant = grid.genbus.groupby('type').get_group('solar')"
]
},
Expand Down Expand Up @@ -653,7 +653,7 @@
"metadata": {},
"outputs": [],
"source": [
"data_reise = to_reise(data)"
"data_reise = helpers.to_reise(data)"
]
},
{
Expand Down
15 changes: 8 additions & 7 deletions prereise/gather/solardata/ga_wind/ga_wind.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pandas as pd
from tqdm import tqdm

from .helpers import ll2ij
from prereise.gather.solardata.ga_wind import helpers


def retrieve_data(solar_plant, hs_api_key,
Expand All @@ -15,11 +15,12 @@ def retrieve_data(solar_plant, hs_api_key,
"""Retrieve irradiance data from Gridded Atmospheric Wind Integration \
National Dataset.

:param solar_plant: pandas DataFrame with the following structure: \
['plantID'(index), 'lat', 'lon', 'GenMWMax'].
:param year: year.
:return: pandas DataFrame with the following structure: ['Pout', \
'plantID', 'ts', 'tsID']. The power output is in MW.
:param pandas solar_plant: data frame with *'lat'*, *'lon'* and \
*'GenMWMax'* and *'plantID'* as indices.
:param str hs_api_key: API key.
:param str year: year.
:return: (*pandas*) -- data frame with *'Pout'*, *'plantID'*, *'ts'* and \
*'tsID'* as columns. The power output is in MWh.
"""

# Information on solar plants
Expand Down Expand Up @@ -52,7 +53,7 @@ def retrieve_data(solar_plant, hs_api_key,
lat_origin, lon_origin = f['coordinates'][0][0]
ij = {}
for key in coord.keys():
ij[key] = ll2ij(lon_origin, lat_origin, key[0], key[1])
ij[key] = helpers.ll2ij(lon_origin, lat_origin, key[0], key[1])

# Extract time serie
dt = f['datetime']
Expand Down
12 changes: 6 additions & 6 deletions prereise/gather/solardata/ga_wind/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
def ll2ij(lon_origin, lat_origin, lon, lat):
"""Find nearest x/y indices for a given lat/lon.

:param lat: Latitude of coordinate of interest.
:param lon: Longitude of coordinate of interest.
:return: coordinate of the closest pixel in the database.
:param float lat: Latitude of coordinate of interest.
:param float lon: Longitude of coordinate of interest.
:return: (*tuple*) -- coordinate of the closest pixel in the database.
"""

proj_string = """+proj=lcc +lat_1=30 +lat_2=60
Expand All @@ -32,9 +32,9 @@ def ll2ij(lon_origin, lat_origin, lon, lat):
def to_reise(data):
"""Format data for REISE.

:param data: pandas DataFrame as returned by \
:py:func:`prereise.gather.solardata.ga_wind.ga_wind.retrieve_data`.
:return: pandas DataFrame formated for REISE.
:param pandas data: pandas data frame as returned by \
:func:`prereise.gather.solardata.ga_wind.ga_wind.retrieve_data`.
:return: (*pandas*) data frame formated for REISE.
"""
ts = data['ts'].unique()
plantID = data[data.tsID == 1].plantID.values
Expand Down
2 changes: 1 addition & 1 deletion prereise/gather/solardata/nsrdb/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__all__ = ["helpers", "nsrdb"]
__all__ = ["helpers", "naive", "sam"]
Loading