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

Site info refactor #201

Closed
wants to merge 134 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 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
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
6 changes: 3 additions & 3 deletions examples/CSP_PV_Battery_Analysis/simulation_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ def init_hybrid_plant(techs_in_sim: list, is_test: bool = False, ud_techs: dict
"lon": -116.7830,
"elev": 561,
"tz": 1,
"no_wind": True
}
}
solar_file = example_root + "02_weather_data/daggett_ca_34.865371_-116.783023_psmv3_60_tmy.csv"
prices_file = example_root + "03_cost_load_price_data/constant_norm_prices.csv"
desired_schedule_file = example_root + "03_cost_load_price_data/desired_schedule_normalized.csv"
Expand All @@ -98,7 +97,8 @@ def init_hybrid_plant(techs_in_sim: list, is_test: bool = False, ud_techs: dict
site = SiteInfo(site_data,
solar_resource_file=solar_file,
grid_resource_file=prices_file,
desired_schedule=desired_schedule
desired_schedule=desired_schedule,
wind=False
)

# Load in system costs
Expand Down
4 changes: 2 additions & 2 deletions examples/offshore-hybrid/wind-h2.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ def setup_hopp(plant_config, turbine_config, wind_resource, orbit_project, flori
hopp_site_input_data["lat"] = plant_config["project_location"]["lat"]
hopp_site_input_data["lon"] = plant_config["project_location"]["lon"]
hopp_site_input_data["year"] = plant_config["wind_resource_year"]
hopp_site_input_data["no_solar"] = not plant_config["project_parameters"]["solar"]
solar = plant_config["project_parameters"]["solar"]

# set desired schedule based on electrolyzer capacity
desired_schedule = [plant_config["electrolyzer"]["rating"]]*8760
desired_schedule = []

# generate HOPP SiteInfo class instance
hopp_site = SiteInfo(hopp_site_input_data, hub_height=turbine_config["hub_height"], desired_schedule=desired_schedule)
hopp_site = SiteInfo(hopp_site_input_data, hub_height=turbine_config["hub_height"], desired_schedule=desired_schedule, solar=solar)

# replace wind data with previously downloaded and adjusted wind data
hopp_site.wind_resource = wind_resource
Expand Down
6 changes: 4 additions & 2 deletions hopp/eco/hopp_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def setup_hopp(
hopp_site_input_data["lat"] = plant_config["project_location"]["lat"]
hopp_site_input_data["lon"] = plant_config["project_location"]["lon"]
hopp_site_input_data["year"] = plant_config["wind_resource_year"]
hopp_site_input_data["no_wind"] = not plant_config["project_parameters"]["wind"]
hopp_site_input_data["no_solar"] = not plant_config["project_parameters"]["solar"]
wind = plant_config["project_parameters"]["wind"]
solar = plant_config["project_parameters"]["solar"]

# set desired schedule based on electrolyzer capacity
desired_schedule = [plant_config["electrolyzer"]["rating"]] * 8760
Expand All @@ -33,6 +33,8 @@ def setup_hopp(
hopp_site_input_data,
hub_height=turbine_config["hub_height"],
desired_schedule=desired_schedule,
wind=wind,
solar=solar
)

# replace wind data with previously downloaded and adjusted wind data
Expand Down
207 changes: 103 additions & 104 deletions hopp/simulation/technologies/sites/site_info.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
from typing import Optional, Union
from pathlib import Path

from attrs import define, field
import matplotlib.pyplot as plt
from shapely.geometry import *
from shapely.geometry.base import *
from shapely.validation import make_valid
from fastkml import kml
import numpy as np
from numpy.typing import NDArray
from shapely.geometry import Polygon, MultiPolygon, Point
from shapely.geometry.base import BaseGeometry
from shapely.ops import transform
from shapely.validation import make_valid
from fastkml import kml, KML
import pyproj
import utm

from hopp.simulation.technologies.resource.solar_resource import SolarResource
from hopp.simulation.technologies.resource.wind_resource import WindResource
from hopp.simulation.technologies.resource.elec_prices import ElectricityPrices
from hopp.simulation.technologies.resource import (
SolarResource,
WindResource,
ElectricityPrices
)
from hopp.simulation.technologies.layout.plot_tools import plot_shape
from hopp.utilities.log import hybrid_logger as logger
from hopp.utilities.keys import set_nrel_key_dot_env

from hopp.type_dec import (
hopp_array_converter as converter, NDArrayFloat, resource_file_converter,
hopp_float_type
)
from hopp.simulation.base import BaseClass
from hopp.utilities.log import hybrid_logger as logger

def plot_site(verts, plt_style, labels):
for i in range(len(verts)):
Expand All @@ -25,140 +38,123 @@ def plot_site(verts, plt_style, labels):

plt.grid()


class SiteInfo:
"""
Site specific information

Attributes
----------
data : dict
dictionary of initialization data
lat : float
site latitude [decimal degrees]
long : float
site longitude [decimal degrees]
vertices : np.array
site boundary vertices [m]
polygon : shapely.geometry.polygon
site polygon
valid_region : shapely.geometry.polygon
`tidy` site polygon
solar_resource : :class:`hybrid.resource.SolarResource`
class containing solar resource data
wind_resource : :class:`hybrid.resource.WindResource`
class containing wind resource data
elec_prices : :class:`hybrid.resource.ElectricityPrices`
Class containing electricity prices
n_timesteps : int
Number of timesteps in resource data
n_periods_per_day : int
Number of time periods per day
interval : int
Number of minutes per time interval
urdb_label : string
`Link Utility Rate DataBase <https://openei.org/wiki/Utility_Rate_Database>`_ label for REopt runs
capacity_hours : list
Boolean list where ``True`` if the hour counts for capacity payments, ``False`` otherwise
desired_schedule : list
Absolute desired load profile [MWe]
follow_desired_schedule : boolean
``True`` if a desired schedule was provided, ``False`` otherwise
@define
class SiteInfo(BaseClass):
"""
Represents site-specific information needed by the hybrid simulation class and layout optimization.

def __init__(self, data,
solar_resource_file="",
wind_resource_file="",
grid_resource_file="",
hub_height=97,
capacity_hours=[],
desired_schedule=[]):
"""
Site specific information required by the hybrid simulation class and layout optimization.

:param data: dict, containing the following keys:

#. ``lat``: float, latitude [decimal degrees]
#. ``lon``: float, longitude [decimal degrees]
#. ``year``: int, year used to pull solar and/or wind resource data. If not provided, default is 2012 [-]
#. ``elev``: float (optional), elevation (metadata purposes only) [m]
#. ``tz``: int (optional), timezone code (metadata purposes only) [-]
#. ``no_solar``: bool (optional), if ``True`` solar data download for site is skipped, otherwise solar resource is downloaded from NSRDB
#. ``no_wind``: bool (optional), if ``True`` wind data download for site is skipped, otherwise wind resource is downloaded from wind-toolkit
#. ``site_boundaries``: dict (optional), with the following keys:
Attributes:
data (dict): Dictionary of initialization data.
lat (numpy.float64): Site latitude in decimal degrees.
lon (numpy.float64): Site longitude in decimal degrees.
tz (int, optional): Timezone code for metadata purposes only. Defaults to None.
vertices (:obj:`NDArray`): Site boundary vertices in meters.
polygon (:obj:`shapely.geometry.polygon.Polygon`): Site polygon.
valid_region (:obj:`shapely.geometry.polygon.Polygon`): Tidy site polygon.
solar_resource (:obj:`hopp.simulation.technologies.resource.SolarResource`): Class containing solar resource data.
wind_resource (:obj:`hopp.simulation.technologies.resource.WindResource`): Class containing wind resource data.
elec_prices (:obj:`hopp.simulation.technologies.resource.ElectricityPrices`): Class containing electricity prices.
n_timesteps (int): Number of timesteps in resource data.
n_periods_per_day (int): Number of time periods per day.
interval (int): Number of minutes per time interval.
urdb_label (str): Link to `Utility Rate DataBase <https://openei.org/wiki/Utility_Rate_Database>`_ label for REopt runs.
capacity_hours (:obj:`NDArray`): Boolean list indicating hours that count for capacity payments.
desired_schedule (:obj:`NDArray`): Absolute desired load profile in MWe.
follow_desired_schedule (bool): Indicates if a desired schedule was provided. Defaults to False.

* ``verts``: list of list [x,y], site boundary vertices [m]
* ``verts_simple``: list of list [x,y], simple site boundary vertices [m]
Args:
data (dict): Dictionary containing site-specific information.
solar_resource_file (Union[Path, str], optional): Path to solar resource file. Defaults to "".
wind_resource_file (Union[Path, str], optional): Path to wind resource file. Defaults to "".
grid_resource_file (Union[Path, str], optional): Path to grid pricing data file. Defaults to "".
hub_height (float, optional): Turbine hub height for resource download in meters. Defaults to 97.0.
capacity_hours (:obj:`NDArray`, optional): Boolean list indicating hours for capacity payments. Defaults to [].
desired_schedule (:obj:`NDArray`, optional): Absolute desired load profile in MWe. Defaults to [].
solar (bool, optional): Whether to set solar data for this site. Defaults to True.
wind (bool, optional): Whether to set wind data for this site. Defaults to True.
"""
# User provided
data: dict
solar_resource_file: Union[Path, str] = field(default="", converter=resource_file_converter)
wind_resource_file: Union[Path, str] = field(default="", converter=resource_file_converter)
grid_resource_file: Union[Path, str] = field(default="", converter=resource_file_converter)
hub_height: hopp_float_type = hopp_float_type(97.)
capacity_hours: NDArray = field(default=[], converter=converter(bool))
desired_schedule: NDArrayFloat = field(default=[], converter=converter())
solar: bool = True
wind: bool = True

#. ``kml_file``: string (optional), filepath to KML with "Boundary" and "Exclusion" Placemarks
#. ``urdb_label``: string (optional), `Link Utility Rate DataBase <https://openei.org/wiki/Utility_Rate_Database>`_ label for REopt runs
# Set in post init hook
n_timesteps: int = field(init=False, default=None)
lat: hopp_float_type = field(init=False)
lon: hopp_float_type = field(init=False)
year: int = field(init=False, default=2012)
tz: Optional[int] = field(init=False, default=None)
solar_resource: Optional[SolarResource] = field(init=False, default=None)
wind_resource: Optional[WindResource] = field(init=False, default=None)
elec_prices: Optional[ElectricityPrices] = field(init=False, default=None)
n_periods_per_day: int = field(init=False)
interval: int = field(init=False)
follow_desired_schedule: bool = field(init=False)
polygon: Union[Polygon, BaseGeometry] = field(init=False)
vertices: NDArrayFloat = field(init=False)
kml_data: Optional[KML] = field(init=False, default=None)

.. TODO: Can we get rid of verts_simple and simplify site_boundaries
# .. TODO: Can we get rid of verts_simple and simplify site_boundaries

:param solar_resource_file: string, location (path) and filename of solar resource file (if not downloading from NSRDB)
:param wind_resource_file: string, location (path) and filename of wind resource file (if not downloading from wind-toolkit)
:param grid_resource_file: string, location (path) and filename of grid pricing data
:param hub_height: int (default = 97), turbine hub height for resource download [m]
:param capacity_hours: list of booleans, (8760 length) ``True`` if the hour counts for capacity payments, ``False`` otherwise
:param desired_schedule: list of floats, (8760 length) absolute desired load profile [MWe]
"""
def __attrs_post_init__(self):
set_nrel_key_dot_env()
self.data = data

data = self.data
if 'site_boundaries' in data:
self.vertices = np.array([np.array(v) for v in data['site_boundaries']['verts']])
self.polygon: Polygon = Polygon(self.vertices)
self.polygon = Polygon(self.vertices)
self.polygon = self.polygon.buffer(1e-8)
if 'kml_file' in data:
self.kml_data, self.polygon, data['lat'], data['lon'] = self.kml_read(data['kml_file'])
self.polygon = self.polygon.buffer(1e-8)

if 'lat' not in data or 'lon' not in data:
raise ValueError("SiteInfo requires lat and lon")
self.lat = data['lat']
self.lon = data['lon']
self.n_timesteps = None

if 'year' not in data:
data['year'] = 2012
if 'tz' in data:
self.tz = data['tz']

if 'no_solar' not in data:
data['no_solar'] = False

if not data['no_solar']:
self.solar_resource = SolarResource(data['lat'], data['lon'], data['year'], filepath=solar_resource_file)
if self.solar:
self.solar_resource = SolarResource(data['lat'], data['lon'], data['year'], filepath=self.solar_resource_file)
self.n_timesteps = len(self.solar_resource.data['gh']) // 8760 * 8760

if 'no_wind' not in data:
data['no_wind'] = False

if not data['no_wind']:
if self.wind:
# TODO: allow hub height to be used as an optimization variable
self.wind_resource = WindResource(data['lat'], data['lon'], data['year'], wind_turbine_hub_ht=hub_height,
filepath=wind_resource_file)
self.wind_resource = WindResource(data['lat'], data['lon'], data['year'], wind_turbine_hub_ht=self.hub_height,
filepath=self.wind_resource_file)
n_timesteps = len(self.wind_resource.data['data']) // 8760 * 8760
if self.n_timesteps is None:
self.n_timesteps = n_timesteps
elif self.n_timesteps != n_timesteps:
raise ValueError(f"Wind resource timesteps of {n_timesteps} different than other resource timesteps of {self.n_timesteps}")

self.elec_prices = ElectricityPrices(data['lat'], data['lon'], data['year'], filepath=grid_resource_file)
self.elec_prices = ElectricityPrices(data['lat'], data['lon'], data['year'], filepath=self.grid_resource_file)
self.n_periods_per_day = self.n_timesteps // 365 # TODO: Does not handle leap years well
self.interval = int((60*24)/self.n_periods_per_day)
self.urdb_label = data['urdb_label'] if 'urdb_label' in data.keys() else None

if len(capacity_hours) == self.n_timesteps:
self.capacity_hours = capacity_hours
else:
self.capacity_hours = [False] * self.n_timesteps
if len(self.capacity_hours) != self.n_timesteps:
self.capacity_hours = np.array([False] * self.n_timesteps)

# Desired load schedule for the system to dispatch against
self.desired_schedule = desired_schedule
self.follow_desired_schedule = len(desired_schedule) == self.n_timesteps
if len(desired_schedule) > 0 and len(desired_schedule) != self.n_timesteps:
self.follow_desired_schedule = len(self.desired_schedule) == self.n_timesteps
if len(self.desired_schedule) > 0 and len(self.desired_schedule) != self.n_timesteps:
raise ValueError('The provided desired schedule does not match length of the simulation horizon.')

# FIXME: this a hack
if 'no_wind' in data and data["no_wind"]:

if not self.wind:
logger.info("Set up SiteInfo with solar resource files: {}".format(self.solar_resource.filename))
elif 'no_solar' in data and data["no_solar"]:
elif not self.solar:
logger.info("Set up SiteInfo with wind resource files: {}".format(self.wind_resource.filename))
else:
logger.info(
Expand Down Expand Up @@ -220,6 +216,9 @@ def plot(self,
return figure, axes

def kml_write(self, filepath, turb_coords=None, solar_region=None, wind_radius=200):
if self.kml_data is None:
raise AttributeError("No KML data to write.")

if turb_coords is not None:
turb_coords = np.atleast_2d(turb_coords)
for n, (x, y) in enumerate(turb_coords):
Expand Down
5 changes: 2 additions & 3 deletions hopp/to_organize/hopp_tools_steel.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,10 @@ def set_site_info(hopp_dict, site_df, sample_site):
lon = float(lon)
sample_site['lat'] = lat
sample_site['lon'] = lon
sample_site['no_solar'] = False
# if solar_size_mw>0:
# sample_site['no_solar'] = False
# sample_site['solar'] = True
# else:
# sample_site['no_solar'] = True
# sample_site['solar'] = False

hopp_dict.add('Configuration', {'sample_site': sample_site})

Expand Down
6 changes: 3 additions & 3 deletions hopp/tools/dispatch/csp_pv_battery_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ def init_hybrid_plant():
"elev": 641,
"year": 2012,
"tz": -8,
"no_wind": True
}
}

root = "C:/Users/WHamilt2/Documents/Projects/HOPP/CSP_PV_battery_dispatch_plots/"
solar_file = root + "34.865371_-116.783023_psmv3_60_tmy.csv"
Expand All @@ -84,7 +83,8 @@ def init_hybrid_plant():
site = SiteInfo(site_data,
solar_resource_file=solar_file,
grid_resource_file=prices_file,
desired_schedule=desired_schedule
desired_schedule=desired_schedule,
wind=False
)

technologies = {'tower': {
Expand Down
1 change: 0 additions & 1 deletion hopp/tools/hopp_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def set_site_info(site_df, sample_site):
lon = float(lon)
sample_site['lat'] = lat
sample_site['lon'] = lon
sample_site['no_solar'] = False

return site_df, sample_site

Expand Down
Loading
Loading