reV.bespoke.bespoke.BespokeSinglePlant
- class BespokeSinglePlant(gid, excl, res, tm_dset, sam_sys_inputs, objective_function, capital_cost_function, fixed_operating_cost_function, variable_operating_cost_function, balance_of_system_cost_function, min_spacing='5x', wake_loss_multiplier=1, ga_kwargs=None, output_request=('system_capacity', 'cf_mean'), ws_bins=(0.0, 20.0, 5.0), wd_bins=(0.0, 360.0, 45.0), excl_dict=None, inclusion_mask=None, data_layers=None, resolution=64, excl_area=None, exclusion_shape=None, eos_mult_baseline_cap_mw=200, prior_meta=None, gid_map=None, bias_correct=None, pre_loaded_data=None, close=True)[source]
Bases:
object
Framework for analyzing and optimizing a wind plant layout specific to the local wind resource and exclusions for a single reV supply curve point.
- Parameters:
gid (int) – gid for supply curve point to analyze.
excl (str | ExclusionMask) – Filepath to exclusions h5 or ExclusionMask file handler.
res (str | Resource) – Filepath to .h5 wind resource file or pre-initialized Resource handler
tm_dset (str) – Dataset name in the exclusions file containing the exclusions-to-resource mapping data.
sam_sys_inputs (dict) – SAM windpower compute module system inputs not including the wind resource data.
objective_function (str) – The objective function of the optimization as a string, should return the objective to be minimized during layout optimization. Variables available are:
n_turbines
: the number of turbinessystem_capacity
: wind plant capacityaep
: annual energy productionavg_sl_dist_to_center_m
: Average straight-line distance to the supply curve point center from all turbine locations (in m). Useful for computing plant BOS costs.avg_sl_dist_to_medoid_m
: Average straight-line distance to the medoid of all turbine locations (in m). Useful for computing plant BOS costs.nn_conn_dist_m
: Total BOS connection distance using nearest-neighbor connections. This variable is only available for thebalance_of_system_cost_function
equation.fixed_charge_rate
: user input fixed_charge_rate if included as part of the sam system config.capital_cost
: plant capital cost as evaluated by capital_cost_functionfixed_operating_cost
: plant fixed annual operating cost as evaluated by fixed_operating_cost_functionvariable_operating_cost
: plant variable annual operating cost as evaluated by variable_operating_cost_functionbalance_of_system_cost
: plant balance of system cost as evaluated by balance_of_system_cost_functionself.wind_plant
: the SAM wind plant object, through which all SAM variables can be accessed
capital_cost_function (str) – The plant capital cost function as a string, must return the total capital cost in $. Has access to the same variables as the objective_function.
fixed_operating_cost_function (str) – The plant annual fixed operating cost function as a string, must return the fixed operating cost in $/year. Has access to the same variables as the objective_function.
variable_operating_cost_function (str) – The plant annual variable operating cost function as a string, must return the variable operating cost in $/kWh. Has access to the same variables as the objective_function. You can set this to “0” to effectively ignore variable operating costs.
balance_of_system_cost_function (str) – The plant balance-of-system cost function as a string, must return the variable operating cost in $. Has access to the same variables as the objective_function. You can set this to “0” to effectively ignore balance-of-system costs.
balance_of_system_cost_function (str) – The plant balance-of-system cost function as a string, must return the variable operating cost in $. Has access to the same variables as the objective_function.
min_spacing (float | int | str) – Minimum spacing between turbines in meters. Can also be a string like “5x” (default) which is interpreted as 5 times the turbine rotor diameter.
wake_loss_multiplier (float, optional) – A multiplier used to scale the annual energy lost due to wake losses. .. WARNING:: This multiplier will ONLY be applied during the optimization process and will NOT be come through in output values such as the hourly profiles, aep, any of the cost functions, or even the output objective.
ga_kwargs (dict | None) – Dictionary of keyword arguments to pass to GA initialization. If None, default initialization values are used. See
GeneticAlgorithm
for a description of the allowed keyword arguments.output_request (list | tuple) – Outputs requested from the SAM windpower simulation after the bespoke plant layout optimization. Can also request resource means like ws_mean, windspeed_mean, temperature_mean, pressure_mean.
ws_bins (tuple) – 3-entry tuple with (start, stop, step) for the windspeed binning of the wind joint probability distribution. The stop value is inclusive, so ws_bins=(0, 20, 5) would result in four bins with bin edges (0, 5, 10, 15, 20).
wd_bins (tuple) – 3-entry tuple with (start, stop, step) for the winddirection binning of the wind joint probability distribution. The stop value is inclusive, so ws_bins=(0, 360, 90) would result in four bins with bin edges (0, 90, 180, 270, 360).
excl_dict (dict | None) – Dictionary of exclusion keyword arugments of the format {layer_dset_name: {kwarg: value}} where layer_dset_name is a dataset in the exclusion h5 file and kwarg is a keyword argument to the reV.supply_curve.exclusions.LayerMask class. None if excl input is pre-initialized.
inclusion_mask (np.ndarray) – 2D array pre-extracted inclusion mask where 1 is included and 0 is excluded. The shape of this will be checked against the input resolution.
data_layers (None | dict) – Aggregation data layers. Must be a dictionary keyed by data label name. Each value must be another dictionary with “dset”, “method”, and “fpath”.
resolution (int) – Number of exclusion points per SC point along an axis. This number**2 is the total number of exclusion points per SC point.
excl_area (float | None, optional) – Area of an exclusion pixel in km2. None will try to infer the area from the profile transform attribute in excl_fpath, by default None
exclusion_shape (tuple) – Shape of the full exclusions extent (rows, cols). Inputing this will speed things up considerably.
eos_mult_baseline_cap_mw (int | float, optional) – Baseline plant capacity (MW) used to calculate economies of scale (EOS) multiplier from the capital_cost_function. EOS multiplier is calculated as the $-per-kW of the wind plant divided by the $-per-kW of a plant with this baseline capacity. By default, 200 (MW), which aligns the baseline with ATB assumptions. See here: https://tinyurl.com/y85hnu6h.
prior_meta (pd.DataFrame | None) – Optional meta dataframe belonging to a prior run. This will only run the timeseries power generation step and assume that all of the wind plant layouts are fixed given the prior run. The meta data needs columns “capacity”, “turbine_x_coords”, and “turbine_y_coords”.
gid_map (None | str | dict) – Mapping of unique integer generation gids (keys) to single integer resource gids (values). This can be None, a pre-extracted dict, or a filepath to json or csv. If this is a csv, it must have the columns “gid” (which matches the techmap) and “gid_map” (gids to extract from the resource input). This is useful if you’re running forecasted resource data (e.g., ECMWF) to complement historical meteorology (e.g., WTK).
bias_correct (str | pd.DataFrame, optional) – 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
.pre_loaded_data (BespokeSinglePlantData, optional) – A pre-loaded
BespokeSinglePlantData
object, orNone
. Can be useful to speed up execution on file systems with slow parallel reads.close (bool) – Flag to close object file handlers on exit.
Methods
Aggregate optional data layers if requested and save to self.meta
bias_correct_ws
(ws, dset, h5_gids)Bias correct windspeed data if the
bias_correct
input was provided.Check special dependencies for bespoke
close
()Close any open file handlers via the sc point attribute.
Get a namespace of arguments for calculating LCOE based on the bespoke optimized wind plant capacity
Special method for calculating the exclusion-weighted mean wind direction for the BespokeSinglePlant
get_weighted_res_ts
(dset)Special method for calculating the exclusion-weighted mean resource timeseries data for the BespokeSinglePlant.
Initialize the annual wind plant timeseries analysis object(s) using the annual resource data and the sam system inputs from the optimized plant.
Recalculate the multi-year mean LCOE based on the multi-year mean annual energy production (AEP)
run
(*args, **kwargs)Run the bespoke optimization for a single wind plant.
Run the wind plant layout optimization and export outputs to outputs property.
Run the wind plant multi-year timeseries analysis and export output requests to outputs property.
Attributes
DEPENDENCIES
OUT_ATTRS
Get an ordered list of single-year time index objects that matches the profile outputs from the wind_plant_ts object.
SC point gid for this bespoke plant.
Get the integer SAM system config turbine hub height (meters)
Get the supply curve point 2D inclusion mask (included is 1, excluded is 0)
Get the basic supply curve point meta data
Get the original (pre-optimized) SAM windpower system inputs.
Saved outputs for the single wind plant bespoke optimization.
Get the length of a single exclusion pixel side (meters)
Bespoke plant turbine placement optimizer object.
Get the reV compliant wind resource dataframe representing the aggregated and included wind resource in the current reV supply curve point at the turbine hub height.
Get the SAM windpower system inputs.
Get the reV supply curve point object.
Get the wind joint probability distribution and corresonding bin edges
ReV WindPowerPD compute object for plant layout optimization based on wind joint probability distribution
ReV WindPower compute object(s) based on wind resource timeseries data keyed by year
Get the sorted list of analysis years.
- close()[source]
Close any open file handlers via the sc point attribute. If this class was initialized with close=False, this will not close any handlers.
- bias_correct_ws(ws, dset, h5_gids)[source]
Bias correct windspeed data if the
bias_correct
input was provided.- Parameters:
ws (np.ndarray) – Windspeed data in shape (time, space)
dset (str) – Resource dataset name e.g., “windspeed_100m”, “temperature_100m”, “pressure_100m”, or something similar
h5_gids (list | np.ndarray) – Array of integer gids (spatial indices) from the source h5 file. This is used to get the correct bias correction parameters from
bias_correct
table based on itsgid
column
- Returns:
ws (np.ndarray) – Bias corrected windspeed data in same shape as input
- get_weighted_res_ts(dset)[source]
Special method for calculating the exclusion-weighted mean resource timeseries data for the BespokeSinglePlant.
- Parameters:
dset (str) – Resource dataset name e.g., “windspeed_100m”, “temperature_100m”, “pressure_100m”, or something similar
- Returns:
data (np.ndarray) – Timeseries data of shape (n_time,) for the wind plant weighted by the plant inclusions mask.
- get_weighted_res_dir()[source]
Special method for calculating the exclusion-weighted mean wind direction for the BespokeSinglePlant
- Returns:
mean_wind_dirs (np.ndarray) – Timeseries array of winddirection data in shape (n_time,) in units of degrees from north.
- property gid
SC point gid for this bespoke plant.
- Returns:
int
- property include_mask
Get the supply curve point 2D inclusion mask (included is 1, excluded is 0)
- Returns:
np.ndarray
- property pixel_side_length
Get the length of a single exclusion pixel side (meters)
- Returns:
float
- property original_sam_sys_inputs
Get the original (pre-optimized) SAM windpower system inputs.
- Returns:
dict
- property sam_sys_inputs
Get the SAM windpower system inputs. If the wind plant has not yet been optimized, this returns the initial SAM config. If the wind plant has been optimized using the wind_plant_pd object, this returns the final optimized SAM plant config.
- Returns:
dict
- property sc_point
Get the reV supply curve point object.
- Returns:
AggSCPoint
- property meta
Get the basic supply curve point meta data
- Returns:
pd.DataFrame
- property hub_height
Get the integer SAM system config turbine hub height (meters)
- Returns:
int
- property res_df
Get the reV compliant wind resource dataframe representing the aggregated and included wind resource in the current reV supply curve point at the turbine hub height. Includes a DatetimeIndex and columns for temperature, pressure, windspeed, and winddirection.
- Returns:
pd.DataFrame
- property years
Get the sorted list of analysis years.
- Returns:
list
- property annual_time_indexes
Get an ordered list of single-year time index objects that matches the profile outputs from the wind_plant_ts object.
- Returns:
list
- property wind_dist
Get the wind joint probability distribution and corresonding bin edges
- Returns:
wind_dist (np.ndarray) – 2D array probability distribution of (windspeed, winddirection) normalized so the sum of all values = 1.
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
- initialize_wind_plant_ts()[source]
Initialize the annual wind plant timeseries analysis object(s) using the annual resource data and the sam system inputs from the optimized plant.
- Returns:
wind_plant_ts (dict) – Annual reV.SAM.generation.WindPower object(s) keyed by year.
- property wind_plant_pd
ReV WindPowerPD compute object for plant layout optimization based on wind joint probability distribution
- Returns:
reV.SAM.generation.WindPowerPD
- property wind_plant_ts
ReV WindPower compute object(s) based on wind resource timeseries data keyed by year
- Returns:
dict
- property plant_optimizer
Bespoke plant turbine placement optimizer object.
- Returns:
PlaceTurbines
- recalc_lcoe()[source]
Recalculate the multi-year mean LCOE based on the multi-year mean annual energy production (AEP)
- get_lcoe_kwargs()[source]
Get a namespace of arguments for calculating LCOE based on the bespoke optimized wind plant capacity
- Returns:
lcoe_kwargs (dict) – kwargs for the SAM lcoe model. These are based on the original sam_sys_inputs, normalized to the original system_capacity, and updated based on the bespoke optimized system_capacity, includes fixed_charge_rate, system_capacity (kW), capital_cost ($), fixed_operating_cos ($), variable_operating_cost ($/kWh), balance_of_system_cost ($). Data source priority: outputs, plant_optimizer, original_sam_sys_inputs, meta
- run_wind_plant_ts()[source]
Run the wind plant multi-year timeseries analysis and export output requests to outputs property.
- Returns:
outputs (dict) – Output dictionary for the full BespokeSinglePlant object. The multi-year timeseries data is also exported to the BespokeSinglePlant.outputs property.
- run_plant_optimization()[source]
Run the wind plant layout optimization and export outputs to outputs property.
- Returns:
outputs (dict) – Output dictionary for the full BespokeSinglePlant object. The layout optimization output data is also exported to the BespokeSinglePlant.outputs property.
- property outputs
Saved outputs for the single wind plant bespoke optimization.
- Returns:
dict