windkit.weibull.fit_weibull_wasp_m1_m3_fgtm#

windkit.weibull.fit_weibull_wasp_m1_m3_fgtm(m1, m3, freq_gt_mean, atol=1e-08)[source]#

Fit weibull parameters from the first and third moments and the fraction of probability mass above the mean

Parameters:
  • m1 (xarray.DataArray, array-like, or scalar) – First moment / mean

  • m3 (xarray.DataArray, array-like, or scalar) – Third moment / skewness

  • freq_gt_mean (xarray.DataArray, array-like, or scalar) – Skewness term: frequency-mass that falls above the mean value

  • atol (float) – Absolute tolerance for root-finding algorithm, applied to 3 / k

Returns:

  • A (xarray.DataArray, numpy.ndarray, or numpy scalar) – Weibull scale parameter, mirroring the input type. NaN where the moments cannot be fitted, see Notes.

  • k (xarray.DataArray, numpy.ndarray, or numpy scalar) – Weibull shape parameter, mirroring the input type. NaN where the moments cannot be fitted, see Notes.

Notes

This function has the optional dependency ‘numba’. If numba is installed, the function will use a numba-compiled version of the algorithm which is much faster. If numba is not installed, the function will use a scipy-based root-finding algorithm and vectorization through np.vectorize which is much slower.

Both backends return NaN for A and k at every point whose moments cannot be fitted: where an input is NaN or infinite, m1 or m3 is not positive, freq_gt_mean is outside (0, 1), m3 is below m1**3 by more than a relative 1e-12, which no wind speed distribution allows, or the shape parameter that reproduces m3 and freq_gt_mean lies outside [1/32, 128). A histogram with a single occupied bin, where m3 equals m1**3 up to rounding, is still fitted, because the fit matches the frequency above m1 rather than m1 itself.