← All posts

Fitting Weibull Distributions to ERA5 Wind Data

python
yield-assessment
data-analysis
Using scipy to fit Weibull parameters to ERA5 reanalysis wind speed data.
Author

Majid Bastankhah

Published

March 18, 2026

Introduction

The Weibull distribution is the standard model for offshore wind speed frequency. Here we fit it to ERA5 10m wind speed data using maximum likelihood estimation.

Code
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt

Simulate ERA5-like wind speeds and fit

Code
rng = np.random.default_rng(42)
wind_speeds = rng.weibull(2.2, size=8760) * 9.5  # k=2.2, A=9.5 m/s

c, loc, scale = stats.weibull_min.fit(wind_speeds, floc=0)
print(f'Fitted k={c:.2f}, A={scale:.2f} m/s')
Code
x = np.linspace(0, 25, 200)
pdf_fitted = stats.weibull_min.pdf(x, c, loc, scale)

fig, ax = plt.subplots(figsize=(8, 4))
ax.hist(wind_speeds, bins=40, density=True, alpha=0.5, label='ERA5 data')
ax.plot(x, pdf_fitted, lw=2, label=f'Weibull fit (k={c:.2f})')
ax.set_xlabel('Wind speed (m/s)')
ax.set_ylabel('Probability density')
ax.legend()
plt.tight_layout()

Conclusion

The MLE fit recovers the shape parameter closely. This fitted distribution feeds directly into AEP calculations via numerical integration against the turbine power curve.