flasc.utilities.energy_ratio_utilities.add_reflected_rows

flasc.utilities.energy_ratio_utilities.add_reflected_rows#

flasc.utilities.energy_ratio_utilities.add_reflected_rows(df_, edges, overlap_distance)[source]#

Add reflected rows to a dataframe.

Adds rows to a dataframe with where the wind direction is reflected around the nearest edge if within overlap_distance

Given a wind direction DataFrame df_, this function adds reflected rows to the DataFrame such that each wind direction in the original DataFrame has a corresponding reflected wind direction. The reflected wind direction is calculated by subtracting the wind direction from the nearest edge in edges and then subtracting that difference again from the original wind direction. The resulting wind direction is then wrapped around to the range [0, 360) degrees. The function returns a new DataFrame with the original rows and the added reflected rows.

This function enables overlapping bins in the energy ratio functions

Parameters:
  • df -- polars.DataFrame The DataFrame to add reflected rows to.

  • edges (ndarray | list) -- numpy.ndarray An array of wind direction edges to use for reflection. (Should be same as used in energy ratio)

  • overlap_distance (float) -- float The maximum distance between a wind direction and an edge for the wind direction to be considered overlapping.

  • df_ (DataFrame)

Returns:

polars.DataFrame

A new DataFrame with the original rows and the added reflected rows.