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

Fix URDBv7_to_ElectricityRates #100

Merged
merged 1 commit into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 9 additions & 7 deletions files/ResourceTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ def try_get_demand_structure(urdb_name, data_name):
month_row += [p[i] for i in (1, 2, 3)]
flat_mat.append(month_row)
urdb_data['ur_dc_flat_mat'] = flat_mat
elif "demandratestructure" not in urdb_response.keys():
elif "demandratestructure" in urdb_response.keys():
urdb_data['ur_dc_enable'] = 1
else:
urdb_data['ur_dc_enable'] = 0

if urdb_data['ur_dc_enable'] == 1 and "ur_dc_tou_mat" not in urdb_data.keys():
Expand All @@ -251,36 +253,36 @@ class FetchResourceFiles():
Download solar and wind resource files from NREL developer network
https://developer.nrel.gov/.

:param str tech: *Required* Name of technology.
:param str tech: *Required* Name of technology.
'wind' for NREL WIND Toolkit at https://developer.nrel.gov/docs/wind/wind-toolkit/wtk-download/.
'solar' for NREL NSRDB at https://developer.nrel.gov/docs/solar/nsrdb/nsrdb_data_query/

!param str nrel_api_key: *Required* NREL developer API key, available at https://developer.nrel.gov/signup/.

:param str nrel_api_email: *Required* Email address associated with nrel_api_key.

:param str resource_dir: Directory to store downloaded files.
:param str resource_dir: Directory to store downloaded files.
Default = 'None', which results in `data/PySAM Downloaded Weather Files`.

:param int workers: Number of threads to use when parellelizing downloads.
Default = 1.

:param str resource_type: Name of API for NSRDB solar data.
Default = 'psm3-tmy' for solar, '' for wind.
:param str resource_type: Name of API for NSRDB solar data.
Default = 'psm3-tmy' for solar, '' for wind.
'psm3' for 30- or 60-minute single-year file
'psm3-tmy' for 60-minute TMY, TGY, or TDY typical-year file
'psm3-5min' for 5-, 30- or 60-minute single-year file
'' for WIND Toolkit

:param str resource_year: Data year, changes over time so check API documentation for latest information.
:param str resource_year: Data year, changes over time so check API documentation for latest information.
Default = 'tmy' for solar, '2014' for wind.
'1998' to '2019', etc. for NSRDB psm3
'tmy' for latest TMY file from NSRDB psm3-tmy
'tmy-2016' to 'tmy-2018', etc. for NSRDB psm3-tmy
'2018', etc. for NSRDB psm3-5min
'2007' to '2014' for WIND Toolkit

:param int resource_interval_min: Time interval of resource data in minutes. See available intervals under `resource_type` above.
:param int resource_interval_min: Time interval of resource data in minutes. See available intervals under `resource_type` above.
Default = 60.

:param int resource_height: For wind only, wind resource measurement height above ground in meters.
Expand Down
24 changes: 24 additions & 0 deletions tests/test_ResourceTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,30 @@ def test_urdb():
assert(flat_mat_tested == flat_mat)


def test_urdb_2():
urdb = str(Path(__file__).parent / "urdbv7.json")
with open(urdb, 'r') as file:
urdb_data = json.load(file)
urdb_data.pop("flatdemandmonths")
ur5 = tools.URDBv7_to_ElectricityRates(urdb_data)

ec_tou = [1, 1, 100, 0, 0.070768997073173523, 0,
1, 2, 9.9999996802856925e+37, 0, 0.082948997616767883, 0,
2, 1, 100, 0, 0.056908998638391495, 0,
2, 2, 9.9999996802856925e+37, 0, 0.069078996777534485, 0]

dc_tou = [1, 1, 100, 19.538999557495117,
1, 2, 9.9999996802856925e+37, 13.093000411987305,
2, 1, 100, 8.0909996032714844,
2, 2, 9.9999996802856925e+37, 4.6760001182556152]

ec_tou_tested = [item for sublist in ur5['ur_ec_tou_mat'] for item in sublist]
dc_tou_tested = [item for sublist in ur5['ur_dc_tou_mat'] for item in sublist]

assert(ec_tou_tested == ec_tou)
assert(dc_tou_tested == dc_tou)


def test_resourcefilefetcher():

# please get your own API key from here https://developer.nrel.gov/signup/
Expand Down