Welcome to the windpowerlib documentation!¶
Contents:
Getting started¶
Introduction¶
The windpowerlib is a library that provides a set of functions and classes to calculate the power output of wind turbines. It was originally part of the feedinlib (windpower and photovoltaic) but was taken out to build up a community concentrating on wind power models.
For a quick start see the Examples and basic usage section.
Documentation¶
Full documentation can be found at readthedocs.
Use the project site of readthedocs to choose the version of the documentation. Go to the download page to download different versions and formats (pdf, html, epub) of the documentation.
Installation¶
If you have a working Python 3 environment, use pypi to install the latest windpowerlib version:
pip install windpowerlib
The windpowerlib is designed for Python 3 and tested on Python >= 3.5. We highly recommend to use virtual environments. Please see the installation page of the oemof documentation for complete instructions on how to install python and a virtual environment on your operating system.
Optional Packages¶
To see the plots of the windpowerlib example in the Examples and basic usage section you should install the matplotlib package. Matplotlib can be installed using pip:
pip install matplotlib
Examples and basic usage¶
The basic usage of the windpowerlib is shown in the ModelChain example that is available as jupyter notebook and python script:
To run the example you need the example weather and turbine data used:
Example weather data file
Example power curve data file
Example power coefficient curve data file
Example nominal power data file
Furthermore, you have to install the windpowerlib and to run the notebook you also need to install notebook using pip3. To launch jupyter notebook type jupyter notebook
in the terminal.
This will open a browser window. Navigate to the directory containing the notebook to open it. See the jupyter notebook quick start guide for more information on how to install and
how to run jupyter notebooks.
Further functionalities, like the modelling of wind farms and wind turbine clusters, are shown in the TurbineClusterModelChain example. As the ModelChain example it is available as jupyter notebook and as python script. The weather and turbine data in this example is the same as in the example above.
You can also look at the examples in the Examples section.
Wind turbine data¶
The windpowerlib provides data of many wind turbines but it is also possible to use your own turbine data.
Use internal data¶
The windpowerlib provides wind turbine data (power curves, hub heights, etc.) for a large set of wind turbines. See Initialize wind turbine in Examples on how to use this data in your simulations.
The dataset is hosted and maintained on the OpenEnergy database (oedb). To update your local files with the latest version of the oedb turbine library you can execute the following in your python console:
from windpowerlib.wind_turbine import load_turbine_data_from_oedb
load_turbine_data_from_oedb()
If you find your turbine in the database it is very easy to use it in the windpowerlib
from windpowerlib import WindTurbine
enercon_e126 = {
"turbine_type": "E-126/4200", # turbine type as in register
"hub_height": 135, # in m
}
e126 = WindTurbine(**enercon_e126)
We would like to encourage anyone to contribute to the turbine library by adding turbine data or reporting errors in the data. See here for more information on how to contribute.
Use your own turbine data¶
It is possible to use your own power curve. However, the most sustainable way is to send us the data to be included in the windpowerlib and to be available for all users. This may not be possible in all cases.
Assuming the data files looks like this:
You can use pandas to read the file and pass it to the turbine dictionary. I you have basic knowledge of pandas it is easy to use any kind of data file.
import pandas as pd
from windpowerlib import WindTurbine, create_power_curve
my_data = pd.read_csv("path/to/my/data/file.csv")
my_turbine_data = {
"nominal_power": 6e6, # in W
"hub_height": 115, # in m
"power_curve": create_power_curve(
wind_speed=my_data["wind"], power=my_data["power"]
),
}
my_turbine = WindTurbine(**my_turbine2)
See the modelchain_example for more information.
Contributing¶
We are warmly welcoming all who want to contribute to the windpowerlib. If you are interested in wind models and want to help improving the existing model do not hesitate to contact us via github or email (windpowerlib@rl-institut.de).
Clone: https://github.com/wind-python/windpowerlib and install the cloned repository using pip:
pip install -e /path/to/the/repository
As the windpowerlib started with contributors from the oemof developer group we use the same developer rules.
How to create a pull request:
- Fork the windpowerlib repository to your own github account.
- Change, add or remove code.
- Commit your changes.
- Create a pull request and describe what you will do and why.
- Wait for approval.
Generally the following steps are required when changing, adding or removing code:
- Add new tests if you have written new functions/classes.
- Add/change the documentation (new feature, API changes …).
- Add a whatsnew entry and your name to Contributors.
- Check if all tests still work by simply executing pytest in your windpowerlib directory:
pytest
Citing the windpowerlib¶
We use the zenodo project to get a DOI for each version. Search zenodo for the right citation of your windpowerlib version.
License (MIT)¶
Copyright (c) 2019 oemof developer group
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Examples¶
SPDX-FileCopyrightText: 2019 oemof developer group contact@oemof.org
SPDX-License-Identifier: MIT
SPDX-License-Identifier: CC-BY-4.0
ModelChain example¶
This example shows you the basic usage of the windpowerlib by using the ModelChain
class. There are mainly three steps. First you have to import your weather data, then you need to specify your wind turbine, and in the last step call the windpowerlib functions to calculate the feed-in time series.
Before you start you have to import the packages needed for these steps.
Import necessary packages and modules¶
[1]:
import os
import pandas as pd
import requests
from windpowerlib import ModelChain, WindTurbine, create_power_curve
from windpowerlib import data as wt
You can use the logging package to get logging messages from the windpowerlib. Change the logging level if you want more or less messages.
[2]:
import logging
logging.getLogger().setLevel(logging.DEBUG)
Import weather data¶
In order to use the windpowerlib you need to at least provide wind speed data for the time frame you want to analyze. The function below imports example weather data from the weather.csv file provided along with the windpowerlib. The data includes wind speed at two different heights in m/s, air temperature in two different heights in K, surface roughness length in m and air pressure in Pa.
To find out which weather data in which units need to be provided to use the ModelChain or other functions of the windpowerlib see the individual function documentation.
[3]:
def get_weather_data(filename='weather.csv', **kwargs):
r"""
Imports weather data from a file.
The data include wind speed at two different heights in m/s, air
temperature in two different heights in K, surface roughness length in m
and air pressure in Pa. The height in m for which the data applies is
specified in the second row.
In case no weather data file exists, an example weather data file is
automatically downloaded and stored in the same directory as this example.
Parameters
----------
filename : str
Filename of the weather data file. Default: 'weather.csv'.
Other Parameters
----------------
datapath : str, optional
Path where the weather data file is stored.
Default is the same directory this example is stored in.
Returns
-------
:pandas:`pandas.DataFrame<frame>`
DataFrame with time series for wind speed `wind_speed` in m/s,
temperature `temperature` in K, roughness length `roughness_length`
in m, and pressure `pressure` in Pa.
The columns of the DataFrame are a MultiIndex where the first level
contains the variable name as string (e.g. 'wind_speed') and the
second level contains the height as integer at which it applies
(e.g. 10, if it was measured at a height of 10 m). The index is a
DateTimeIndex.
"""
if 'datapath' not in kwargs:
kwargs['datapath'] = os.path.dirname(__file__)
file = os.path.join(kwargs['datapath'], filename)
# download example weather data file in case it does not yet exist
if not os.path.isfile(file):
logging.debug("Download weather data for example.")
req = requests.get("https://osf.io/59bqn/download")
with open(file, "wb") as fout:
fout.write(req.content)
# read csv file
weather_df = pd.read_csv(
file,
index_col=0,
header=[0, 1],
date_parser=lambda idx: pd.to_datetime(idx, utc=True))
# change time zone
weather_df.index = weather_df.index.tz_convert(
'Europe/Berlin')
return weather_df
# Read weather data from csv
weather = get_weather_data(filename='weather.csv', datapath='')
print(weather[['wind_speed', 'temperature', 'pressure']][0:3])
variable_name wind_speed temperature pressure
height 10 80 2 10 0
2010-01-01 00:00:00+01:00 5.32697 7.80697 267.60 267.57 98405.7
2010-01-01 01:00:00+01:00 5.46199 7.86199 267.60 267.55 98382.7
2010-01-01 02:00:00+01:00 5.67899 8.59899 267.61 267.54 98362.9
Initialize wind turbine¶
There are three ways to initialize a WindTurbine object in the windpowerlib. You can either use turbine data from the OpenEnergy Database (oedb) turbine library that is provided along with the windpowerlib, as done for the ‘enercon_e126’, or specify your own turbine by directly providing a power (coefficient) curve, as done below for ‘my_turbine’, or provide your own turbine data in csv files, as done for ‘my_turbine2’.
You can execute the following to get a table of all wind turbines for which power and/or power coefficient curves are provided.
[4]:
# get power curves
# get names of wind turbines for which power curves and/or are provided
# set print_out=True to see the list of all available wind turbines
df = wt.get_turbine_types(print_out=False)
# find all Enercons
print(df[df["manufacturer"].str.contains("Enercon")])
manufacturer turbine_type has_power_curve has_cp_curve
1 Enercon E-101/3050 True True
2 Enercon E-101/3500 True True
3 Enercon E-115/3000 True True
4 Enercon E-115/3200 True True
5 Enercon E-126/4200 True True
6 Enercon E-126/7500 True False
7 Enercon E-126/7580 True False
8 Enercon E-141/4200 True True
9 Enercon E-53/800 True True
10 Enercon E-70/2000 True False
11 Enercon E-70/2300 True True
12 Enercon E-82/2000 True True
13 Enercon E-82/2300 True True
14 Enercon E-82/2350 True True
15 Enercon E-82/3000 True True
16 Enercon E-92/2350 True True
17 Enercon E48/800 True True
[5]:
# find all Enercon 101 turbines
print(df[df["turbine_type"].str.contains("E-101")])
manufacturer turbine_type has_power_curve has_cp_curve
1 Enercon E-101/3050 True True
2 Enercon E-101/3500 True True
[6]:
# specification of wind turbine where power curve is provided in the
# oedb turbine library
enercon_e126 = {
'turbine_type': 'E-126/4200', # turbine type as in oedb turbine library
'hub_height': 135 # in m
}
# initialize WindTurbine object
e126 = WindTurbine(**enercon_e126)
[7]:
# specification of own wind turbine (Note: power curve values and
# nominal power have to be in Watt)
my_turbine = {
'nominal_power': 3e6, # in W
'hub_height': 105, # in m
'power_curve': pd.DataFrame(
data={'value': [p * 1000 for p in [
0.0, 26.0, 180.0, 1500.0, 3000.0, 3000.0]], # in W
'wind_speed': [0.0, 3.0, 5.0, 10.0, 15.0, 25.0]}) # in m/s
}
# initialize WindTurbine object
my_turbine = WindTurbine(**my_turbine)
[8]:
# specification of wind turbine where power coefficient curve and nominal
# power is provided in an own csv file
# Read your turbine data from your data file using functions like
# pandas.read_csv().
# >>> import pandas as pd
# >>> my_data = pd.read_csv("path/to/my/data/file")
# >>> my_power = my_data["my_power"]
# >>> my_wind_speed = my_data["my_wind_speed"]
my_power = pd.Series(
[0.0, 39000.0, 270000.0, 2250000.0, 4500000.0, 4500000.0]
)
my_wind_speed = (0.0, 3.0, 5.0, 10.0, 15.0, 25.0)
my_turbine2 = {
"nominal_power": 6e6, # in W
"hub_height": 115, # in m
"power_curve": create_power_curve(
wind_speed=my_wind_speed, power=my_power
),
}
my_turbine2 = WindTurbine(**my_turbine2)
Use the ModelChain to calculate turbine power output¶
The ModelChain is a class that provides all necessary steps to calculate the power output of a wind turbine. When calling the ‘run_model’ method, first the wind speed and density (if necessary) at hub height are calculated and then used to calculate the power output. You can either use the default methods for the calculation steps, as done for ‘my_turbine’, or choose different methods, as done for the ‘e126’. Of course, you can also use the default methods while only changing one or two of them, as done for ‘my_turbine2’.
[9]:
# power output calculation for e126
# own specifications for ModelChain setup
modelchain_data = {
'wind_speed_model': 'logarithmic', # 'logarithmic' (default),
# 'hellman' or
# 'interpolation_extrapolation'
'density_model': 'ideal_gas', # 'barometric' (default), 'ideal_gas'
# or 'interpolation_extrapolation'
'temperature_model': 'linear_gradient', # 'linear_gradient' (def.) or
# 'interpolation_extrapolation'
'power_output_model':
'power_coefficient_curve', # 'power_curve' (default) or
# 'power_coefficient_curve'
'density_correction': True, # False (default) or True
'obstacle_height': 0, # default: 0
'hellman_exp': None} # None (default) or None
# initialize ModelChain with own specifications and use run_model method to
# calculate power output
mc_e126 = ModelChain(e126, **modelchain_data).run_model(
weather)
# write power output time series to WindTurbine object
e126.power_output = mc_e126.power_output
DEBUG:root:Calculating wind speed using logarithmic wind profile.
DEBUG:root:Calculating temperature using temperature gradient.
DEBUG:root:Calculating density using ideal gas equation.
DEBUG:root:Calculating power output using power coefficient curve.
[10]:
# power output calculation for my_turbine
# initialize ModelChain with default parameters and use run_model
# method to calculate power output
mc_my_turbine = ModelChain(my_turbine).run_model(weather)
# write power output time series to WindTurbine object
my_turbine.power_output = mc_my_turbine.power_output
DEBUG:root:Calculating wind speed using logarithmic wind profile.
DEBUG:root:Calculating power output using power curve.
[11]:
# power output calculation for example_turbine
# own specification for 'power_output_model'
mc_example_turbine = ModelChain(
my_turbine2,
wind_speed_model='hellman').run_model(weather)
my_turbine2.power_output = mc_example_turbine.power_output
DEBUG:root:Calculating wind speed using hellman equation.
DEBUG:root:Calculating power output using power curve.
Plot results¶
If you have matplotlib installed you can visualize the calculated power output and used power (coefficient) curves.
[12]:
# try to import matplotlib
logging.getLogger().setLevel(logging.WARNING)
try:
from matplotlib import pyplot as plt
# matplotlib inline needed in notebook to plot inline
%matplotlib inline
except ImportError:
plt = None
[13]:
# plot turbine power output
if plt:
e126.power_output.plot(legend=True, label='Enercon E126')
my_turbine.power_output.plot(legend=True, label='myTurbine')
my_turbine2.power_output.plot(legend=True, label='myTurbine2')
plt.xlabel('Time')
plt.ylabel('Power in W')
plt.show()

[14]:
# plot power (coefficient) curves
if plt:
if e126.power_coefficient_curve is not None:
e126.power_coefficient_curve.plot(
x='wind_speed', y='value', style='*',
title='Enercon E126 power coefficient curve')
plt.xlabel('Wind speed in m/s')
plt.ylabel('Power in W')
plt.show()
if e126.power_curve is not None:
e126.power_curve.plot(x='wind_speed', y='value', style='*',
title='Enercon E126 power curve')
plt.xlabel('Wind speed in m/s')
plt.ylabel('Power in W')
plt.show()
if my_turbine.power_coefficient_curve is not None:
my_turbine.power_coefficient_curve.plot(
x='wind_speed', y='value', style='*',
title='myTurbine power coefficient curve')
plt.xlabel('Wind speed in m/s')
plt.ylabel('Power in W')
plt.show()
if my_turbine.power_curve is not None:
my_turbine.power_curve.plot(x='wind_speed', y='value', style='*',
title='myTurbine power curve')
plt.xlabel('Wind speed in m/s')
plt.ylabel('Power in W')
plt.show()
if my_turbine2.power_coefficient_curve is not None:
my_turbine2.power_coefficient_curve.plot(
x='wind_speed', y='value', style='*',
title='myTurbine2 power coefficient curve')
plt.xlabel('Wind speed in m/s')
plt.ylabel('Power in W')
plt.show()
if my_turbine2.power_curve is not None:
my_turbine2.power_curve.plot(x='wind_speed', y='value', style='*',
title='myTurbine2 power curve')
plt.xlabel('Wind speed in m/s')
plt.ylabel('Power in W')
plt.show()




[ ]:
SPDX-FileCopyrightText: 2019 oemof developer group contact@oemof.org
SPDX-License-Identifier: MIT
SPDX-License-Identifier: CC-BY-4.0
TurbineClusterModelChain example¶
This example shows you how to calculate the power output of wind farms and wind turbine clusters using the windpowerlib. A cluster can be useful if you want to calculate the feed-in of a region for which you want to use one single weather data point.
Functions that are used in the ModelChain example, like the initialization of wind turbines, are imported and used without further explanation.
Imports and initialization of wind turbines¶
The import of weather data and the initialization of wind turbines is done as in the modelchain_example
. Be aware that currently for wind farm and wind cluster calculations wind turbines need to have a power curve as some calculations do not work with the power coefficient curve.
[1]:
import pandas as pd
import modelchain_example as mc_e
from windpowerlib import TurbineClusterModelChain, WindTurbineCluster, WindFarm
import logging
logging.getLogger().setLevel(logging.DEBUG)
[2]:
# Get weather data
weather = mc_e.get_weather_data('weather.csv')
print(weather[['wind_speed', 'temperature', 'pressure']][0:3])
# Initialize wind turbines
my_turbine, e126, my_turbine2 = mc_e.initialize_wind_turbines()
print()
print('nominal power of my_turbine: {}'.format(my_turbine.nominal_power))
variable_name wind_speed temperature pressure
height 10 80 2 10 0
2010-01-01 00:00:00+01:00 5.32697 7.80697 267.60 267.57 98405.7
2010-01-01 01:00:00+01:00 5.46199 7.86199 267.60 267.55 98382.7
2010-01-01 02:00:00+01:00 5.67899 8.59899 267.61 267.54 98362.9
nominal power of my_turbine: 3000000.0
Initialize wind farm¶
To initialize a specific wind farm you need to provide a wind turbine fleet specifying the wind turbines and their number or total installed capacity (in Watt) in the farm. Optionally, you can specify a wind farm efficiency and a name as an identifier.
[3]:
# specification of wind farm data where turbine fleet is provided in a
# pandas.DataFrame
# for each turbine type you can either specify the number of turbines of
# that type in the wind farm (float values are possible as well) or the
# total installed capacity of that turbine type in W
wind_turbine_fleet = pd.DataFrame(
{'wind_turbine': [my_turbine, e126], # as windpowerlib.WindTurbine
'number_of_turbines': [6, None],
'total_capacity': [None, 12.6e6]}
)
# initialize WindFarm object
example_farm = WindFarm(name='example_farm',
wind_turbine_fleet=wind_turbine_fleet)
Following, a wind farm with a constant efficiency is defined. A wind farm efficiency can also be dependent on the wind speed in which case it needs to be provided as a dataframe with ‘wind_speed’ and ‘efficiency’ columns containing wind speeds in m/s and the corresponding dimensionless wind farm efficiency.
[4]:
# specification of wind farm data (2) containing a wind farm efficiency
# wind turbine fleet is provided using the to_group function
example_farm_2_data = {
'name': 'example_farm_2',
'wind_turbine_fleet': [my_turbine.to_group(6),
e126.to_group(total_capacity=12.6e6)],
'efficiency': 0.9}
# initialize WindFarm object
example_farm_2 = WindFarm(**example_farm_2_data)
print('nominal power of first turbine type of example_farm_2: {}'.format(
example_farm_2.wind_turbine_fleet.loc[0, 'wind_turbine'].nominal_power))
nominal power of first turbine type of example_farm_2: 3000000.0
Initialize wind turbine cluster¶
Like for a wind farm for the initialization of a wind turbine cluster you can use a dictionary that contains the basic parameters. A wind turbine cluster is defined by its wind farms.
[5]:
# specification of cluster data
example_cluster_data = {
'name': 'example_cluster',
'wind_farms': [example_farm, example_farm_2]}
# initialize WindTurbineCluster object
example_cluster = WindTurbineCluster(**example_cluster_data)
Use the TurbineClusterModelChain to calculate power output¶
The TurbineClusterModelChain is a class that provides all necessary steps to calculate the power output of a wind farm or wind turbine cluster.
Like the ModelChain (see basic example) you can use the TurbineClusterModelChain with default parameters as shown in this example for the wind farm or specify custom parameters as done here for the cluster. If you use the ‘run_model’ method first the aggregated power curve and the mean hub height of the wind farm/cluster is calculated, then inherited functions of the ModelChain are used to calculate the wind speed and density (if necessary) at hub height. After that, depending on the parameters, wake losses are applied and at last the power output is calculated.
[6]:
# power output calculation for example_farm
# initialize TurbineClusterModelChain with default parameters and use
# run_model method to calculate power output
mc_example_farm = TurbineClusterModelChain(example_farm).run_model(weather)
# write power output time series to WindFarm object
example_farm.power_output = mc_example_farm.power_output
DEBUG:root:Wake losses considered by dena_mean wind efficiency curve.
DEBUG:root:Aggregated power curve not smoothed.
DEBUG:root:Calculating wind speed using logarithmic wind profile.
DEBUG:root:Calculating power output using power curve.
[7]:
# set efficiency of example_farm to apply wake losses
example_farm.efficiency = 0.9
# power output calculation for turbine_cluster
# own specifications for TurbineClusterModelChain setup
modelchain_data = {
'wake_losses_model': 'wind_farm_efficiency', #
# 'dena_mean' (default), None,
# 'wind_farm_efficiency' or name
# of another wind efficiency curve
# see :py:func:`~.wake_losses.get_wind_efficiency_curve`
'smoothing': True, # False (default) or True
'block_width': 0.5, # default: 0.5
'standard_deviation_method': 'Staffell_Pfenninger', #
# 'turbulence_intensity' (default)
# or 'Staffell_Pfenninger'
'smoothing_order': 'wind_farm_power_curves', #
# 'wind_farm_power_curves' (default) or
# 'turbine_power_curves'
'wind_speed_model': 'logarithmic', # 'logarithmic' (default),
# 'hellman' or
# 'interpolation_extrapolation'
'density_model': 'ideal_gas', # 'barometric' (default), 'ideal_gas' or
# 'interpolation_extrapolation'
'temperature_model': 'linear_gradient', # 'linear_gradient' (def.) or
# 'interpolation_extrapolation'
'power_output_model': 'power_curve', # 'power_curve' (default) or
# 'power_coefficient_curve'
'density_correction': True, # False (default) or True
'obstacle_height': 0, # default: 0
'hellman_exp': None} # None (default) or None
# initialize TurbineClusterModelChain with own specifications and use
# run_model method to calculate power output
mc_example_cluster = TurbineClusterModelChain(
example_cluster, **modelchain_data).run_model(weather)
# write power output time series to WindTurbineCluster object
example_cluster.power_output = mc_example_cluster.power_output
DEBUG:root:Wake losses considered with wind_farm_efficiency.
DEBUG:root:Aggregated power curve smoothed by method: Staffell_Pfenninger
DEBUG:root:Calculating wind speed using logarithmic wind profile.
DEBUG:root:Calculating temperature using temperature gradient.
DEBUG:root:Calculating density using ideal gas equation.
DEBUG:root:Calculating power output using power curve.
Plot results¶
If you have matplotlib installed you can visualize the calculated power output.
[8]:
# try to import matplotlib
logging.getLogger().setLevel(logging.WARNING)
try:
from matplotlib import pyplot as plt
# matplotlib inline needed in notebook to plot inline
%matplotlib inline
except ImportError:
plt = None
[9]:
# plot turbine power output
if plt:
example_cluster.power_output.plot(legend=True, label='example cluster')
example_farm.power_output.plot(legend=True, label='example farm')
plt.xlabel('Wind speed in m/s')
plt.ylabel('Power in W')
plt.show()

