flasc.utilities.utilities#

Utility functions for the FLASC module.

Functions

estimate_dt

Automatically estimate timestep in a time_array.

get_num_turbines

Get the number of turbines in a dataframe.

interp_with_max_gap

Interpolate data linearly or using nearest-neighbor with maximum gap.

flasc.utilities.utilities.estimate_dt(time_array)[source]#

Automatically estimate timestep in a time_array.

Parameters:

time_array (list) -- List or dataframe with time entries

Returns:

Timestep in dt.timedelta format

Return type:

datetime.timedelta

flasc.utilities.utilities.get_num_turbines(df)[source]#

Get the number of turbines in a dataframe.

Parameters:

df (pd.DataFrame | FlascDataFrame) -- Dataframe with turbine data

Returns:

Number of turbines in the dataframe

Return type:

int

flasc.utilities.utilities.interp_with_max_gap(x, xp, fp, max_gap, kind, wrap_around_360=False)[source]#

Interpolate data linearly or using nearest-neighbor with maximum gap.

If there is larger gap in data than max_gap, the gap will be filled with np.nan.

Parameters:
  • x (np.array) -- The output x-data; the data points in x-axis that you want the interpolation results from.

  • xp (np.array) -- The input x-data.

  • fp (np.array) -- The input y-data.

  • max_gap (float) -- The maximum allowable distance between x and xp for which interpolation is still performed. Gaps larger than this will be filled with np.nan in the output target_y.

  • kind (str) -- The interpolation method to use. Can be 'linear' or 'nearest'.

  • wrap_around_360 (bool) -- If True, the interpolation will be done in a circular fashion, i.e., the interpolation will wrap around 360 degrees.

Returns:

The interpolation results.

Return type:

np.array

flasc.utilities.utilities._interpolate_with_max_gap(x, xp, fp, max_gap, assume_sorted=False, kind='linear', extrapolate=True)[source]#

Interpolate data linearly or using nearest-neighbor with maximum gap.

If there is larger gap in data than max_gap, the gap will be filled with np.nan.

The input values should not contain NaNs.

Parameters:
  • x (np.array) -- The output x-data; the data points in x-axis that you want the interpolation results from.

  • xp (np.array) -- The input x-data.

  • fp (np.array) -- The input y-data.

  • max_gap (float) -- The maximum allowable distance between x and xp for which interpolation is still performed. Gaps larger than this will be filled with np.nan in the output target_y.

  • assume_sorted (bool) -- If True, assume that xp is sorted in ascending order. If False, sort xp and fp to be monotonous.

  • kind (str) -- The interpolation method to use. Can be 'linear' or 'nearest'.

  • extrapolate (bool) -- If True, extrapolate the data points on the boundaries

Returns:

The interpolation results.

Return type:

np.array