rex.sam_resource.SAMResource

class SAMResource(sites, tech, time_index, hub_heights=None, require_wind_dir=False, means=False)[source]

Bases: object

Resource container for SAM. Resource handlers preload the datasets needed by SAM for the sites of interest. SAMResource handles all ETL needed before resource data is passed into SAM.

Parameters
  • sites (int | list | tuple | slice) – int, list, tuple, or slice indicating sites to send to SAM

  • tech (str) – SAM technology string. See class attributes for options.

  • time_index (pandas.DatetimeIndex) – Time-series datetime index

  • hub_heights (int | float | list, optional) – Hub height(s) to extract wind data at, by default None

  • require_wind_dir (bool, optional) – Boolean flag indicating that wind direction is required, by default False

  • means (bool, optional) – Boolean flag to compute mean resource when res_array is set, by default False

Methods

append_var_list(var)

Append a new variable to the SAM resource protected var_list.

check_irradiance_datasets(datasets[, clearsky])

Check available irradiance datasets

check_units(var_name, var_array, tech)

Check units of variable array and convert to SAM units if needed

compute_irradiance([clearsky])

Fillin missing irradiance dataset from available values and SZA

curtail_windspeed(gids, curtailment)

Apply temporal curtailment mask to windspeed resource at given sites

enforce_arr_range(var, arr, valid_range, sites)

Check an array for valid data range, warn, patch, and return.

roll_timeseries(time_series, timezone, ...)

Roll timeseries array to given timezone from UTC

runnable()

Check to see if SAMResource iterator is runnable: - Meta must be loaded - Variables in var_list must be loaded

set_clearsky()

Make the NSRDB var list for solar based on clearsky irradiance.

Attributes

CSP_DATA_RANGES

DATA_RANGES

LF_DATA_RANGES

PV_DATA_RANGES

RES_VARS

SWH_DATA_RANGES

TPPH_DATA_RANGES

WAVE_DATA_RANGES

WIND_DATA_RANGES

h

Get heights for wind sites

lat_lon

site latitudes and longitudes

meta

Return sites meta

shape

Shape of variable arrays

sites

Sites being pre-loaded for SAM

sites_slice

Get the sites in slice format if possible

sza

Solar zenith angle for sites of interest

time_index

Return time_index

var_list

Return variable list associated with SAMResource type

property sites

Sites being pre-loaded for SAM

Returns

sites (list) – List of sites to be provided to SAM

property sites_slice

Get the sites in slice format if possible

Returns

sites (list | slice) – Sites slice belonging to this instance of ProjectPoints. The type is slice if possible. Will be a list only if sites are non-sequential.

property shape

Shape of variable arrays

Returns

self._shape (tuple) – Shape (time_index, sites) of variable arrays

property var_list

Return variable list associated with SAMResource type

Returns

_var_list (list) – List of resource variables associated with resource type (‘solar’ or ‘wind’)

property time_index

Return time_index

Returns

self._time_index (pandas.DatetimeIndex) – Time-series datetime index

property meta

Return sites meta

Returns

self._meta (pandas.DataFrame) – DataFrame of sites meta data

property h

Get heights for wind sites

Returns

self._h (int | float | list) – Hub height or height(s) for wind resource, None for solar resource

property lat_lon

site latitudes and longitudes

Returns

ndarray

property sza

Solar zenith angle for sites of interest

Returns

ndarray

static check_units(var_name, var_array, tech)[source]

Check units of variable array and convert to SAM units if needed

Parameters
  • var_name (str) – Variable name

  • var_array (ndarray) – Variable data

  • tech (str) – SAM technology string (windpower, pvwattsv5, solarwaterheat, etc..)

Returns

var_array (ndarray) – Variable data with updated units if needed

static enforce_arr_range(var, arr, valid_range, sites)[source]

Check an array for valid data range, warn, patch, and return.

Parameters
  • var (str) – variable name

  • arr (np.ndarray) – Array to be checked and patched

  • valid_range (np.ndarray | tuple | list) – arr data will be ensured within the min/max values of valid_range

  • sites (list) – Resource gid site list for warning printout.

Returns

arr (np.ndarray) – Patched array with valid range.

static roll_timeseries(time_series, timezone, time_interval)[source]

Roll timeseries array to given timezone from UTC

Parameters
  • time_series (ndarray) – time_series array to roll

  • timezone (int) – Time zone as UTC offset

  • time_interval (int) – Number of step-steps in an hour, needed to compute time shift

Returns

time_series (ndarray) – Time series in local time

check_irradiance_datasets(datasets, clearsky=False)[source]

Check available irradiance datasets

Parameters
  • datasets (list) – List of available datasets in resource .h5 file

  • clearsky (bool, optional) – Flag to check for clearsky irradiance datasets, by default False

compute_irradiance(clearsky=False)[source]

Fillin missing irradiance dataset from available values and SZA

Parameters

clearsky (bool, optional) – Flag to check for clearsky irradiance datasets, by default False

set_clearsky()[source]

Make the NSRDB var list for solar based on clearsky irradiance.

append_var_list(var)[source]

Append a new variable to the SAM resource protected var_list.

Parameters

var (str) – New resource variable to be added to the protected var_list property.

runnable()[source]

Check to see if SAMResource iterator is runnable: - Meta must be loaded - Variables in var_list must be loaded

Returns

bool – Returns True if runnable check passes

curtail_windspeed(gids, curtailment)[source]

Apply temporal curtailment mask to windspeed resource at given sites

Parameters
  • gids (int | list) – gids for site or list of sites to curtail

  • curtailment (ndarray) – Temporal multiplier for curtailment