Loads Module
The loads module contains a set of functions to calculate quantities of interest for mechanical loads assessments.
General
The loads general submodule contains general loads calculations that can be applied to most MRE devices.
Bins calculated statistics against data signal (or channel) according to IEC TS 626003:2020 ED1. 

Transfer function for deriving blade flap and edge moments using blade matrix. 

Calculates the damage equivalent load of a single data signal (or channel) based on IEC TS 626003:2020 ED1. 
This module provides tools for analyzing and processing data signals related to turbine blade performance and fatigue analysis. It implements methodologies based on standards such as IEC TS 626003:2020 ED1, incorporating statistical binning, moment calculations, and fatigue damage estimation using the rainflow counting algorithm. Key functionalities include:
bin_statistics: Bins timeseries data against a specified signal, such as wind speed, to calculate mean and standard deviation statistics for each bin, following IEC TS 626003:2020 ED1 guidelines. It supports output in both pandas DataFrame and xarray Dataset formats.
blade_moments: Calculates the flapwise and edgewise moments of turbine blades using derived calibration coefficients and raw strain signals. This function is crucial for understanding the loading and performance characteristics of turbine blades.
damage_equivalent_load: Estimates the damage equivalent load (DEL) of a single data signal using a 4point rainflow counting algorithm. This method is vital for assessing fatigue life and durability of materials under variable amplitude loading.
References:  C. Amzallag et. al., International Journal of Fatigue, 16 (1994) 287293.  ISO 121102, Metallic materials  Fatigue testing  Variable amplitude fatigue testing.  G. Marsh et. al., International Journal of Fatigue, 82 (2016) 757765.
 mhkit.loads.general.bin_statistics(data: DataFrame  Dataset, bin_against: ndarray, bin_edges: ndarray, data_signal: List[str]  None = None, to_pandas: bool = True) Tuple[DataFrame  Dataset, DataFrame  Dataset] [source]
Bins calculated statistics against data signal (or channel) according to IEC TS 626003:2020 ED1.
 Parameters:
data (pandas DataFrame or xarray Dataset) – Timeseries statistics of data signal(s)
bin_against (array) – Data signal to bin data against (e.g. wind speed)
bin_edges (array) – Bin edges with consistent step size
data_signal (list, optional) – List of data signal(s) to bin, default = all data signals
to_pandas (bool (optional)) – Flag to output pandas instead of xarray. Default = True.
 Returns:
bin_mean (pandas DataFrame or xarray Dataset) – Mean of each bin
bin_std (pandas DataFrame or xarray Dataset) – Standard deviation of each bim
 mhkit.loads.general.blade_moments(blade_coefficients: ndarray, flap_offset: float, flap_raw: ndarray, edge_offset: float, edge_raw: ndarray) Tuple[ndarray, ndarray] [source]
Transfer function for deriving blade flap and edge moments using blade matrix.
 Parameters:
blade_coefficients (numpy array) – Derived blade calibration coefficients listed in order of D1, D2, D3, D4
flap_offset (float) – Derived offset of raw flap signal obtained during calibration process
flap_raw (numpy array) – Raw strain signal of blade in the flapwise direction
edge_offset (float) – Derived offset of raw edge signal obtained during calibration process
edge_raw (numpy array) – Raw strain signal of blade in the edgewise direction
 Returns:
M_flap (numpy array) – Blade flapwise moment in SI units
M_edge (numpy array) – Blade edgewise moment in SI units
 mhkit.loads.general.damage_equivalent_load(data_signal: ndarray, m: float  int, bin_num: int = 100, data_length: float  int = 600) float [source]
Calculates the damage equivalent load of a single data signal (or channel) based on IEC TS 626003:2020 ED1. 4point rainflow counting algorithm from fatpack module is based on the following resources:
C. Amzallag et. al. Standardization of the rainflow counting method for fatigue analysis. International Journal of Fatigue, 16 (1994) 287293
ISO 121102, Metallic materials  Fatigue testing  Variable amplitude fatigue testing.
G. Marsh et. al. Review and application of Rainflow residue processing techniques for accurate fatigue damage estimation. International Journal of Fatigue, 82 (2016) 757765
Parameters:
 data_signalarray
