flasc.utilities.tuner_utilities

flasc.utilities.tuner_utilities#

Utilities for tuning FLORIS parameters.

This module contains utilities for tuning FLORIS parameters. This includes functions for resimulating FLORIS with SCADA data, and functions for setting parameters in a FLORIS model.

Functions

nested_get

Get a value from a nested dictionary using a list of keys.

nested_set

Set a value in a nested dictionary using a list of keys.

replicate_nan_values

Replicate NaN Values in DataFrame df_2 to Match DataFrame df_1.

resim_floris

Resimulate FLORIS with SCADA data.

flasc.utilities.tuner_utilities.replicate_nan_values(df_1, df_2)[source]#

Replicate NaN Values in DataFrame df_2 to Match DataFrame df_1.

For columns that are common between df_1 and df_2, this function ensures that NaN values in df_2 appear in the same locations as NaN values in df_1. This is primarily useful when df_2 represents a FLORIS resimulation of df_1, and you want to ensure that missing data is consistent between the two DataFrames.

Parameters:
  • df_1 (pandas.DataFrame) -- The reference DataFrame containing NaN values.

  • df_2 (pandas.DataFrame) -- The DataFrame to be updated to match NaN positions in df_1.

Returns:

A new DataFrame with NaN values in df_2 replaced to match df_1.

Return type:

pandas.DataFrame

flasc.utilities.tuner_utilities.nested_get(dic, keys)[source]#

Get a value from a nested dictionary using a list of keys.

Based on: stackoverflow.com/questions/14692690/access-nested-dictionary-items-via-a-list-of-keys

Return type:

Any

Parameters:
  • dic (Dict[str, Any]) -- The dictionary to get the value from.

  • keys (List[str]) -- A list of keys to traverse the dictionary.

Returns:

The value at the end of the key traversal.

Return type:

Any

flasc.utilities.tuner_utilities.nested_set(dic, keys, value, idx=None)[source]#

Set a value in a nested dictionary using a list of keys.

Based on: stackoverflow.com/questions/14692690/access-nested-dictionary-items-via-a-list-of-keys

Return type:

None

Parameters:
  • dic (Dict[str, Any]) -- The dictionary to set the value in.

  • keys (List[str]) -- A list of keys to traverse the dictionary.

  • value (Any) -- The value to set.

  • idx (Optional[int], optional) -- If the value is an list, the index to change. Defaults to None.

flasc.utilities.tuner_utilities.resim_floris(fm_in, df_scada, yaw_angles=None)[source]#

Resimulate FLORIS with SCADA data.

This function takes a FlorisModel and a SCADA dataframe, and resimulates the FlorisModel with the SCADA data. The SCADA data is expected to contain columns for wind speed, wind direction, and power reference. The function returns a dataframe containing the power output of each turbine in the FlorisModel.

Parameters:
  • fm_in (FlorisModel) -- The FlorisModel to resimulate.

  • df_scada (pd.DataFrame) -- The SCADA data to use for resimulation.

  • yaw_angles (np.array, optional) -- The yaw angles to use for resimulation. Defaults to None.

Returns:

A DataFrame containing the power output of each turbine in the FlorisModel.

Return type:

pd.DataFrame