[10]:
# plot aggregated (and smoothed) power curve of example_cluster
if plt:
example_cluster.power_curve.plot(
x='wind_speed', y='value', style='*')
plt.xlabel('Wind speed in m/s')
plt.ylabel('Power in W')
plt.show()

[ ]:
Model description¶
Wind power plants¶
The windpowerlib provides three classes for modelling wind power as wind turbines (WindTurbine
),
wind farms (WindFarm
) and wind turbine clusters (WindTurbineCluster
).
Descriptions can also be found in the sections Wind turbine data, Wind farm calculations and Wind turbine cluster calculations.
Height correction and conversion of weather data¶
Weather data is usually available for a restricted amount of heights above ground. However, for wind feed-in time series calculations weather data is needed at hub height of the examined wind turbines. Thus, the windpowerlib provides functions for the height correction of weather data.
Functions for the height correction of wind speed to the hub height of a wind turbine are described in the Wind speed module. Respectively a function for the height correction of temperature data is provided in the Temperature module. Functions for density calculations can be found in the Density module.
If weather data is available for at least two different heights the respective figure at hub height can be determined by using linear or logarithmic inter-/extrapolation functions of the Tools module.
Power output calculations¶
Wind feed-in time series can be calculated via power curves and power coefficient curves in the windpowerlib. Functions for power output calculations are described in the Power output module.
Wake losses¶
The windpowerlib provides two options for the consideration of wake losses in wind farms: reduction of wind speeds and wind farm efficiency (reduction of power in power curves).
For the first option wind efficiency curves are provided which determine the
average reduction of wind speeds within a wind farm induced by wake losses depending on the wind speed. These curves
were taken from the dena-Netzstudie II and the dissertation of Kaspar Knorr
(for references see get_wind_efficiency_curve()
).
The following graph shows all provided wind efficiency curves. The mean wind efficiency curves were calculated in
the dena-Netzstudie II and by Kaspar Knorr by averaging wind efficiency curves of 12 wind farms distributed over Germany (dena) or
respectively of over 2000 wind farms in Germany (Knorr). Curves with the appendix ‘extreme’
are wind efficiency curves of single wind farms that are extremely deviating from the respective
mean wind efficiency curve.
The second option to consider wake losses is to apply them to power curves by reducing the power values
by a constant or on a wind speed depending wind farm efficiency (see wake_losses_to_power_curve()
).
Applying the wind farm efficiency (curve) to power curves instead of feed-in time series has the advantage that the
power curves can further be aggregated to obtain turbine cluster power curves (see WindTurbineCluster
).
Smoothing of power curves¶
To account for the spatial distribution of wind speeds within an area the windpowerlib provides a
function for power curve smoothing and uses the approach of Nørgaard and Holttinen (for references see smooth_power_curve()
).
The modelchains¶
The modelchains are implemented to ensure an easy start into the Windpowerlib. They work like models that combine all functions provided in the library. Via parameteres desired functions of the windpowerlib can be selected. For parameters not being specified default parameters are used. The ModelChain is a model to determine the output of a wind turbine while the TurbineClusterModelChain is a model to determine the output of a wind farm or wind turbine cluster. The usage of both modelchains is shown in the Examples section.
What’s New¶
These are new features and improvements of note in each release
Releases
v0.2.1 (March 9, 2021)¶
Other changes¶
- A WindpowerlibUserWarning is raised if the weather data contain nan/null values. If you are aware of the nan-values you can filter the warning. (PR 96)
- Raise an error if diameter of rotor is greater than the hub height.
- Raise an error if “farm efficiency” method is chosen but no farm efficiency is set.
- Data height in weather data DataFrame can be of type string and will be converted to numeric internally. This makes is easier to read a csv-file with a header using pandas read_csv function.
- Code-style is now “black”.
- Licence changed from GPLv3 to MIT.
- A new function check_turbine_data(filename) is added to check the turbine data. If new data is downloaded from the oedb the data will be checked and removed if an error occurs. Furthermore, it is always possible to restore the original turbine data using the function restore_default_turbine_data(). (PR 101)
- Speed Improvement in “power_curve_density_correction” (PR 107 and PR 114 )
Contributors¶
- Birgit Schachler
- Kumar Shivam
- kyri-petrou
- Sabine Haas
- Uwe Krien
- Velibor Zeli
v0.2.0 (September 9, 2019)¶
API changes¶
- The
WindTurbine
API has been revised. Main changes are that the parameters fetch_curve and data_source have been removed. These parameters were formerly used to specify whether the power or power coefficient curve should be retrieved and the source to retrieve them from. Now per default the power curve and/or power coefficient curve are tried to be retrieved from the oedb turbine library that is provided along with the windpowerlib and holds turbine data for a large set of wind turbines. Further important changes are the renaming of the parameter name to turbine_type and the removal of the coordinates. See theWindTurbine
docstring and Initialize wind turbine in the Examples section for more information. (PR 62) - The
WindFarm
API has been revised. The wind_turbine_fleet parameter can now be provided as a pandas DataFrame (PR 63) or as a list using theto_group()
method (PR 68. Furthermore, the option to specify the wind turbine fleet using the total installed capacity of each turbine type has been added. See theWindFarm
docstring and Initialize wind farm in the Examples section for more information. - get_installed_power() methods in
WindFarm
andWindTurbineCluster
were removed. Installed power is instead now directly calculated inside the nominal_power getter. - Removed unnecessary wake_losses_model parameter in
wake_losses_to_power_curve()
. Whether a constant wind farm efficiency or a wind farm efficiency curve is used is decided by the type of the wind farm efficiency. - Combined options ‘constant_efficiency’ and ‘power_efficiency_curve’ of wake_losses_model parameter in
TurbineClusterModelChain()
to ‘wind_farm_efficiency’. Therefore, default value of wake_losses_model inassign_power_curve()
andassign_power_curve()
changed to ‘wind_farm_efficiency’. - Removed overwrite parameter from
get_turbine_data_from_oedb()
Other changes¶
- Power curves and nominal power of wind turbines are now saved in file in W instead of kW to be consistent with internal units.
- Restructured csv reading for offline usage of windpowerlib. The nominal power of wind turbines is now saved to a separate file along with other turbine data from the oedb turbine library.
- get_turbine_types() can now be used to get provided turbine types of oedb turbine library as well as provided turbine types of local files.
Documentation¶
- Improved documentation of
ModelChain
andTurbineClusterModelChain
parameters (PR 64). - Added info in README and getting started section on how to contribute to the oedb wind turbine library.
Contributors¶
- Birgit Schachler
- Sabine Haas
- Uwe Krien
v0.1.3 (September 2, 2019)¶
Contributors¶
- Birgit Schachler
- Uwe Krien
v0.1.2 (June 24, 2019)¶
New features¶
- new attribute nominal_power in
WindFarm
andWindTurbineCluster
classes (PR #53) - use properties and setters for nominal_power and installed_power in
WindFarm
andWindTurbineCluster
classes - made windpowerlib work offline: added csv files containing turbine data from OpenEnergy Database (oedb) to the repository for offline usage (PR #52)
Bug fixes¶
- fixed issue with pandas Multiindex labels and codes attributes (PR #51)
Other changes¶
- made
get_turbine_types()
also accessible via get_turbine_types() –> from windpowerlib import get_turbine_types - added kwargs in init of
WindTurbine
,WindFarm
andWindTurbineCluster
- we are working with deprecation warnings to draw our user’s attention to important changes (PR #53)
Deprecations¶
wind_farm and wind_turbine_cluster:
- Parameter coordinates is deprecated. In the future the parameter can only be set after instantiation of WindFarm object.
- installed_power is deprecated, use nominal_power instead
wind_turbine:
- Parameters name, data_source and fetch_curve are deprecated. The parameter name will be renamed to turbine_type. Data source and fetching will be defined by the parameters power_coefficient_curve, power_curve and nominal_power in the future.
- Parameter coordinates is deprecated. In the future the parameter can only be set after instantiation of WindTurbine object.
power_curves:
- wake_losses_model is deprecated, will be defined by the type of wind_farm_efficiency
Contributors¶
- Sabine Haas
- Birgit Schachler
- Uwe Krien
v0.1.1 (January 31, 2019)¶
Other changes¶
- Adapted csv reading to pandas API change
- Removed logging message for successful database connection
- Added system exit and error message in case a non-existing power (coefficient) curve of an existing turbine type is tried to be used
Contributors¶
- Uwe Krien
- Sabine Haas
v0.1.0 (January 17, 2019)¶
ATTENTION: From v0.1.0 on power (coefficient) curves are provided by the OpenEnergy Database (oedb)
instead of in csv files (v0.6.0 and lower) due to legal reasons.
Use get_turbine_types()
to check whether the turbine types you need are included in the database.
If your turbine type is not included you can either use your own csv file or open an issue.
New classes¶
WindFarm
class for modelling a wind farm. Defines a standard set of wind farm attributes, for example aggregated power curve and wind farm efficiency to take wake losses into account.WindTurbineCluster
class for modelling a turbine cluster that contains several wind turbines and/or wind farms. This class is useful for gathering all wind turbines in a weather data grid cell. An aggregated power curve can be calculated which considers the wake losses of the wind farms by a set efficiency if desired.TurbineClusterModelChain
class shows the usage of new functions and classes of windpowerlib v.0.1 and is based on the ModelChain class.
New functions¶
smooth_power_curve()
for taking into account the spatial distribution of wind speedwake_losses_to_power_curve()
: application of wake losses to a power curvereduce_wind_speed()
: application of wake losses to a wind speed time series by using wind efficiency curves which are provided in the data directorylogarithmic_interpolation_extrapolation()
for wind speed time seriesgauss_distribution()
needed for power curve smoothingestimate_turbulence_intensity()
by roughness lengthget_turbine_data_from_oedb()
for retrieving power curves from OpenEnergy Database
Testing¶
- added continuous integration to automatically test the windpowerlib for different python versions and to check the test coverage
Documentation¶
- added second example section and jupyter notebook
- added model description
API changes¶
- renamed attribute turbine_name of WindTurbine class to name to match with name attribute of WindFarm and WindTurbineCluster class
- renamed basic_example to modelchain_example
- renamed column ‘values’ of power (coefficient) curves to ‘value’ to prevent errors using df.value(s)
- renamed run_basic_example() to run_example() in modelchain_example
- renamed parameter wind_turbine of ModelChain object to power_plant
- removed parameter density_correction from power_plant.power_coefficient()
Other changes¶
- removed deprecated attributes (.ix)
- added turbine_cluster_modelchain_example showing the usage of the TurbineClusterModelChain
Contributors¶
- Sabine Haas
- Uwe Krien
- Birgit Schachler
v0.0.6 (July 07, 2017)¶
Documentation¶
- added basic usage section and jupyter notebook
Testing¶
- added tests for different data types and wind_turbine module
- added example to tests
- added and fixed doctests
Other changes¶
- various API changes due to having better comprehensible function and variable names
- renamed Modelchain to ModelChain
- moved functions for temperature calculation to temperature module
- new function for interpolation and extrapolation
Contributors¶
- Sabine Haas
- Birgit Schachler
- Uwe Krien
v0.0.5 (April 10, 2017)¶
New features¶
- complete restructuring of the windpowerlib
- power curves for numerous wind turbines are provided
- new function for calculation of air density at hub height (rho_ideal_gas)
- new function for calculation of wind speed at hub height (v_wind_hellman)
- density correction for calculation of power output
- modelchain for convenient usage
Documentation¶
- added references
Testing¶
- tests for all modules were added
Contributors¶
- Sabine Haas
- Birgit Schachler
- Uwe Krien
API¶
Classes¶
wind_turbine.WindTurbine (hub_height[, …]) |
Defines a standard set of wind turbine attributes. |
wind_farm.WindFarm (wind_turbine_fleet[, …]) |
Defines a standard set of wind farm attributes. |
wind_turbine_cluster.WindTurbineCluster (…) |
Defines a standard set of wind turbine cluster attributes. |
modelchain.ModelChain (power_plant[, …]) |
Model to determine the output of a wind turbine |
turbine_cluster_modelchain.TurbineClusterModelChain (…) |
Model to determine the output of a wind farm or wind turbine cluster. |
Temperature¶
Function for calculating air temperature at hub height.
temperature.linear_gradient (temperature, …) |
Calculates the temperature at hub height using a linear gradient. |
Density¶
Functions for calculating air density at hub height.
density.barometric (pressure, …) |
Calculates the density of air at hub height using the barometric height equation. |
density.ideal_gas (pressure, pressure_height, …) |
Calculates the density of air at hub height using the ideal gas equation. |
Wind speed¶
Functions for calculating wind speed at hub height.
wind_speed.logarithmic_profile (wind_speed, …) |
Calculates the wind speed at hub height using a logarithmic wind profile. |
wind_speed.hellman (wind_speed, …[, …]) |
Calculates the wind speed at hub height using the hellman equation. |
Wind turbine data¶
Functions and methods to obtain the nominal power as well as
power curve or power coefficient curve needed by the WindTurbine
class.
wind_turbine.get_turbine_data_from_file (…) |
Fetches turbine data from a csv file. |
data.store_turbine_data_from_oedb ([schema, …]) |
Loads turbine library from the OpenEnergy database (oedb). |
data.get_turbine_types ([turbine_library, …]) |
Get all provided wind turbine types provided. |
Data Container¶
Create data container to be used as an input in classes und functions.
wind_turbine.WindTurbineGroup |
A simple data container to define more than one turbine of the same type. |
wind_turbine.WindTurbine.to_group ([…]) |
Creates a WindTurbineGroup , a NamedTuple data container with the fields ‘number_of_turbines’ and ‘wind_turbine’. |
Wind farm calculations¶
Functions and methods to calculate the mean hub height, installed power as well
as the aggregated power curve of a WindFarm
object.
wind_farm.WindFarm.check_and_complete_wind_turbine_fleet () |
Function to check wind turbine fleet user input. |
wind_farm.WindFarm.nominal_power |
The nominal power is the sum of the nominal power of all turbines. |
wind_farm.WindFarm.mean_hub_height () |
Calculates the mean hub height of the wind farm. |
wind_farm.WindFarm.assign_power_curve ([…]) |
Calculates the power curve of a wind farm. |
Wind turbine cluster calculations¶
Functions and methods to calculate the mean hub height, nominal power as well
as the aggregated power curve of a WindTurbineCluster
object.
This is realized in a new module as the functions differ from the functions in
the WindFarm
class.
wind_turbine_cluster.WindTurbineCluster.nominal_power |
The nominal power is the sum of the nominal power of all turbines in the wind turbine cluster. |
wind_turbine_cluster.WindTurbineCluster.mean_hub_height () |
Calculates the mean hub height of the wind turbine cluster. |
wind_turbine_cluster.WindTurbineCluster.assign_power_curve ([…]) |
Calculates the power curve of a wind turbine cluster. |
Power output¶
Functions for calculating power output of a wind power plant.
power_output.power_coefficient_curve (…) |
Calculates the turbine power output using a power coefficient curve. |
power_output.power_curve (wind_speed, …[, …]) |
Calculates the turbine power output using a power curve. |
power_output.power_curve_density_correction (…) |
Calculates the turbine power output using a density corrected power curve. |
Alteration of power curves¶
Functions for smoothing power curves or applying wake losses to a power curve.
power_curves.smooth_power_curve (…[, …]) |
Smoothes a power curve by using a Gauss distribution. |
power_curves.wake_losses_to_power_curve (…) |
Reduces the power values of a power curve by an efficiency (curve). |
power_curves.create_power_curve (wind_speed, …) |
A list, numpy.array, pandas.Series or other iterables can be passed to define the wind speed and the power output. |
Wake losses¶
Functions for applying wake losses to a wind speed time series.
wake_losses.reduce_wind_speed (wind_speed[, …]) |
Reduces wind speed by a wind efficiency curve. |
wake_losses.get_wind_efficiency_curve ([…]) |
Reads wind efficiency curve(s) specified in curve_name. |
ModelChain¶
Creating a ModelChain object.
modelchain.ModelChain (power_plant[, …]) |
Model to determine the output of a wind turbine |
Running the ModelChain.
modelchain.ModelChain.run_model (weather_df) |
Runs the model. |
Methods of the ModelChain object.
modelchain.ModelChain.temperature_hub (weather_df) |
Calculates the temperature of air at hub height. |
modelchain.ModelChain.density_hub (weather_df) |
Calculates the density of air at hub height. |
modelchain.ModelChain.wind_speed_hub (weather_df) |
Calculates the wind speed at hub height. |
modelchain.ModelChain.calculate_power_output (…) |
Calculates the power output of the wind power plant. |
TurbineClusterModelChain¶
The TurbineClusterModelChain inherits all functions from the ModelChain.
Creating a TurbineClusterModelChain object.
turbine_cluster_modelchain.TurbineClusterModelChain (…) |
Model to determine the output of a wind farm or wind turbine cluster. |
Running the TurbineClusterModelChain.
turbine_cluster_modelchain.TurbineClusterModelChain.run_model (…) |
Runs the model. |
Methods of the TurbineClusterModelChain object.
turbine_cluster_modelchain.TurbineClusterModelChain.assign_power_curve (…) |
Calculates the power curve of the wind turbine cluster. |
turbine_cluster_modelchain.TurbineClusterModelChain.temperature_hub (…) |
Calculates the temperature of air at hub height. |
turbine_cluster_modelchain.TurbineClusterModelChain.density_hub (…) |
Calculates the density of air at hub height. |
turbine_cluster_modelchain.TurbineClusterModelChain.wind_speed_hub (…) |
Calculates the wind speed at hub height. |
turbine_cluster_modelchain.TurbineClusterModelChain.calculate_power_output (…) |
Calculates the power output of the wind power plant. |
Tools¶
Additional functions used in the windpowerlib.
tools.linear_interpolation_extrapolation (df, …) |
Linearly inter- or extrapolates between the values of a data frame. |
tools.logarithmic_interpolation_extrapolation (df, …) |
Logarithmic inter- or extrapolation between the values of a data frame. |
tools.gauss_distribution (function_variable, …) |
Gauss distribution. |
tools.estimate_turbulence_intensity (height, …) |
Estimate turbulence intensity by the roughness length. |
ModelChain example¶
The modelchain_example
consists of the following functions.
modelchain_example.get_weather_data ([filename]) |
Imports weather data from a file. |
modelchain_example.initialize_wind_turbines () |
Initializes three WindTurbine objects. |
modelchain_example.calculate_power_output (…) |
Calculates power output of wind turbines using the ModelChain . |
modelchain_example.plot_or_print (my_turbine, …) |
Plots or prints power output and power (coefficient) curves. |
modelchain_example.run_example () |
Runs the basic example. |
TurbineClusterModelChain example¶
The turbine_cluster_modelchain_example
consists of the following functions
as well as it uses functions of the modelchain_example
.
turbine_cluster_modelchain_example.initialize_wind_farms (…) |
Initializes two WindFarm objects. |
turbine_cluster_modelchain_example.initialize_wind_turbine_cluster (…) |
Initializes a WindTurbineCluster object. |
turbine_cluster_modelchain_example.calculate_power_output (…) |
Calculates power output of wind farms and clusters using the TurbineClusterModelChain . |
turbine_cluster_modelchain_example.plot_or_print (…) |
Plots or prints power output and power (coefficient) curves. |
turbine_cluster_modelchain_example.run_example () |
Runs the example. |