Solar Resource (API)#

By default, solar resource data is downloaded from the NREL Developer Network hosted National Solar Radiation Database (NSRDB) dataset Physical Solar Model (PSM) v3.2.2. Using this functionality requires an NREL API key.

class hopp.simulation.technologies.resource.solar_resource.SolarResource(lat, lon, year, path_resource=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/hopp/envs/latest/lib/python3.11/site-packages/hopp/simulation/resource_files'), filepath='', use_api=False, resource_data=None, **kwargs)#

Bases: Resource

Class to manage Solar Resource data from API calls or preloaded data.

Parameters:
  • lat (float)

  • lon (float)

  • year (int)

  • path_resource (str | Path)

  • filepath (str | Path)

  • use_api (bool)

  • resource_data (dict | None)

solar_attributes: str = 'ghi,dhi,dni,wind_speed,air_temperature,solar_zenith_angle,surface_pressure,dew_point'#

attributes of solar resource data to download from API call

__init__(lat, lon, year, path_resource=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/hopp/envs/latest/lib/python3.11/site-packages/hopp/simulation/resource_files'), filepath='', use_api=False, resource_data=None, **kwargs)#

Resource class to download solar resource data using API call or set with preloaded dictionary

Parameters:
  • lat (float) – latitude corresponding to location for solar resource data

  • lon (float) – longitude corresponding to location for solar resource data

  • year (int) – year for resource data. must be between 1998 and 2022

  • path_resource (Union[str, Path], optional) – filepath to resource_files directory. Defaults to ROOT_DIR/”simulation”/”resource_files”.

  • filepath (Union[str, Path], optional) – full filepath to solar resource data file. Defaults to “”.

  • use_api (bool, optional) – Make an API call even if there’s an existing file. Defaults to False.

  • resource_data (Optional[dict], optional) – dictionary of preloaded and formatted solar resource data. Defaults to None.

  • kwargs – extra kwargs

filename#

filepath of resource data file, defaults to None

download_resource()#

Download solar resource file from NSRDB API call

Returns:

success (bool) – whether API download was successful or not

format_data()#

Format as ‘solar_resource_data’ dictionary for use in PySAM.

static call_api(url, filename)#
Parameters:
  • 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

property data#

Get data as dictionary formatted for SAM

roll_timezone(roll_hours, timezone)#

Roll weather data timezone. This function appears unused.

Parameters:
  • roll_hours (Union[int,float]) – number of hours to roll the timezone by

  • timezone (int) – timezone for location