flasc.analysis.expected_power_analysis_utilities#

Utilities for SCADA data using expected power methods.

flasc.analysis.expected_power_analysis_utilities._add_wd_ws_bins(df_: DataFrame, wd_cols: List[str], ws_cols: List[str], wd_step: float = 2.0, wd_min: float = 0.0, wd_max: float = 360.0, ws_step: float = 1.0, ws_min: float = 0.0, ws_max: float = 50.0) DataFrame[source]#

Add wind direction (wd) and wind speed (ws) bin columns to the dataframe.

Parameters:
  • df (pl.DataFrame) -- A polars dataframe, exported from a_in.get_df()

  • wd_cols (List[str]) -- A list of column names for wind direction

  • ws_cols (List[str]) -- A list of column names for wind speed

  • wd_step (float) -- The step size for the wind direction bins. Defaults to 2.0.

  • wd_min (float) -- The minimum wind direction value. Defaults to 0.0.

  • wd_max (float) -- The maximum wind direction value. Defaults to 360.0.

  • ws_step (float) -- The step size for the wind speed bins. Defaults to 1.0.

  • ws_min (float) -- The minimum wind speed value. Defaults to 0.0.

  • ws_max (float) -- The maximum wind speed value. Defaults to 50.0.

  • df_ (DataFrame)

Returns:

A polars dataframe with the wd and ws bin columns added.

Return type:

pl.DataFrame

flasc.analysis.expected_power_analysis_utilities._bin_and_group_dataframe_expected_power(df_: DataFrame, test_cols: List[str], bin_cols_without_df_name: List[str] = ['wd_bin', 'ws_bin']) DataFrame[source]#

Group dataframes by bin columns and calculate the mean and variance of the test columns.

Parameters:
  • df (pl.DataFrame) -- A polars dataframe, exported from a_in.get_df()

  • test_cols (List[str]) -- A list of column names to calculate the mean and variance of

  • bin_cols_without_df_name (List[str]) -- A list of column names to bin the dataframes by. Defaults to ["wd_bin", "ws_bin"].

  • df_ (DataFrame)

Returns:

A polars dataframe with the mean and variance of the test columns

grouped by bin columns.

Return type:

pl.DataFrame

flasc.analysis.expected_power_analysis_utilities._synchronize_nulls(df_bin: DataFrame, sync_cols: List[str], uplift_pairs: List[List[str]], bin_cols_without_df_name: List[str] = ['wd_bin', 'ws_bin']) DataFrame[source]#

Copy the nans from the test columns in one of df_name to the other within uplift pairs.

Parameters:
  • df_bin (pl.DataFrame) -- A polars dataframe with the mean and variance of the test columns grouped by bin columns.

  • sync_cols (List[str]) -- Columns to synchronize.

  • uplift_pairs (List[List[str]]) -- A list of the df_name values to copy the nans from for each pair

  • bin_cols_without_df_name (List[str]) -- A list of column names to bin the dataframes by. Defaults to ["wd_bin", "ws_bin"].

Returns:

A polars dataframe with the nans copied from one of the df_name values

to the other.

Return type:

pl.DataFrame

flasc.analysis.expected_power_analysis_utilities._get_num_points_pair(df_: DataFrame, test_cols: List[str], bin_cols_with_df_name: List[str]) DataFrame[source]#

Get the number of points for each pair of test columns.

Parameters:
  • df (pl.DataFrame) -- A polars dataframe

  • test_cols (List[str]) -- A list of column names to calculate the number of points for

  • bin_cols_with_df_name (List[str]) -- A list of column names to bin the dataframes by.

  • df_ (DataFrame)

Returns:

A polars dataframe with the number of points for each pair of test columns.

Return type:

pl.DataFrame

flasc.analysis.expected_power_analysis_utilities._compute_covariance(df_: DataFrame, test_cols: List[str], bin_cols_with_df_name: List[str]) DataFrame[source]#

Compute the covariance matrix for the test columns.

Parameters:
  • df (pl.DataFrame) -- A polars dataframe

  • test_cols (List[str]) -- A list of column names to calculate the covariance of

  • bin_cols_with_df_name (List[str]) -- A list of column names to bin the dataframes by.

  • df_ (DataFrame)

Returns:

A polars dataframe with the covariance matrix.

Return type:

pl.DataFrame

flasc.analysis.expected_power_analysis_utilities._fill_cov_with_var(df_cov: DataFrame, test_cols: List[str], fill_all: bool = True) DataFrame[source]#

Fill covariance terms with the product of the square root of the variances.

Fill the null (or all) values in the covariance matrix with the product of the square root of the variances of the corresponding test columns.

Leave the number of points as is (the number of shared points between the two test columns).

Parameters:
  • df_cov (pl.DataFrame) -- A polars dataframe with the covariance matrix

  • test_cols (List[str]) -- A list of column names to calculate the covariance of

  • fill_all (bool) -- If True, fill all values of cov, regardless of whether or not missing/Null

Returns:

A polars dataframe with the null values filled according to the strategy.

Return type:

pl.DataFrame

flasc.analysis.expected_power_analysis_utilities._set_cov_to_zero(df_cov: DataFrame, test_cols: List[str]) DataFrame[source]#

Set all covariance terms to 0, leaving only the variances.

Parameters:
  • df_cov (pl.DataFrame) -- A polars dataframe with the covariance matrix

  • test_cols (List[str]) -- A list of column names to calculate the covariance of

Returns:

A polars dataframe with the covariance terms set to 0.

Return type:

pl.DataFrame

flasc.analysis.expected_power_analysis_utilities._synchronize_var_nulls_back_to_mean(df_bin: DataFrame, test_cols: List[str]) DataFrame[source]#

For each row, for any turbine with a null var, null mean power.

For each row, if there are any turbines with undefined variances

(because count < 2), then the mean power for those turbines would get set to Null as well.

Parameters:
  • df_bin (pl.DataFrame) -- A polars dataframe with the mean and variance of the test columns grouped by bin columns.

  • test_cols (List[str]) -- A list of column names to calculate the covariance of

Returns:

Update df_bin dataframe

Return type:

pl.DataFrame