From c2e770647d0b1f073fb38ab464a8bf9c7c91fe47 Mon Sep 17 00:00:00 2001 From: elenya-grant <116225007+elenya-grant@users.noreply.github.com> Date: Fri, 17 Jan 2025 09:48:45 -0700 Subject: [PATCH] updated some formatting in resource files for readthedocs build --- .../technologies/resource/resource.py | 17 +++++++++------- .../technologies/resource/solar_resource.py | 8 +++----- .../technologies/resource/wind_resource.py | 20 ++++++++++--------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/hopp/simulation/technologies/resource/resource.py b/hopp/simulation/technologies/resource/resource.py index 80806cd8c..846a02f3b 100644 --- a/hopp/simulation/technologies/resource/resource.py +++ b/hopp/simulation/technologies/resource/resource.py @@ -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 diff --git a/hopp/simulation/technologies/resource/solar_resource.py b/hopp/simulation/technologies/resource/solar_resource.py index b8e5c6173..201d2dec3 100644 --- a/hopp/simulation/technologies/resource/solar_resource.py +++ b/hopp/simulation/technologies/resource/solar_resource.py @@ -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, @@ -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') diff --git a/hopp/simulation/technologies/resource/wind_resource.py b/hopp/simulation/technologies/resource/wind_resource.py index 770c8eb93..545e4e112 100644 --- a/hopp/simulation/technologies/resource/wind_resource.py +++ b/hopp/simulation/technologies/resource/wind_resource.py @@ -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 @@ -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, @@ -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: