reV.SAM.generation.AbstractSamWind
- class AbstractSamWind(*args, **kwargs)[source]
Bases:
AbstractSamGeneration
,PowerCurveLossesMixin
,ABC
Wind generation from SAM.
See the PySAM
Windpower
documentation for the configuration keys required in the sam_sys_inputs config. You may also include the followingreV
-specific keys:reV_power_curve_losses
: A dictionary that can be used to initializePowerCurveLossesInput
. For example:reV_power_curve_losses = { 'target_losses_percent': 9.8, 'transformation': 'exponential_stretching' }
See the description of the class mentioned above or the reV losses demo notebook for detailed instructions on how to specify this input.
reV_outages
: Specification forreV
-scheduled stochastic outage losses. For example:outage_info = [ { 'count': 6, 'duration': 24, 'percentage_of_capacity_lost': 100, 'allowed_months': ['January', 'March'], 'allow_outage_overlap': True }, { 'count': 10, 'duration': 1, 'percentage_of_capacity_lost': 10, 'allowed_months': ['January'], 'allow_outage_overlap': False }, ... ]
See the description of
add_scheduled_losses()
or the reV losses demo notebook for detailed instructions on how to specify this input.reV_outages_seed
: Integer value used to seed the RNG used to compute stochastic outage losses.time_index_step
: Integer representing the step size used to sample thetime_index
in the resource data. This can be used to reduce temporal resolution (i.e. for 30 minute input data,time_index_step=1
yields the full 30 minute time series as output, whiletime_index_step=2
yields hourly output, and so forth).Note
The reduced data shape (i.e. after applying a step size of time_index_step) must still be an integer multiple of 8760, or the execution will fail.
- Parameters:
resource (pd.DataFrame) – Timeseries solar or wind resource data for a single location with a pandas DatetimeIndex. There must be columns for all the required variables to run the respective SAM simulation. Remapping will be done to convert typical NSRDB/WTK names into SAM names (e.g. DNI -> dn and wind_speed -> windspeed)
meta (pd.DataFrame | pd.Series) – Meta data corresponding to the resource input for the single location. Should include values for latitude, longitude, elevation, and timezone.
sam_sys_inputs (dict) – Site-agnostic SAM system model inputs arguments.
site_sys_inputs (dict) – Optional set of site-specific SAM system inputs to complement the site-agnostic inputs.
output_request (list) – Requested SAM outputs (e.g., ‘cf_mean’, ‘annual_energy’, ‘cf_profile’, ‘gen_profile’, ‘energy_yield’, ‘ppa_price’, ‘lcoe_fcr’).
drop_leap (bool) – Drops February 29th from the resource data. If False, December 31st is dropped from leap years.
Methods
Adjust power curve in SAM config file to account for losses.
add_scheduled_losses
([resource])Add stochastically scheduled losses to SAM config file.
Get annual energy generation value in kWh from SAM.
Assign the self.sam_sys_inputs attribute to the PySAM object.
cf_mean
()Get mean capacity factor (fractional) from SAM.
Get hourly capacity factor (frac) profile in local timezone.
check_resource_data
(resource)Check resource dataframe for NaN values
collect_outputs
([output_lookup])Collect SAM output_request, convert timeseries outputs to UTC, and save outputs to self.outputs property.
default
()Get the executed default pysam object.
drop_leap
(resource)Drop Feb 29th from resource df with time index.
Get annual energy yield value in kwh/kw from SAM.
ensure_res_len
(arr, time_index)Ensure time_index has a constant time-step and only covers 365 days (no leap days).
execute
()Call the PySAM execute method.
Get power generation profile (local timezone) in kW.
get_sam_res
(*args, **kwargs)Get the SAM resource iterator object (single year, single file).
get_time_interval
(time_index)Get the time interval.
make_datetime
(series)Ensure that pd series is a datetime series with dt accessor
Convert array-like SAM outputs to UTC np.ndarrays
reV_run
(points_control, res_file, site_df[, ...])Execute SAM generation based on a reV points control instance.
run
()Run a reV-SAM generation object by assigning inputs, executing the SAM simulation, collecting outputs, and converting all arrays to UTC.
Run SAM generation with possibility for follow on econ analysis.
set_resource_data
(resource, meta)Placeholder for resource data setting (nsrdb or wtk)
tz_elev_check
(sam_sys_inputs, ...)Check timezone+elevation input and use json config timezone+elevation if not in resource meta.
Collect wind resource and weights from inputs.
Attributes
DIR
IGNORE_ATTRS
MODULE
Specify outage information in the config file using this key.
Specify a randomizer seed in the config file using this key.
Specify power curve loss target in the config file using this key.
Get the heirarchical PySAM object attribute dictionary.
Returns true if instance has a timezone set
Get the list of lowest level input attribute/variable names.
Original power curve for site.
Get meta data property.
Get module property.
A value to use as the seed for the outage losses.
Get the pysam object.
Get the site number for this SAM simulation.
- OUTAGE_CONFIG_KEY = 'reV_outages'
Specify outage information in the config file using this key.
- OUTAGE_SEED_CONFIG_KEY = 'reV_outages_seed'
Specify a randomizer seed in the config file using this key.
- POWER_CURVE_CONFIG_KEY = 'reV_power_curve_losses'
Specify power curve loss target in the config file using this key.
- PYSAM = <module 'PySAM.GenericSystem' from '/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/PySAM/GenericSystem.cpython-38-x86_64-linux-gnu.so'>
- add_power_curve_losses()
Adjust power curve in SAM config file to account for losses.
This function reads the information in the
reV_power_curve_losses
key of thesam_sys_inputs
dictionary and computes a new power curve that accounts for the loss percentage specified from that input. If no power curve loss info is specified insam_sys_inputs
, the power curve will not be adjusted.See also
adjust_power_curve()
Power curve shift calculation.
- add_scheduled_losses(resource=None)
Add stochastically scheduled losses to SAM config file.
This function reads the information in the
reV_outages
key of thesam_sys_inputs
dictionary and computes stochastically scheduled losses from that input. If the value forreV_outages
is a string, it must have been generated by callingjson.dumps()
on the list of dictionaries containing outage specifications. Otherwise, the outage information is expected to be a list of dictionaries containing outage specifications. SeeOutage
for a description of the specifications allowed for each outage. The scheduled losses are passed to SAM via thehourly
key to signify which hourly capacity factors should be adjusted with outage losses. If no outage info is specified insam_sys_inputs
, no scheduled losses are added.- Parameters:
resource (pd.DataFrame, optional) – Time series resource data for a single location with a pandas DatetimeIndex. The
year
value of the index will be used to seed the stochastically scheduled losses. If None, no yearly seed will be used.
See also
Outage
Single outage specification.
Notes
The scheduled losses are passed to SAM via the
hourly
key to signify which hourly capacity factors should be adjusted with outage losses. If the user specifies other hourly adjustment factors via thehourly
key, the effect is combined. For example, if the user inputs a 33% hourly adjustment factor and reV schedules an outage for 70% of the farm down for the same hour, then the resulting adjustment factor isThis means the generation will be reduced by ~80%, because the user requested 33% losses for the 30% the farm that remained operational during the scheduled outage (i.e. 20% remaining of the original generation).
- annual_energy()
Get annual energy generation value in kWh from SAM.
- Returns:
output (float) – Annual energy generation (kWh).
- assign_inputs()
Assign the self.sam_sys_inputs attribute to the PySAM object.
- property attr_dict
Get the heirarchical PySAM object attribute dictionary.
- Returns:
_attr_dict (dict) –
- Dictionary with:
keys: variable groups values: lowest level attribute/variable names
- cf_mean()
Get mean capacity factor (fractional) from SAM.
- Returns:
output (float) – Mean capacity factor (fractional).
- cf_profile()
Get hourly capacity factor (frac) profile in local timezone. See self.outputs attribute for collected output data in UTC.
- Returns:
cf_profile (np.ndarray) – 1D numpy array of capacity factor profile. Datatype is float32 and array length is 8760*time_interval.
- check_resource_data(resource)
Check resource dataframe for NaN values
- Parameters:
resource (pd.DataFrame) – Timeseries solar or wind resource data for a single location with a pandas DatetimeIndex. There must be columns for all the required variables to run the respective SAM simulation. Remapping will be done to convert typical NSRDB/WTK names into SAM names (e.g. DNI -> dn and wind_speed -> windspeed)
- collect_outputs(output_lookup=None)
Collect SAM output_request, convert timeseries outputs to UTC, and save outputs to self.outputs property.
- Parameters:
output_lookup (dict | None) – Lookup dictionary mapping output keys to special output methods. None defaults to generation default outputs.
- classmethod default()
Get the executed default pysam object.
- Returns:
PySAM.GenericSystem
- static drop_leap(resource)
Drop Feb 29th from resource df with time index.
- Parameters:
resource (pd.DataFrame) – Resource dataframe with an index containing a pandas time index object with month and day attributes.
- Returns:
resource (pd.DataFrame) – Resource dataframe with all February 29th timesteps removed.
- energy_yield()
Get annual energy yield value in kwh/kw from SAM.
- Returns:
output (float) – Annual energy yield (kwh/kw).
- static ensure_res_len(arr, time_index)
Ensure time_index has a constant time-step and only covers 365 days (no leap days). If not remove last day
- Parameters:
arr (ndarray) – Array to truncate if time_index has a leap day
time_index (pandas.DatatimeIndex) – Time index associated with arr, used to check time-series frequency and number of days
- Returns:
arr (ndarray) – Truncated array of data such that there are 365 days
- execute()
Call the PySAM execute method. Raise SAMExecutionError if error. Include the site index if available.
- gen_profile()
Get power generation profile (local timezone) in kW. See self.outputs attribute for collected output data in UTC.
- Returns:
output (np.ndarray) – 1D array of hourly power generation in kW. Datatype is float32 and array length is 8760*time_interval.
- static get_sam_res(*args, **kwargs)
Get the SAM resource iterator object (single year, single file).
- classmethod get_time_interval(time_index)
Get the time interval.
- Parameters:
time_index (pd.series) – Datetime series. Must have a dt attribute to access datetime properties (added using make_datetime method).
- Returns:
time_interval (int:) – This value is the number of indices over which an hour is counted. So if the timestep is 0.5 hours, time_interval is 2.
- property has_timezone
Returns true if instance has a timezone set
- property input_list
Get the list of lowest level input attribute/variable names.
- Returns:
_inputs (list) – List of lowest level input attributes.
- property input_power_curve
Original power curve for site.
- Type:
PowerCurve
- static make_datetime(series)
Ensure that pd series is a datetime series with dt accessor
- property meta
Get meta data property.
- property module
Get module property.
- outputs_to_utc_arr()
Convert array-like SAM outputs to UTC np.ndarrays
- property pysam
Get the pysam object.
- classmethod reV_run(points_control, res_file, site_df, lr_res_file=None, output_request=('cf_mean',), drop_leap=False, gid_map=None, nn_map=None, bias_correct=None)
Execute SAM generation based on a reV points control instance.
- Parameters:
points_control (config.PointsControl) – PointsControl instance containing project points site and SAM config info.
res_file (str) – Resource file with full path.
site_df (pd.DataFrame) – Dataframe of site-specific input variables. Row index corresponds to site number/gid (via df.loc not df.iloc), column labels are the variable keys that will be passed forward as SAM parameters.
lr_res_file (str | None) – Optional low resolution resource file that will be dynamically mapped+interpolated to the nominal-resolution res_file. This needs to be of the same format as resource_file, e.g. they both need to be handled by the same rex Resource handler such as WindResource
output_request (list | tuple) – Outputs to retrieve from SAM.
drop_leap (bool) – Drops February 29th from the resource data. If False, December 31st is dropped from leap years.
gid_map (None | dict) – Mapping of unique integer generation gids (keys) to single integer resource gids (values). This enables the user to input unique generation gids in the project points that map to non-unique resource gids. This can be None or a pre-extracted dict.
nn_map (np.ndarray) – Optional 1D array of nearest neighbor mappings associated with the res_file to lr_res_file spatial mapping. For details on this argument, see the rex.MultiResolutionResource docstring.
bias_correct (None | pd.DataFrame) – Optional DataFrame or CSV filepath to a wind or solar resource bias correction table. This has columns:
gid
: GID of site (can be index name of dataframe)method
: function name fromrex.bias_correction
module
The
gid
field should match the true resourcegid
regardless of the optionalgid_map
input. Onlywindspeed
orGHI
+DNI
+DHI
are corrected, depending on the technology (wind for the former, PV or CSP for the latter). See the functions in therex.bias_correction
module for available inputs formethod
. Any additional kwargs required for the requestedmethod
can be input as additional columns in thebias_correct
table e.g., for linear bias correction functions you can includescalar
andadder
inputs as columns in thebias_correct
table on a site-by-site basis. IfNone
, no corrections are applied. By default,None
.
- Returns:
out (dict) – Nested dictionaries where the top level key is the site index, the second level key is the variable name, second level value is the output variable value.
- run()
Run a reV-SAM generation object by assigning inputs, executing the SAM simulation, collecting outputs, and converting all arrays to UTC.
- run_gen_and_econ()
Run SAM generation with possibility for follow on econ analysis.
- abstract set_resource_data(resource, meta)
Placeholder for resource data setting (nsrdb or wtk)
- property site
Get the site number for this SAM simulation.
- static tz_elev_check(sam_sys_inputs, site_sys_inputs, meta)
Check timezone+elevation input and use json config timezone+elevation if not in resource meta.
- Parameters:
sam_sys_inputs (dict) – Site-agnostic SAM system model inputs arguments.
site_sys_inputs (dict) – Optional set of site-specific SAM system inputs to complement the site-agnostic inputs.
meta (pd.DataFrame | pd.Series) – Meta data corresponding to the resource input for the single location. Should include values for latitude, longitude, elevation, and timezone.
- Returns:
meta (pd.DataFrame | pd.Series) – Dataframe or series for a single site. Will include “timezone” and “elevation” from the sam and site system inputs if found.
- wind_resource_from_input()
Collect wind resource and weights from inputs.
- Returns:
PowerCurveWindResource
– Wind resource used to compute power curve shift.- Raises:
reVLossesValueError – If power curve losses are not compatible with the ‘wind_resource_model_choice’.