reV.SAM.generation.WindPowerPD

class WindPowerPD(ws_edges, wd_edges, wind_dist, meta, sam_sys_inputs, site_sys_inputs=None, output_request=None)[source]

Bases: AbstractSamGeneration, PowerCurveLossesMixin

WindPower analysis with wind speed/direction joint probabilty distrubtion input

Initialize a SAM generation object for windpower with a speed/direction joint probability distribution.

Parameters:
  • ws_edges (np.ndarray) – 1D array of windspeed (m/s) values that set the bin edges for the wind probability distribution. Same len as wind_dist.shape[0] + 1

  • wd_edges (np.ndarray) – 1D array of winddirections (deg) values that set the bin edges for the wind probability dist. Same len as wind_dist.shape[1] + 1

  • wind_dist (np.ndarray) – 2D array probability distribution of (windspeed, winddirection).

  • 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’).

Methods

add_power_curve_losses()

Adjust power curve in SAM config file to account for losses.

add_scheduled_losses([resource])

Add stochastically scheduled losses to SAM config file.

annual_energy()

Get annual energy generation value in kWh from SAM.

assign_inputs()

Assign the self.sam_sys_inputs attribute to the PySAM object.

cf_mean()

Get mean capacity factor (fractional) from SAM.

cf_profile()

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.

energy_yield()

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.

gen_profile()

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

outputs_to_utc_arr()

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_gen_and_econ()

Run SAM generation with possibility for follow on econ analysis.

set_resource_data(ws_edges, wd_edges, wind_dist)

Send wind PD to pysam

tz_elev_check(sam_sys_inputs, ...)

Check timezone+elevation input and use json config timezone+elevation if not in resource meta.

wind_resource_from_input()

Collect wind resource and weights from inputs.

Attributes

DIR

IGNORE_ATTRS

MODULE

OUTAGE_CONFIG_KEY

Specify outage information in the config file using this key.

OUTAGE_SEED_CONFIG_KEY

Specify a randomizer seed in the config file using this key.

POWER_CURVE_CONFIG_KEY

Specify power curve loss target in the config file using this key.

attr_dict

Get the heirarchical PySAM object attribute dictionary.

has_timezone

Returns true if instance has a timezone set

input_list

Get the list of lowest level input attribute/variable names.

input_power_curve

Original power curve for site.

meta

Get meta data property.

module

Get module property.

outage_seed

A value to use as the seed for the outage losses.

pysam

Get the pysam object.

site

Get the site number for this SAM simulation.

PYSAM = <module 'PySAM.Windpower' from '/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/PySAM/Windpower.cpython-38-x86_64-linux-gnu.so'>
set_resource_data(ws_edges, wd_edges, wind_dist)[source]

Send wind PD to pysam

Parameters:
  • ws_edges (np.ndarray) – 1D array of windspeed (m/s) values that set the bin edges for the wind probability distribution. Same len as wind_dist.shape[0] + 1

  • wd_edges (np.ndarray) – 1D array of winddirections (deg) values that set the bin edges for the wind probability dist. Same len as wind_dist.shape[1] + 1

  • wind_dist (np.ndarray) – 2D array probability distribution of (windspeed, winddirection).

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.

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 the sam_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 in sam_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 the sam_sys_inputs dictionary and computes stochastically scheduled losses from that input. If the value for reV_outages is a string, it must have been generated by calling json.dumps() on the list of dictionaries containing outage specifications. Otherwise, the outage information is expected to be a list of dictionaries containing outage specifications. See Outage for a description of the specifications allowed for each outage. The scheduled losses are passed to SAM via the hourly key to signify which hourly capacity factors should be adjusted with outage losses. If no outage info is specified in sam_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 the hourly 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 is

This 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.

property outage_seed

A value to use as the seed for the outage losses.

Type:

int

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 from rex.bias_correction module

    The gid field should match the true resource gid regardless of the optional gid_map input. Only windspeed or GHI + DNI + DHI are corrected, depending on the technology (wind for the former, PV or CSP for the latter). See the functions in the rex.bias_correction module for available inputs for method. Any additional kwargs required for the requested method can be input as additional columns in the bias_correct table e.g., for linear bias correction functions you can include scalar and adder inputs as columns in the bias_correct table on a site-by-site basis. If None, 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.

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’.