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
Aandkat every point whose moments cannot be fitted: where an input is NaN or infinite,m1orm3is not positive,freq_gt_meanis outside (0, 1),m3is belowm1**3by more than a relative 1e-12, which no wind speed distribution allows, or the shape parameter that reproducesm3andfreq_gt_meanlies outside [1/32, 128). A histogram with a single occupied bin, wherem3equalsm1**3up to rounding, is still fitted, because the fit matches the frequency abovem1rather thanm1itself.