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

Remove network calls from tests #204

Closed
wants to merge 136 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
766ac1c
Added ORBIT citation and references. Commented each function, citing …
nRiccobo Feb 17, 2023
161d9ea
last comment changes
nRiccobo Feb 23, 2023
2af5f61
reformat plots, generate paths for plots, add onshore substation to p…
jaredthomas68 Apr 13, 2023
3c1e489
on-turbine pressure vessel visualization. updates to grid only
jaredthomas68 Apr 13, 2023
c53940e
fix plot. fix grid-only
jaredthomas68 Apr 17, 2023
2563117
correct power, correct technology usage
jaredthomas68 Apr 18, 2023
180d9b2
Added Floating Platform Model and testsl
Apr 21, 2023
b5c7cdb
initial code for custom orbit layout
jaredthomas68 Apr 21, 2023
9b9f50d
use custome layout for ORBIT and FLORIS - IN PROGRESS
jaredthomas68 Apr 24, 2023
77ea4d4
correct visualization given different h2 storage types on turbine
jaredthomas68 Apr 24, 2023
d1b808c
updates to example simulation file
jaredthomas68 Apr 25, 2023
c7b5254
Updated Floating Platform Model and tests
Jun 1, 2023
84c72cc
Merge branch 'NREL:feature/offshore-h2' into feature/offshore-h2
ckiefer14 Jun 7, 2023
bdf9643
Update to fixed and floating platform models, Add test for Floating, …
Jun 7, 2023
10e737a
Update to fixed and floating platform models, Add test for Floating, …
Jun 7, 2023
3eace51
Merge branch 'feature/offshore-h2' of https://github.com/NREL/HOPP in…
nRiccobo Jun 12, 2023
5b5bc23
Updated test section to work with ORBIT 1.06
nRiccobo Jun 12, 2023
212e3b6
Fixed equation ref. comment
nRiccobo Jun 21, 2023
f26ee0d
Call to SemiTaut Branch in Orbit to pull mooring costs, Update to the…
Jun 29, 2023
7ebc209
Added new plotting script to show all years and locations on the same…
ereznicek Jul 6, 2023
fbd0797
Add sources to test files, Update floating cost to match ORBIT Techni…
Jul 7, 2023
edcc534
Added a script to plot regional sensitivity
ereznicek Jul 7, 2023
ad0f88e
Improved regional sensitivity plotting script
ereznicek Jul 10, 2023
34d72b5
Update to source information for test files
Jul 11, 2023
4237708
Merge branch 'feature/green_steel_ammonia' into refactor/green_steel_…
cfrontin Jul 13, 2023
813cafa
minor modifications to example
jaredthomas68 Jul 13, 2023
084396d
Remove Project code
Jul 14, 2023
aaf058a
working on refactor... broken scripts.
cfrontin Jul 14, 2023
f04f870
Merge pull request #136 from ckiefer14/feature/green_steel_ammonia
jaredthomas68 Jul 14, 2023
bbb8faf
examples/H2_Analysis removed, replaced with temp hopp/to_organize sub…
cfrontin Jul 14, 2023
554a05f
Move LCA_green_steel and ProFAST files to Project repo
Jul 18, 2023
58a2694
Merge pull request #128 from ckiefer14/feature/offshore-h2
jaredthomas68 Jul 18, 2023
cd03224
Merge pull request #138 from ckiefer14/feature/green_steel_ammonia
jaredthomas68 Jul 18, 2023
df7a5cd
changes induced by move to project repo
cfrontin Jul 19, 2023
fdb54d0
improved project/software splits, coupled with greensteel commit: c9f…
cfrontin Jul 19, 2023
4e464f5
Add clarity to depth limitation on example_floating_project.yaml and …
Jul 19, 2023
018020b
merge cfrontin and ckiefer work
jaredthomas68 Jul 20, 2023
212dc6e
Merge branch 'cfrontin-refactor/green_steel_ammonia' into green_steel…
jaredthomas68 Jul 20, 2023
ea5c40b
Merge branch 'feature/offshore-h2' into feature/offshore-h2
jaredthomas68 Jul 20, 2023
74d4363
Merge pull request #107 from nRiccobo/feature/offshore-h2
jaredthomas68 Jul 20, 2023
6fdc507
Merge branch 'feature/offshore-h2' of github.com:NREL/HOPP into featu…
jaredthomas68 Jul 20, 2023
5305fb2
merge green_steel_cleanup into offshore-h2
jaredthomas68 Jul 20, 2023
bc948e9
Remove project codes and move software codes into HOPP/hopp/to_organi…
Jul 20, 2023
6c23f5f
Merge pull request #140 from ckiefer14/green_steel_cleanup
jaredthomas68 Jul 20, 2023
1724ec2
Update import statements and import files that other files depend on
Jul 25, 2023
4441baa
removing duplicate base.py
bayc Jul 25, 2023
e8f5c62
reinstante hopp_for_h2_floris.py
cfrontin Jul 25, 2023
d7c891c
hotfix to make refactored floris compatible with old run scripts.
cfrontin Jul 27, 2023
93bc26e
Merge remote-tracking branch 'upstream/green_steel_cleanup' into gree…
cfrontin Jul 27, 2023
f322f50
fix hopp_tools_steel
cfrontin Jul 27, 2023
d57d9ac
Update import statements to paths already in repo
Jul 27, 2023
bfc1727
Restore LCA_single_scenario_Profast.py as run_profast_for_hydrogen.py…
Jul 27, 2023
41fd125
Remove Duplicates, update import statements
Jul 28, 2023
a180ca7
Merge pull request #143 from cfrontin/green_steel_cleanup
jaredthomas68 Jul 28, 2023
88ff311
Test file restore with history
Jul 28, 2023
6b3f790
Delete Test move
Jul 28, 2023
4d0f461
Rename of Test file move
Jul 28, 2023
b35bd97
Test
Jul 28, 2023
c667c60
Test 2
Jul 28, 2023
c274b9f
Test
Jul 28, 2023
e383f54
Move H2_Analysis files to this branch with history
Jul 28, 2023
b42e7ab
Test
Jul 28, 2023
26fdfc9
Test
Jul 28, 2023
467e8a8
test
Jul 28, 2023
cfbbcaa
Move H2_Analysis files that keep history from feature/green_steel_amm…
Jul 28, 2023
c7d9683
Test
Jul 28, 2023
21e2d00
Restore run_profast scripts with history
Jul 28, 2023
591b71e
Move LCA_single_scenario files into to organize and keep history
Jul 28, 2023
398ee51
Removed files that had no history and replaced them in commit before …
Jul 28, 2023
924b4a2
Updated import statments to restored files with history
Jul 28, 2023
fc80d98
Deleted duplicate files that had no history with them/Replaced in to_…
Jul 28, 2023
66989b0
Update import statements to direct to files in to_organize2
Jul 29, 2023
91b9946
comments
jaredthomas68 Jul 31, 2023
47ed611
Merge branch 'feature/offshore-h2' into green_steel_cleanup
jaredthomas68 Jul 31, 2023
6bb4557
moving towards better separation.
cfrontin Jul 31, 2023
7c126dd
correct how the fixed platform is being used
jaredthomas68 Jul 31, 2023
3a05dcd
check ORBIT for already registered FlexPlatformDesign and FixedPlatfo…
jaredthomas68 Jul 31, 2023
9506a41
Update CI Action to run on PRs (#151)
camirmas Jul 31, 2023
aa9b428
correct typo
jaredthomas68 Aug 1, 2023
2f16f70
remove old print statements
jaredthomas68 Aug 1, 2023
20cf68a
i think green steel openmdao version is working.
cfrontin Aug 1, 2023
cb814b2
Merge pull request #141 from ckiefer14/green_steel_cleanup
jaredthomas68 Aug 1, 2023
677fd38
Merge remote-tracking branch 'origin/green_steel_cleanup' into green_…
jaredthomas68 Aug 1, 2023
a302d07
Revised comments on floating project depth limitations
Aug 1, 2023
1d2ec16
correct merge conflict
jaredthomas68 Aug 1, 2023
6f8f323
Merge pull request #139 from ckiefer14/feature/offshore-h2
jaredthomas68 Aug 1, 2023
200cd0f
Merge branch 'feature/offshore-h2' into green_steel_cleanup
jaredthomas68 Aug 1, 2023
5e6567f
Merge remote-tracking branch 'upstream/green_steel_cleanup' into gree…
cfrontin Aug 1, 2023
a1ff561
sanitizing my branch to match upstream
cfrontin Aug 1, 2023
aa1e0ab
restore run rodeo
cfrontin Aug 1, 2023
edceca3
move run rodeo
cfrontin Aug 1, 2023
7d800fe
break out distributed pipe cost.
cfrontin Aug 1, 2023
4db3bd1
mv dist pipe cost.
cfrontin Aug 1, 2023
76e828e
working on getting tests running
jaredthomas68 Aug 1, 2023
390b297
working toward reconciliation w/ ckiefer
cfrontin Aug 1, 2023
8d47e9f
removed all of to_organize2, history preserved in to_organize with .
cfrontin Aug 2, 2023
d676f47
trying to get tests to run under pytest
jaredthomas68 Aug 2, 2023
b172d08
typo fix
cfrontin Aug 2, 2023
dc1ffb6
getting more tests running
jaredthomas68 Aug 2, 2023
b28b915
Merge remote-tracking branch 'origin/dev/refactor' into green_steel_c…
jaredthomas68 Aug 2, 2023
b75636d
improved nrel api handling, trailing whitespace removal.
cfrontin Aug 2, 2023
89ea455
Merge branch 'master' into green_steel_cleanup
jaredthomas68 Aug 2, 2023
e5eb190
add orbit to requirements
jaredthomas68 Aug 2, 2023
a7e17a0
working on getting Avangrid code to run
jaredthomas68 Aug 2, 2023
0d55872
correct orbit requirement line
jaredthomas68 Aug 2, 2023
45da1e1
add pyaml-include to requirements
jaredthomas68 Aug 2, 2023
22cb997
adding charles's fix.
cfrontin Aug 4, 2023
88a040a
update hopp for h2 floris
cfrontin Aug 4, 2023
2f16962
Merge remote-tracking branch 'upstream/green_steel_cleanup' into gree…
cfrontin Aug 4, 2023
62d97d4
enable scaling wind farm costs to expected wind farm capex
jaredthomas68 Aug 7, 2023
7f9b361
Merge pull request #155 from cfrontin/green_steel_cleanup
jaredthomas68 Aug 7, 2023
2bed4c7
ignore all pycache directories at all levels
jaredthomas68 Aug 8, 2023
8216fd2
remove obsolete shapely version spec
jaredthomas68 Aug 8, 2023
c68c9bf
change which desal model is being called
jaredthomas68 Aug 8, 2023
a82a54d
allow expected_plant_costs to be missing in plant_config
jaredthomas68 Aug 8, 2023
c667c46
Merge pull request #156 from NREL/feature/offshore-h2
jaredthomas68 Aug 8, 2023
cb328b2
added option for run_h2_PEM model to use IVcurve model.
cfrontin Aug 9, 2023
86a0d86
Merge remote-tracking branch 'upstream/green_steel_cleanup' into gree…
cfrontin Aug 9, 2023
b3b057b
fix conflict w/ pull
cfrontin Aug 9, 2023
b79fa5e
update .gitignore
jaredthomas68 Aug 9, 2023
252f2ff
less some plots, eco example working.
cfrontin Aug 9, 2023
34adb51
remove comments
cfrontin Aug 9, 2023
beb7f97
Merge pull request #159 from cfrontin/green_steel_cleanup
jaredthomas68 Aug 10, 2023
43580d5
Merge remote-tracking branch 'origin/green_steel_cleanup' into green_…
jaredthomas68 Aug 10, 2023
e1611cb
Added and changed some files to get green steel code to work
ereznicek Aug 10, 2023
026548d
Fixed an issue with storage ITC in run_profast_for_hydrogen.py
ereznicek Aug 11, 2023
9004508
Merge pull request #161 from ereznicek/green_steel_cleanup
jaredthomas68 Aug 15, 2023
2e0d3f1
Merge remote-tracking branch 'origin/green_steel_cleanup' into green_…
jaredthomas68 Aug 15, 2023
065981e
Cleanup + test fixes (#189)
camirmas Aug 21, 2023
f8c3174
Revert "Update __init__.py (#194)"
camirmas Aug 21, 2023
dec83a6
Merge branch 'green_steel_cleanup' of https://github.com/NREL/HOPP in…
camirmas Aug 21, 2023
cb51d61
Refactor SiteInfo class
camirmas Aug 22, 2023
ec833ce
Remove double-negatives in SiteInfo
camirmas Aug 22, 2023
12d46d4
Merge branch 'dev/refactor' of https://github.com/NREL/HOPP into site…
camirmas Aug 22, 2023
f8b3b00
Remove network calls from tests
camirmas Aug 23, 2023
c32e7f7
Merge branch 'dev/refactor' of https://github.com/NREL/HOPP into reso…
camirmas Aug 23, 2023
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
- name: Unit tests
run: |
pip install pytest
pip install responses
PYTHONPATH=. pytest tests
- name: Lint with flake8
run: |
Expand Down
5 changes: 4 additions & 1 deletion hopp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
with open(Path(__file__).parent / "version.py") as _version_file:
__version__ = _version_file.read().strip()

ROOT_DIR = Path(__file__).resolve().parent
ROOT_DIR = Path(__file__).resolve().parent

# environment variable used to specify a testing environment
TEST_ENV_VAR="TEST"
8 changes: 5 additions & 3 deletions hopp/simulation/technologies/layout/flicker_mismatch.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from typing import List, Union, Optional, Sequence
import multiprocessing_on_dill as mp
from pathlib import Path
import functools
import copy
from itertools import product
import sys

import multiprocessing_on_dill as mp
import functools
import matplotlib.pyplot as plt
sys.path.append('.')

Expand All @@ -13,6 +14,7 @@
from pvmismatch import pvsystem
import PySAM.Pvwattsv8 as pv

from hopp import ROOT_DIR
from hopp.utilities.log import flicker_logger as logger
from hopp.simulation.technologies.resource import SolarResource
from hopp.simulation.technologies.layout.shadow_flicker import get_sun_pos, get_turbine_shadows_timeseries, create_pv_string_points
Expand Down Expand Up @@ -167,7 +169,7 @@ def _setup_irradiance(self):
pv_model.SystemDesign.gcr = .1
if self.solar_resource_data is None:
filename = str(self.lat) + "_" + str(self.lon) + "_psmv3_60_2012.csv"
weather_path = Path(__file__).parent.parent.parent / "resource_files" / "solar" / filename
weather_path = ROOT_DIR.parent / "resource_files" / "solar" / filename
if not weather_path.is_file():
SolarResource(self.lat, self.lon, year=2012)
if not weather_path.is_file():
Expand Down
15 changes: 9 additions & 6 deletions hopp/simulation/technologies/utility_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@

from hopp.utilities.keys import get_developer_nrel_gov_key

URDB_BASE_URL = "https://api.openei.org/utility_rates"

class UtilityRate:
"""
Class to define a utility rate and interact with the Utility Rate Database (URDB)
https://api.openei.org/utility_rates?version=7&format=json&detail=full&getpage={urdb_label}&api_key={api_key}'
"""
def __init__(self, path_rates, urdb_label):
def __init__(self, path_rates, urdb_label, api_key=None):
self.path_rates = path_rates
self.urdb_label = urdb_label
self.api_key = api_key or get_developer_nrel_gov_key()

@property
def urdb_url(self):
return f"{URDB_BASE_URL}?version=7&format=json&detail=full&getpage={self.urdb_label}&api_key={self.api_key}"

def get_urdb_response(self):
file_exists = False
Expand All @@ -21,11 +27,8 @@ def get_urdb_response(self):
file_exists = os.path.exists(file_urdb_json)
results = None
if not file_exists and self.urdb_label is not None:
urdb_url = 'https://api.openei.org/utility_rates?version=7&format=json&detail=full&getpage={urdb_label}&api_key={api_key}'.format(
urdb_label=self.urdb_label, api_key=get_developer_nrel_gov_key())

# since NREL can't figure out its certificate
resp = requests.get(urdb_url, verify=False)
resp = requests.get(self.urdb_url, verify=False)

if resp.ok:
results = json.loads(resp.text, strict=False)
Expand All @@ -34,7 +37,7 @@ def get_urdb_response(self):
with open(file_urdb_json, 'w') as fp:
json.dump(obj=results, fp=fp)
self.urdb_response = results
elif os.path.exists(file_urdb_json):
elif file_exists:
with open(file_urdb_json, 'r') as fp:
results = json.load(fp=fp)
self.results = results
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pytest
python-dotenv
pytz
requests
responses
scipy
timezonefinder

Expand Down
1 change: 1 addition & 0 deletions resource_files/utility_rate_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"{\"items\":[{\"label\":\"5ca4d1175457a39b23b3d45e\",\"uri\":\"https:\\/\\/apps.openei.org\\/IURDB\\/rate\\/view\\/5ca4d1175457a39b23b3d45e\",\"sector\":\"Industrial\",\"energyweekendschedule\":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],\"enddate\":1546239600,\"flatdemandunit\":\"kW\",\"supersedes\":\"5a6b955b5457a3285de4a645\",\"demandrateunit\":\"kW\",\"eiaid\":15466,\"demandratestructure\":[[{\"rate\":2.33}],[{\"rate\":4.11}]],\"flatdemandmonths\":[0,0,0,0,0,0,0,0,0,0,0,0],\"revisions\":[1554283703,1554283840,1583403431],\"energyratestructure\":[[{\"rate\":0.01824,\"adj\":0.0239241,\"unit\":\"kWh\"}],[{\"rate\":0.10307,\"adj\":0.0363393,\"unit\":\"kWh\"}]],\"flatdemandstructure\":[[{\"rate\":5.63,\"adj\":3.64}]],\"startdate\":1546329600,\"energyweekdayschedule\":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],\"fixedchargeunits\":\"$\\/month\",\"utility\":\"Public Service Co of Colorado\",\"servicetype\":\"Bundled\",\"description\":\"AVAILABILITY\\r\\nAvailable to Customers with a minimum average Monthly Load Factor of thirty\\r\\npercent (30%) as measured for the previous twelve (12) consecutive Months. Once a\\r\\nCustomer requesting service under this tariff demonstrates a Load Factor of at least\\r\\nthirty percent (30%) and is deemed eligible for service under the tariff, then the\\r\\nCustomer can remain on the schedule even if the Customer&#x;fffds Load Factor subsequently\\r\\nfalls below thirty percent (30%). Eligibility qualifications for new construction for\\r\\nSPVTOU where twelve (12) Months of historical usage is unavailable will be reviewed\\r\\nbased on the submitted Electric Load forecast as part of the solar application.\\r\\nNotwithstanding the above, available to those six (6) irrigation Customer loads\\r\\nwhere a PV System was installed prior to January 1, 2010. The annual amount of new\\r\\ncapacity eligible to take service under Section A is capped at the projected amount of\\r\\non-site PV system capacity for medium size facilities (10 kW &#x;fffd 500 kW) in the\\r\\nCompany&#x;fffds Solar*Rewards&#x;fffd program.\\r\\nThe annual incremental load eligible for service under Section B will be capped\\r\\nat the annual PV capacity limit approved for the Solar*Rewards&#x;fffd Medium program for\\r\\nthe same Year. If in a calendar Year the Company has new participants in the SPVTOU\\r\\ntariff totaling thirty-six (36) Megawatts in aggregate noncoincident demand, the\\r\\nCompany will temporarily suspend the SPVTOU tariff to new entrants and convene a\\r\\nmeeting of the Existing Voluntary Renewable Stakeholder Group to discuss the issue\\r\\nand seek a resolution.\",\"name\":\"Secondary Photovoltaic Time Of Use Schedule (SPVTOU) Section B\",\"is_default\":false,\"source\":\"https:\\/\\/www.xcelenergy.com\\/staticfiles\\/xe\\/PDF\\/Regulatory\\/CO-Rates-&-Regulations-Entire-Electric-Book.pdf\",\"demandweekendschedule\":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],\"voltagecategory\":\"Secondary\",\"energycomments\":\"Adjustments = Earnings Share adjustment + Demand Side Management Cost adjustment + Purchased Capacity Cost adjustment + Transmission Cost adjustment + Electric Commodity adjustment + Clean Air-Clean Jobs Act rider + Renewable Energy Standard adjustment\",\"approved\":true,\"demandweekdayschedule\":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],\"dgrules\":\"Net Metering\",\"country\":\"USA\",\"fixedchargefirstmeter\":44.57,\"demandunits\":\"kW\",\"sourceparent\":\"https:\\/\\/www.xcelenergy.com\\/staticfiles\\/xe\\/PDF\\/Regulatory\\/CO-Rates-&-Regulations-Entire-Electric-Book.pdf\"}]}"
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
Pytest configuration file.
"""
import os

from hopp import TEST_ENV_VAR

def pytest_sessionstart(session):
os.environ["ENV"] = TEST_ENV_VAR

15 changes: 10 additions & 5 deletions tests/hopp/test_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@
from hopp.simulation.technologies.battery import Battery
from hopp.simulation.hybrid_simulation import HybridSimulation

from hopp import ROOT_DIR
from hopp.simulation.technologies.dispatch.power_storage.linear_voltage_convex_battery_dispatch import ConvexLinearVoltageBatteryDispatch
from hopp.simulation.technologies.dispatch.power_storage.simple_battery_dispatch import SimpleBatteryDispatch
from hopp.simulation.technologies.dispatch.hybrid_dispatch_builder_solver import HybridDispatchBuilderSolver
from hopp.simulation.technologies.dispatch.power_sources.pv_dispatch import PvDispatch
from hopp.simulation.technologies.dispatch.power_sources.wind_dispatch import WindDispatch


solar_resource_file = ROOT_DIR.parent / "resource_files" / "solar" / "35.2018863_-101.945027_psmv3_60_2012.csv"
wind_resource_file = ROOT_DIR.parent / "resource_files" / "wind" / "35.2018863_-101.945027_windtoolkit_2012_60min_80m_100m.srw"

@pytest.fixture
def site():
solar_resource_file = Path(__file__).absolute().parent.parent.parent / "resource_files" / "solar" / "35.2018863_-101.945027_psmv3_60_2012.csv"
wind_resource_file = Path(__file__).absolute().parent.parent.parent / "resource_files" / "wind" / "35.2018863_-101.945027_windtoolkit_2012_60min_80m_100m.srw"
return SiteInfo(flatirons_site, solar_resource_file=solar_resource_file, wind_resource_file=wind_resource_file)



interconnect_mw = 50
technologies = {'pv': {
'system_capacity_kw': 50 * 1000,
Expand Down Expand Up @@ -724,8 +725,12 @@ def test_desired_schedule_dispatch():
daily_schedule.extend([0] * 5)
desired_schedule = daily_schedule*365

desired_schedule_site = SiteInfo(flatirons_site,
desired_schedule=desired_schedule)
desired_schedule_site = SiteInfo(
flatirons_site,
solar_resource_file=solar_resource_file,
wind_resource_file=wind_resource_file,
desired_schedule=desired_schedule
)
tower_pv_battery = {key: technologies[key] for key in ('pv', 'tower', 'battery', 'grid')}

# Default case doesn't leave enough head room for battery operations
Expand Down
6 changes: 0 additions & 6 deletions tests/hopp/test_flicker_mismatch.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import platform
from pytest import approx
from hopp.simulation.technologies.layout.flicker_data.plot_flicker import *
from hopp.utilities.keys import set_nrel_key_dot_env


set_nrel_key_dot_env()

lat = 39.7555
lon = -105.2211


def plot_maps(maps, flicker):
for m in maps:
axs = flicker.plot_on_site(False, False)
c = plot_contour(m, flicker, axs, vmin=np.amin(m), vmax=np.amax(m))
plt.colorbar(c)
plt.show()


def test_single_turbine():
FlickerMismatch.diam_mult_nwe = 3
FlickerMismatch.diam_mult_s = 1
Expand Down
24 changes: 9 additions & 15 deletions tests/hopp/test_hybrid.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from pathlib import Path
from copy import deepcopy

from pydoc import apropos
from pytest import approx, fixture, raises
from pathlib import Path
import numpy as np
import json
import PySAM.Singleowner as Singleowner

# from hopp.simulation.technologies.layout.hybrid_layout import WindBoundaryGridParameters, PVGridParameters
from hopp.simulation.technologies.layout.wind_layout import WindBoundaryGridParameters
Expand All @@ -11,23 +16,15 @@
from examples.Detailed_PV_Layout.detailed_pv_config import PVLayoutConfig
from hopp.simulation.technologies.sites.site_info import SiteInfo
from hopp.simulation.technologies.sites.flatirons_site import flatirons_site
import PySAM.Singleowner as Singleowner
from hopp.simulation.technologies.grid import Grid
from hopp.utilities.keys import set_nrel_key_dot_env
from hopp.simulation.technologies.layout.pv_design_utils import size_electrical_parameters
from copy import deepcopy
import numpy as np
import json

set_nrel_key_dot_env()

solar_resource_file = Path(__file__).absolute().parent.parent.parent / "resource_files" / "solar" / "35.2018863_-101.945027_psmv3_60_2012.csv"
wind_resource_file = Path(__file__).absolute().parent.parent.parent / "resource_files" / "wind" / "35.2018863_-101.945027_windtoolkit_2012_60min_80m_100m.srw"
from tests.hopp.utils import create_default_site_info


@fixture
def site():
return SiteInfo(flatirons_site, solar_resource_file=solar_resource_file, wind_resource_file=wind_resource_file)
return create_default_site_info()


interconnection_size_kw = 15000
Expand Down Expand Up @@ -806,10 +803,7 @@ def test_hybrid_tax_incentives(site):


def test_capacity_credit():
site = SiteInfo(data=flatirons_site,
solar_resource_file=solar_resource_file,
wind_resource_file=wind_resource_file,
capacity_hours=capacity_credit_hours)
site = create_default_site_info(capacity_hours=capacity_credit_hours)
wind_pv_battery = {key: technologies[key] for key in ('pv', 'wind', 'battery')}
wind_pv_battery['grid'] = {
'interconnect_kw': interconnection_size_kw
Expand Down
19 changes: 8 additions & 11 deletions tests/hopp/test_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@
from pathlib import Path
from timeit import default_timer
import numpy as np
import os
import json
import matplotlib.pyplot as plt
from shapely import affinity
from shapely.ops import unary_union
from shapely.geometry import Point, Polygon, MultiLineString
from shapely.geometry import Point, MultiLineString

from hopp.simulation.technologies.sites import SiteInfo, flatirons_site
from hopp.simulation.technologies.wind_source import WindPlant
from hopp.simulation.technologies.pv_source import PVPlant
from hopp.simulation.technologies.layout.hybrid_layout import HybridLayout, WindBoundaryGridParameters, PVGridParameters, get_flicker_loss_multiplier
from hopp.simulation.technologies.layout.wind_layout_tools import create_grid
from hopp.simulation.technologies.layout.pv_design_utils import size_electrical_parameters, find_modules_per_string
from hopp.simulation.technologies.detailed_pv_plant import DetailedPVPlant

from tests.hopp.utils import create_default_site_info


@pytest.fixture
def site():
solar_resource_file = Path(__file__).absolute().parent.parent.parent / "resource_files" / "solar" / "35.2018863_-101.945027_psmv3_60_2012.csv"
wind_resource_file = Path(__file__).absolute().parent.parent.parent / "resource_files" / "wind" / "35.2018863_-101.945027_windtoolkit_2012_60min_80m_100m.srw"
return SiteInfo(flatirons_site, solar_resource_file=solar_resource_file, wind_resource_file=wind_resource_file)
return create_default_site_info()


technology = {
Expand All @@ -49,12 +47,11 @@ def site():
}


def test_create_grid():
site_info = SiteInfo(flatirons_site)
bounding_shape = site_info.polygon.buffer(-200)
site_info.plot()
def test_create_grid(site):
bounding_shape = site.polygon.buffer(-200)
site.plot()
turbine_positions = create_grid(bounding_shape,
site_info.polygon.centroid,
site.polygon.centroid,
np.pi / 4,
200,
200,
Expand Down
12 changes: 5 additions & 7 deletions tests/hopp/test_reopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
import PySAM.Singleowner as so
import os

from hopp.simulation.technologies.sites import *
from hopp.simulation.technologies.pv_source import *
from hopp.simulation.technologies.wind_source import *
from hopp.simulation.technologies.sites import SiteInfo
from hopp.simulation.technologies.pv_source import PVPlant
from hopp.simulation.technologies.wind_source import WindPlant
from hopp.simulation.technologies.reopt import REopt
from hopp.utilities.keys import set_nrel_key_dot_env

set_nrel_key_dot_env()
from tests.hopp.utils import create_default_site_info

filepath = os.path.dirname(os.path.abspath(__file__))


Expand All @@ -20,7 +18,7 @@ def test_ReOPT():
lon = -105.2211

# get resource and create model
site = SiteInfo(flatirons_site)
site = create_default_site_info()

load = [1000*(sin(x) + pi)for x in range(0, 8760)]
urdb_label = "5ca4d1175457a39b23b3d45e" # https://openei.org/apps/IURDB/rate/view/5ca3d45ab718b30e03405898
Expand Down
75 changes: 75 additions & 0 deletions tests/hopp/test_resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import os

import requests
import pytest
import responses

from hopp.simulation.technologies.resource import Resource

api_url = "https://api.example.com/data"
fname = "testfile.csv"


@responses.activate
def test_call_api():
responses.add(
responses.GET,
api_url,
status=200,
)
assert Resource.call_api(api_url, fname) == True

# cleanup
os.remove(fname)

@responses.activate
def test_call_api_timeout():
resp = responses.add(
responses.GET,
api_url,
body=requests.exceptions.Timeout()
)
assert Resource.call_api(api_url, fname) == False
assert resp.call_count == 5

@responses.activate
def test_call_api_400_error():
responses.add(
responses.GET,
api_url,
json={'errors': 'Bad request'},
status=400
)
with pytest.raises(requests.exceptions.HTTPError):
Resource.call_api(api_url, fname)

@responses.activate
def test_call_api_403_error():
responses.add(
responses.GET,
api_url,
json={'errors': 'Forbidden'},
status=403
)
with pytest.raises(requests.exceptions.HTTPError):
Resource.call_api(api_url, fname)

@responses.activate
def test_call_api_404_error():
responses.add(
responses.GET,
api_url,
status=404
)
with pytest.raises(requests.exceptions.HTTPError):
Resource.call_api(api_url, fname)

@responses.activate
def test_call_api_429_error():
responses.add(
responses.GET,
api_url,
status=429
)
with pytest.raises(RuntimeError):
Resource.call_api(api_url, fname)
Loading
Loading