Skip to content

Commit

Permalink
updated some formatting in resource files for readthedocs build
Browse files Browse the repository at this point in the history
  • Loading branch information
elenya-grant committed Jan 17, 2025
1 parent 16deb3e commit c2e7706
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
17 changes: 10 additions & 7 deletions hopp/simulation/technologies/resource/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,25 @@ def __init__(self, lat, lon, year, **kwargs):
# update any passed in
self.__dict__.update(kwargs)

self.filename = None
self.filename = None #: filepath of resource data file, defaults to None
self._data = dict()

def check_download_dir(self):
"""Creates directory for the resource file if it does not exist.
"""
if not os.path.isdir(os.path.dirname(self.filename)):
os.makedirs(os.path.dirname(self.filename))

@staticmethod
def call_api(url, filename):
"""
Parameters
---------
url: string
The API endpoint to return data from
filename: string
The filename where data should be written
Args:
url (str): The API endpoint to return data from
filename (str): The filename where data should be written
Returns:
True if downloaded file successfully, False if encountered error in downloading
"""

n_tries = 0
Expand Down
8 changes: 3 additions & 5 deletions hopp/simulation/technologies/resource/solar_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
class SolarResource(Resource):
"""
Class to manage Solar Resource data from API calls or preloaded data.
Attributes:
filename (str): full filepath of solar resource data file
solar_attributes (str): attributes to download from API call
"""

#: attributes of solar resource data to download from API call
solar_attributes: str = 'ghi,dhi,dni,wind_speed,air_temperature,solar_zenith_angle,surface_pressure,dew_point'

def __init__(
self,
Expand Down Expand Up @@ -57,7 +56,6 @@ def __init__(
if os.path.isdir(path_resource):
self.path_resource = path_resource

self.solar_attributes = 'ghi,dhi,dni,wind_speed,air_temperature,solar_zenith_angle,surface_pressure,dew_point'

self.path_resource = os.path.join(self.path_resource, 'solar')

Expand Down
20 changes: 11 additions & 9 deletions hopp/simulation/technologies/resource/wind_resource.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import csv, os
from pathlib import Path
from typing import Union, Optional
from typing import Union, Optional, List
from PySAM.ResourceTools import SRW_to_wind_data

from hopp.utilities.keys import get_developer_nrel_gov_key, get_developer_nrel_gov_email
Expand All @@ -14,15 +14,18 @@

class WindResource(Resource):
""" Class to manage Wind Resource data from API calls or preloaded data.
Attributes:
hub_height_meters (float): the system height
TODO: if optimizer will modify hub height, need to download a range rather than a single
file_resource_heights (dict): dictionary of heights and filenames to download from Wind Toolkit
filename (str): full filepath of wind resource data file
"""

allowed_hub_height_meters = [10, 40, 60, 80, 100, 120, 140, 160, 200]
allowed_hub_height_meters: List[int] = [10, 40, 60, 80, 100, 120, 140, 160, 200]

#: the hub-height for wind resource data (meters)
hub_height_meters: float
# TODO: if optimizer will modify hub height, need to download a range rather than a single

#: dictionary of heights and filenames to download from Wind Toolkit
file_resource_heights: dict


def __init__(
self,
lat: float,
Expand Down Expand Up @@ -55,7 +58,6 @@ def __init__(
# if resource_data is input as a dictionary then set_data
if isinstance(resource_data,dict):
self.data = resource_data
self.filename = None

# if resource_data is not provided, download or load resource data
else:
Expand Down

0 comments on commit c2e7706

Please sign in to comment.