flasc.data_processing.energy_ratio_wd_bias_estimation#
Module to estimate the wind direction bias.
Classes
Class to determine bias in wind direction measurement. |
- class flasc.data_processing.energy_ratio_wd_bias_estimation.bias_estimation(df, df_fm_approx, test_turbines_subset, df_ws_mapping_func, df_pow_ref_mapping_func)[source]#
Class to determine bias in wind direction measurement.
This class can be used to estimate the bias (offset) in a wind direction measurement by comparing the energy ratios in the SCADA data with the predicted energy ratios from FLORIS under various bias correction values. Essentially, this class solves the following optimization problem: the argument in this optimization problem is the offset on the wind direction measurement and the cost is the Pearson correlation coefficient between two lines, namely 1) the energy ratios of the SCADA data, and 2) the predicted energy ratios for the same data by FLORIS under the offset-corrected wind direction.
- Parameters:
df (DataFrame)
df_fm_approx (DataFrame)
test_turbines_subset (List[int])
df_ws_mapping_func (Callable)
df_pow_ref_mapping_func (Callable)
- _load_er_input_for_wd_bias(wd_bias)[source]#
Load EnergyRatioInput objects with bias.
This function initializes an instance of the EnergyRatioInput where the dataframe is shifted by wd_bias for each test turbine. This facilitates the calculation of the energy ratios under this hypothesized wind direction bias. Additionally, the FLORIS predictions for the shifted dataset are calculated and the energy ratios for the FLORIS predictions are also calculated.
- Parameters:
wd_bias (float) -- Hypothesized wind direction bias in degrees.
test_turbines ([iteratible]) -- List of test turbines for which each the energy ratios are calculated and the Pearson correlation coefficients are calculated. Note that this variable is slightly different from 'test_turbines' in the energy ratio classes. Namely, in this class, the energy ratio is calculated for each entry in test_turbines.
- Returns:
- The energy ratio table
object in which the inserted dataframe has a shifted wind direction measurement, offset by 'wd_bias' compared to the nominal dataset.
- Return type:
et ([polars dataframe])
- _get_energy_ratios_allbins(wd_bias, time_mask=None, ws_mask=(6.0, 10.0), wd_mask=None, ti_mask=None, wd_step=3.0, ws_step=1.0, wd_bin_width=3.0, N_btstrp=1, plot_iter_path=None)[source]#
Calculate the energy ratios.
- Parameters:
wd_bias (float) -- Wind direction bias in degrees.
time_mask ([iterable], optional) -- Mask. If None, will not mask the data based on this variable. Defaults to None.
ws_mask ([iterable], optional) -- Wind speed mask. Should be an iterable of length 2, e.g., [6.0, 10.0], defining the lower and upper bound, respectively. If not specified, will not mask the data based on this variable. Defaults to (6, 10).
wd_mask ([iterable], optional) -- Wind direction mask. Should be an iterable of length 2, e.g., [0.0, 180.0], defining the lower and upper bound, respectively. If not specified, will not mask the data based on this variable. Defaults to None.
ti_mask ([iterable], optional) -- Turbulence intensity mask. Should be an iterable of length 2, e.g., [0.04, 0.08], defining the lower and upper bound, respectively. If not specified, will not mask the data based on this variable. Defaults to None.
wd_step (float, optional) -- Wind direction discretization step size. This defines for what wind directions the energy ratio is to be calculated. Note that this does not necessarily also mean each bin has a width of this value. Namely, the bin width can be specified separately. Defaults to 2.0.
ws_step (float, optional) -- Wind speed discretization step size. This defines the resolution and widths of the wind speed bins. Defaults to 1.0.
wd_bin_width ([type], optional) -- The wind direction bin width. This value should be equal or larger than wd_step. When no value is specified, will default to wd_bin_width = wd_step. In the literature, it is not uncommon to specify a bin width larger than the step size to cover for variability in the wind direction measurements. By setting a large value for wd_bin_width, one gets a better idea of the larger-scale wake losses in the wind farm. Defaults to None.
N_btstrp (int, optional) -- Number of bootstrap evaluations for uncertainty quantification (UQ). If N_btstrp=1, will not perform any uncertainty quantification. Defaults to 1.
plot_iter_path ([type], optional) -- Path to save figures of the energy ratios of each iteration to. If not specified, will not plot or save any figures of iterations. Defaults to None.
- calculate_baseline(time_mask=None, ws_mask=(6.0, 10.0), wd_mask=None, ti_mask=None, er_wd_step=3.0, er_ws_step=5.0, er_wd_bin_width=None, er_N_btstrp=1)[source]#
Calculate Baseline energy ratios.
- Parameters:
time_mask ([iterable], optional) -- Time Mask.
ws_mask ([iterable], optional) -- Wind speed mask. Should be an iterable of length 2, e.g., [6.0, 10.0], defining the lower and upper bound, respectively. If not specified, will not mask the data based on this variable. Defaults to (6, 10).
wd_mask ([iterable], optional) -- Wind direction mask. Should be an iterable of length 2, e.g., [0.0, 180.0], defining the lower and upper bound, respectively. If not specified, will not mask the data based on this variable. Defaults to None.
ti_mask ([iterable], optional) -- Turbulence intensity mask. Should be an iterable of length 2, e.g., [0.04, 0.08], defining the lower and upper bound, respectively. If not specified, will not mask the data based on this variable. Defaults to None.
er_wd_step (float, optional) -- Wind direction step size. Defaults to 3.0.
er_ws_step (float, optional) -- Wind speed step size. Defaults to 5.0.
er_wd_bin_width ([type], optional) -- Wind direction bin width. Defaults to None.
er_N_btstrp (int, optional) -- Number of bootstrap evaluations for uncertainty quantification (UQ). If N_btstrp=1, will not perform any uncertainty quantification. Defaults to 1.
- estimate_wd_bias(time_mask=None, ws_mask=(6.0, 10.0), wd_mask=None, ti_mask=None, opt_search_range=(-180.0, 180.0), opt_search_brute_dx=5, opt_workers=4, er_wd_step=3.0, er_ws_step=5.0, er_wd_bin_width=None, er_N_btstrp=1, plot_iter_path=None)[source]#
Estimate wd bias.
Estimate the wind direction bias by comparing the SCADA data under various wind direction corrections to its FLORIS predictions.
- Parameters:
time_mask ([iterable], optional) -- Time mask. Should be an iterable of length 2, e.g., [pd.to_datetime("2019-01-01"), pd.to_datetime("2019-04-01")], defining the lower and upper bound, respectively. If not specified, will not mask the data based on this variable. Defaults to None.
ws_mask ([iterable], optional) -- Wind speed mask. Should be an iterable of length 2, e.g., [6.0, 10.0], defining the lower and upper bound, respectively. If not specified, will not mask the data based on this variable. Defaults to (6, 10).
wd_mask ([iterable], optional) -- Wind direction mask. Should be an iterable of length 2, e.g., [0.0, 180.0], defining the lower and upper bound, respectively. If not specified, will not mask the data based on this variable. Defaults to None.
ti_mask ([iterable], optional) -- Turbulence intensity mask. Should be an iterable of length 2, e.g., [0.04, 0.08], defining the lower and upper bound, respectively. If not specified, will not mask the data based on this variable. Defaults to None.
opt_search_range (tuple, optional) -- Search range for the wind direction offsets to consider. Defaults to (-180., 180.).
opt_search_brute_dx (float, optional) -- Number of points to discretize the search space over. Defaults to 5.
opt_workers (int, optional) -- Number of workers to use for the optimization. Defaults to 4.
er_wd_step (float, optional) -- Wind direction discretization step size. This defines for what wind directions the energy ratio is to be calculated. Note that this does not necessarily also mean each bin has a width of this value. Namely, the bin width can be specified separately. Defaults to 3.0.
er_ws_step (float, optional) -- Wind speed discretization step size. This defines the resolution and widths of the wind speed bins. Defaults to 5.0.
er_wd_bin_width ([type], optional) -- The wind direction bin width. This value should be equal or larger than wd_step. When no value is specified, will default to wd_bin_width = wd_step. In the literature, it is not uncommon to specify a bin width larger than the step size to cover for variability in the wind direction measurements. By setting a large value for wd_bin_width, one gets a better idea of the larger-scale wake losses in the wind farm. Defaults to None.
er_N_btstrp (int, optional) -- Number of bootstrap evaluations for uncertainty quantification (UQ). If N_btstrp=1, will not perform any uncertainty quantification. Defaults to 1.
plot_iter_path ([type], optional) -- Path to save figures of the energy ratios of each iteration to. If not specified, will not plot or save any figures of iterations. Defaults to None.
- Returns:
- The optimal wind direction offset and
the cost function under the optimal offset.
- Return type:
A tuple (float, float)
- plot_energy_ratios(show_uncorrected_data=False, save_path=None, format='png', dpi=200)[source]#
Plot energy ratios.
Plot the energy ratios for the currently evaluated wind direction offset term.
- Parameters:
show_uncorrected_data (bool, optional) -- Compute and show the uncorrected energy ratio (with wd_bias=0) on the plot. Defaults to False.
save_path ([str], optional) -- Path to save the figure to. If not specified, will not save the figure. Defaults to None.
format (str, optional) -- Figure format. Defaults to 'png'.
dpi (int, optional) -- Figure DPI. Defaults to 200.