Data signal being analyzed
 mfloat/int
Fatigue slope factor of material
 bin_numint
Number of bins for rainflow counting method (minimum=100)
 data_lengthfloat/int
Length of measured data (seconds)
 returns:
DEL (float) – Damage equivalent load (DEL) of single data signal
Graphics
The graphics submodule contains functions to plot loads metrics.
Plot showing standard raw statistics of variable 

Plot showing standard binned statistics of single variable 
This module provides functionalities for plotting statistical data related to a given variable or dataset.
plot_statistics is designed to plot raw statistical measures (mean, maximum, minimum, and optional standard deviation) of a variable across a series of xaxis values. It allows for customization of plot labels, title, and saving the plot to a file.
plot_bin_statistics extends these capabilities to binned data, offering a way to visualize binned statistics (mean, maximum, minimum) along with their respective standard deviations. This function also supports label and title customization, as well as saving the plot to a specified path.
 mhkit.loads.graphics.plot_statistics(x: ndarray, y_mean: ndarray, y_max: ndarray, y_min: ndarray, y_stdev: ndarray  None = None, **kwargs: Dict[str, Any]) Axes [source]
Plot showing standard raw statistics of variable
 Parameters:
x (numpy array) – Array of xaxis values
y_mean (numpy array) – Array of mean statistical values of variable
y_max (numpy array) – Array of max statistical values of variable
y_min (numpy array) – Array of min statistical values of variable
y_stdev (numpy array, optional) – Array of standard deviation statistical values of variable
**kwargs (optional) –
 x_labelstring
x axis label for plot
 y_labelstring
y axis label for plot
 titlestring, optional
Title for plot
 save_pathstring
Path and filename to save figure.
 Returns:
ax (matplotlib pyplot axes)
 mhkit.loads.graphics.plot_bin_statistics(bin_centers: ndarray, bin_mean: ndarray, bin_max: ndarray, bin_min: ndarray, bin_mean_std: ndarray, bin_max_std: ndarray, bin_min_std: ndarray, **kwargs: Dict[str, Any]) Axes [source]
Plot showing standard binned statistics of single variable
 Parameters:
bin_centers (numpy array) – xaxis bin center values
bin_mean (numpy array) – Binned mean statistical values of variable
bin_max (numpy array) – Binned max statistical values of variable
bin_min (numpy array) – Binned min statistical values of variable
bin_mean_std (numpy array) – Standard deviations of mean binned statistics
bin_max_std (numpy array) – Standard deviations of max binned statistics
bin_min_std (numpy array) – Standard deviations of min binned statistics
**kwargs (optional) –
 x_labelstring
x axis label for plot
 y_labelstring
y axis label for plot
 titlestring, optional
Title for plot
 save_pathstring
Path and filename to save figure.
 Returns:
ax (matplotlib pyplot axes)
Extreme
The extreme submodule contains functions to calculate peak distribution.

Find the global peaks of a zerocentered response timeseries. 

Estimate the number of peaks in a specified period. 

Estimate the peaks distribution by fitting a Weibull distribution to the peaks of the response. 

Estimate the peaks distribution using the Weibull tail fit method. 

Estimate the peaks distribution using the peaks over threshold method. 

Estimate the shortterm extreme distribution from the peaks distribution. 

Find the block maxima of a timeseries. 

Approximate the shortterm extreme distribution using the block maxima method and the Generalized Extreme Value distribution. 

Approximate the shortterm extreme distribution using the block maxima method and the Gumbel (right) distribution. 

Approximate the shortterm extreme distribution from a timeseries of the response using chosen method. 

Return the longterm extreme distribution of a response of interest using the full sea state approach. 

Calculate MLER (most likely extreme response) coefficients from a sea state spectrum and a response RAO. 

Define the simulation parameters that are used in various MLER functionalities. 

Function that renormalizes the incoming amplitude of the MLER wave to the desired peak height (peak to MSL). 

Generate the wave amplitude time series at X0 from the calculated MLER coefficients 
This package provides tools and functions for extreme value analysis and wave data statistics.
It includes methods for calculating peaks over threshold, estimating shortterm extreme distributions,and performing wave amplitude normalization for most likely extreme response analysis.