Skip to content

Commit

Permalink
Merge 0839793 into 0aeee7b
Browse files Browse the repository at this point in the history
  • Loading branch information
birgits committed Jul 18, 2019
2 parents 0aeee7b + 0839793 commit b6c48fa
Show file tree
Hide file tree
Showing 30 changed files with 1,182 additions and 891 deletions.
5 changes: 0 additions & 5 deletions .gitignore
Expand Up @@ -98,8 +98,3 @@ ENV/

# tests
.pytest_cache

# oedb data dump
/windpowerlib/data/turbine_data_oedb.h5
/windpowerlib/data/oedb_power_coefficient_curves.csv
/windpowerlib/data/oedb_power_curves.csv
23 changes: 15 additions & 8 deletions doc/getting_started.rst
Expand Up @@ -32,31 +32,38 @@ If you have a working Python 3 environment, use pypi to install the latest windp
The windpowerlib is designed for Python 3 and tested on Python >= 3.5.
Please see the `installation page <http://oemof.readthedocs.io/en/stable/installation_and_setup.html>`_ of the oemof documentation for complete instructions on how to install python and a virtual environment on your operating system.

For retrieving power (coefficient) curves from the OpenEnergy Database (oedb) the python package requests will be installed with your windpowerlib installation. The windpowerlib was tested with requests version 2.20.1 but might work with lower versions.

Optional Packages
~~~~~~~~~~~~~~~~~

To see the plots of the windpowerlib example in the :ref:`examplereference-label` section you should `install the matplotlib package <http://matplotlib.org/users/installing.html>`_.
Matplotlib can be installed using pip3 though some Linux users reported that it is easier and more stable to use the pre-built packages of your Linux distribution.
Matplotlib can be installed using pip3:

::

pip install matplotlib

.. _examplereference-label:

Examples and basic usage
=========================

The basic usage of the windpowerlib is shown in the ModelChain example. The presented example is available as jupyter notebook and python script. You can download them along with example weather data:
The basic usage of the windpowerlib is shown in the ModelChain example that is available as jupyter notebook and python script:

* :download:`ModelChain example (Python script) <../example/modelchain_example.py>`
* :download:`ModelChain example (Jupyter notebook) <../example/modelchain_example.ipynb>`
* :download:`Example data file <../example/weather.csv>`

To run the examples you first have to install the windpowerlib. To run the notebook you also need to install notebook using pip3. To launch jupyter notebook type ``jupyter notebook`` in terminal.
To run the example you need the example weather and turbine data used:

* :download:`Example weather data file <../example/weather.csv>`
* :download:`Example power curve data file <../example/data/example_power_curves.csv>`
* :download:`Example power coefficient curve data file <../example/data/example_power_coefficient_curves.csv>`
* :download:`Example nominal power data file <../example/data/example_turbine_data.csv>`

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 <http://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/install.html>`_ and
`how to run <http://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/execute.html>`_ 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 data in this example is the same as in the example above.
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.

* :download:`TurbineClusterModelChain example (Python script) <../example/turbine_cluster_modelchain_example.py>`
* :download:`TurbineClusterModelChain example (Jupyter notebook) <../example/turbine_cluster_modelchain_example.ipynb>`
Expand Down Expand Up @@ -107,7 +114,7 @@ We use the zenodo project to get a DOI for each version. `Search zenodo for the
License
============

Copyright (C) 2017 oemof developing group
Copyright (C) 2017 oemof developer group

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
3 changes: 1 addition & 2 deletions doc/modules.rst
Expand Up @@ -67,9 +67,8 @@ power curve or power coefficient curve needed by the :py:class:`~.wind_turbine.W
.. autosummary::
:toctree: temp/

wind_turbine.WindTurbine.fetch_turbine_data
wind_turbine.get_turbine_data_from_file
wind_turbine.get_turbine_data_from_oedb
wind_turbine.get_oedb_turbine_data
wind_turbine.load_turbine_data_from_oedb
wind_turbine.get_turbine_types

Expand Down
23 changes: 19 additions & 4 deletions doc/whatsnew/v0-2-0.txt
Expand Up @@ -3,22 +3,37 @@ v0.2.0 ()

New features
############
* 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
#############


Testing
#######


Bug fixes
#########


API changes
###########
#############
* Removed unnecessary `wake_losses_model` parameter in :py:func:`~.power_curves.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 :py:func:`~.turbine_cluster_modelchain.TurbineClusterModelChain` to 'wind_farm_efficiency'. Therefore, default value of `wake_losses_model` in :py:func:`~.wind_farm.WindFarm.assign_power_curve` and :py:func:`~.wind_turbine_cluster.WindTurbineCluster.assign_power_curve` changed to 'wind_farm_efficiency'.
* Removed `overwrite` parameter from :py:func:`~.wind_turbine.get_turbine_data_from_oedb`
* Removed `data_source` and `fetch_curve` parameters from :py:func:`~.wind_turbine.WindTurbine` and :py:func:`~.wind_turbine.WindTurbine.fetch_turbine_data`. Now the source and if a curve is fetched or not is specified by the parameters `power_curve`, `power_coefficient_curve` and `nominal_power`. See :py:func:`~.wind_turbine.WindTurbine.fetch_turbine_data` for a description.

Other changes
#############
* Power curves and nominal power of wind turbines are now saved in file in W instead of kW.
* 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.

Testing
#######

Deprecations
############


Contributors
############
* Sabine Haas

6 changes: 3 additions & 3 deletions example/data/example_power_coefficient_curves.csv
@@ -1,3 +1,3 @@
,turbine_id,p_nom,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12,12.5,13,13.5,14,14.5,15,15.5,16,16.5,17,17.5,18,18.5,19,19.5,20,20.5,21,21.5,22,22.5,23,23.5,24,24.5,25,25.5,26
0,DUMMY 1,300000,0,,0,,0,,0,0,0.13,,0.38,,0.46,,0.48,,0.47,,0.44,,0.4,,0.36,,0.31,,0.26,,0.23,,0.2,,0.18,,0.14,,0.11,,0.1,,0.09,,0.07,,0.05,,0.04,,0.04,,0.03,,0
1,DUMMY 2,600000,0,,0,,0,,0.16,0.29,0.35,0.38,0.4,0.41,0.42,0.43,0.43,0.44,0.44,0.44,0.44,0.43,0.42,0.39,0.36,0.32,0.29,0.26,0.23,0.2,0.18,0.16,0.15,0.14,0.12,0.11,0.1,0.09,0.09,0.08,0.07,0.07,0.06,0.06,0.05,0.05,0.05,0.04,0.04,0.04,0.04,0.03,0.03,0,0
turbine_type,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12,12.5,13,13.5,14,14.5,15,15.5,16,16.5,17,17.5,18,18.5,19,19.5,20,20.5,21,21.5,22,22.5,23,23.5,24,24.5,25,25.5,26
DUMMY 1,0,,0,,0,,0,0,0.13,,0.38,,0.46,,0.48,,0.47,,0.44,,0.4,,0.36,,0.31,,0.26,,0.23,,0.2,,0.18,,0.14,,0.11,,0.1,,0.09,,0.07,,0.05,,0.04,,0.04,,0.03,,0
DUMMY 2,0,,0,,0,,0.16,0.29,0.35,0.38,0.4,0.41,0.42,0.43,0.43,0.44,0.44,0.44,0.44,0.43,0.42,0.39,0.36,0.32,0.29,0.26,0.23,0.2,0.18,0.16,0.15,0.14,0.12,0.11,0.1,0.09,0.09,0.08,0.07,0.07,0.06,0.06,0.05,0.05,0.05,0.04,0.04,0.04,0.04,0.03,0.03,0,0
6 changes: 3 additions & 3 deletions example/data/example_power_curves.csv
@@ -1,3 +1,3 @@
,turbine_id,p_nom,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12,12.5,13,13.5,14,14.5,15,15.5,16,16.5,17,17.5,18,18.5,19,19.5,20,20.5,21,21.5,22,22.5,23,23.5,24,24.5,25,25.5,26
0,DUMMY 3,150000,0,0,0,0,0,0,0,18000,34000,70000,10000,150000,190000,260000,330000,420000,510000,620000,740000,880000,1020000,1180000,1330000,1420000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,0,
4,DUMMY 4,225000,0,,0,,0,,0,,4000,,22000,,46000,,76000,,111000,,147000,,184000,,219000,,249000,,274000,,290000,,297000,,302000,,307000,,307000,,305000,,295000,,280000,,260000,,240000,,230000,,225000,0,
turbine_type,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12,12.5,13,13.5,14,14.5,15,15.5,16,16.5,17,17.5,18,18.5,19,19.5,20,20.5,21,21.5,22,22.5,23,23.5,24,24.5,25,25.5,26
DUMMY 3,0,0,0,0,0,0,0,18000,34000,70000,10000,150000,190000,260000,330000,420000,510000,620000,740000,880000,1020000,1180000,1330000,1420000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,1500000,0,
DUMMY 4,0,,0,,0,,0,,4000,,22000,,46000,,76000,,111000,,147000,,184000,,219000,,249000,,274000,,290000,,297000,,302000,,307000,,307000,,305000,,295000,,280000,,260000,,240000,,230000,,225000,0,
5 changes: 5 additions & 0 deletions example/data/example_turbine_data.csv
@@ -0,0 +1,5 @@
turbine_type,nominal_power
DUMMY 1,4200000
DUMMY 2,4200000
DUMMY 3,150000
DUMMY 4,225000
125 changes: 80 additions & 45 deletions example/modelchain_example.ipynb

Large diffs are not rendered by default.

117 changes: 69 additions & 48 deletions example/modelchain_example.py
Expand Up @@ -2,7 +2,7 @@
The ``modelchain_example`` module shows a simple usage of the windpowerlib by
using the :class:`~.modelchain.ModelChain` class. 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
models that combine all functions provided in the library. Via parameters
desired functions of the windpowerlib can be selected. For parameters not being
specified default parameters are used.
Expand Down Expand Up @@ -45,18 +45,18 @@ def get_weather_data(filename='weather.csv', **kwargs):
Parameters
----------
filename : string
filename : str
Filename of the weather data file. Default: 'weather.csv'.
Other Parameters
----------------
datapath : string, optional
datapath : str, optional
Path where the weather data file is stored.
Default: 'windpowerlib/example'.
Returns
-------
weather_df : pandas.DataFrame
: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.
Expand All @@ -71,46 +71,52 @@ def get_weather_data(filename='weather.csv', **kwargs):
kwargs['datapath'] = os.path.join(os.path.split(
os.path.dirname(__file__))[0], 'example')
file = os.path.join(kwargs['datapath'], filename)

# 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 type of index to datetime and set time zone
weather_df.index = pd.to_datetime(weather_df.index).tz_convert(
'Europe/Berlin')

# change type of height from str to int by resetting columns
l0 = [_[0] for _ in weather_df.columns]
l1 = [int(_[1]) for _ in weather_df.columns]
weather_df.columns = [l0, l1]

return weather_df


def initialize_wind_turbines():
r"""
Initializes two :class:`~.wind_turbine.WindTurbine` objects.
Function shows three ways to initialize a WindTurbine object. You can
either specify your own turbine, as done below for 'my_turbine', or fetch
power and/or power coefficient curve data from the OpenEnergy Database
(oedb), as done for the 'enercon_e126', or provide your turbine data in csv
files as done for 'dummy_turbine' with an example file.
Execute ``windpowerlib.wind_turbine.get_turbine_types()`` to get a table
Initializes three :class:`~.wind_turbine.WindTurbine` objects.
This function shows three ways to initialize a WindTurbine object. You can
either 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 'dummy_turbine', or you can use power and/or power
coefficient curve data from the OpenEnergy Database
(oedb) turbine library that is provided along with the windpowerlib,
as done for the 'enercon_e126'. Execute
``windpowerlib.wind_turbine.get_turbine_types()`` to get a table
including all wind turbines for which power and/or power coefficient curves
are provided.
Returns
-------
Tuple (WindTurbine, WindTurbine, WindTurbine)
Tuple (:class:`~.wind_turbine.WindTurbine`,
:class:`~.wind_turbine.WindTurbine`,
:class:`~.wind_turbine.WindTurbine`)
"""

# specification of own wind turbine (Note: power values and nominal power
# have to be in Watt)
my_turbine = {
'name': 'myTurbine',
'nominal_power': 3e6, # in W
'hub_height': 105, # in m
'rotor_diameter': 90, # 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
Expand All @@ -119,33 +125,39 @@ def initialize_wind_turbines():
# initialize WindTurbine object
my_turbine = WindTurbine(**my_turbine)

# specification of wind turbine where power coefficient curve and nominal
# power is provided in an own csv file
csv_path = os.path.join(os.path.dirname(__file__), 'data')
dummy_turbine = {
'turbine_type': "DUMMY 1",
'hub_height': 100, # in m
'rotor_diameter': 70, # in m
'power_coefficient_curve':
'example_power_coefficient_curves.csv', # data is fetched from
# file
'nominal_power': 'example_turbine_data.csv', # data is fetched from
# file
'path': csv_path
}
# initialize WindTurbine object
dummy_turbine = WindTurbine(**dummy_turbine)

# specification of wind turbine where power curve is provided in the oedb
# turbine library
# if you want to use the power coefficient curve change the value of
# 'fetch_curve' to 'power_coefficient_curve'
# 'power_coefficient_curve' to True.
enercon_e126 = {
'name': 'E-126/4200', # turbine type as in register #
'turbine_type': 'E-126/4200', # turbine type as in register
'hub_height': 135, # in m
'rotor_diameter': 127, # in m
'fetch_curve': 'power_curve', # fetch power curve #
'data_source': 'oedb' # data source oedb or name of csv file
'power_coefficient_curve':
False, # curve data is not fetched (default)
'power_curve': True, # data is fetched from oedb turbine library
'nominal_power': True, # data is fetched from oedb turbine library
}
# initialize WindTurbine object
e126 = WindTurbine(**enercon_e126)

# specification of wind turbine where power coefficient curve is provided
# by a csv file
csv_file = os.path.join(os.path.dirname(__file__), 'data',
'example_power_coefficient_curves.csv')
dummy_turbine = {
'name': 'DUMMY 1', # turbine type as in file #
'hub_height': 100, # in m
'rotor_diameter': 70, # in m
'fetch_curve': 'power_coefficient_curve', # fetch cp curve #
'data_source': csv_file # data source
}
# initialize WindTurbine object
dummy_turbine = WindTurbine(**dummy_turbine)

return my_turbine, e126, dummy_turbine


Expand All @@ -163,13 +175,14 @@ def calculate_power_output(weather, my_turbine, e126, dummy_turbine):
Parameters
----------
weather : pd.DataFrame
weather : :pandas:`pandas.DataFrame<frame>`
Contains weather data time series.
my_turbine : WindTurbine
my_turbine : :class:`~.wind_turbine.WindTurbine`
WindTurbine object with self provided power curve.
e126 : WindTurbine
WindTurbine object with power curve from the OpenEnergy Database.
dummy_turbine : WindTurbine
e126 : :class:`~.wind_turbine.WindTurbine`
WindTurbine object with power curve from the OpenEnergy Database
turbine library.
dummy_turbine : :class:`~.wind_turbine.WindTurbine`
WindTurbine object with power coefficient curve from example file.
"""
Expand Down Expand Up @@ -218,12 +231,12 @@ def plot_or_print(my_turbine, e126, dummy_turbine):
Parameters
----------
my_turbine : WindTurbine
my_turbine : :class:`~.wind_turbine.WindTurbine`
WindTurbine object with self provided power curve.
e126 : WindTurbine
WindTurbine object with power curve from data file provided by the
windpowerlib.
dummy_turbine : WindTurbine
e126 : :class:`~.wind_turbine.WindTurbine`
WindTurbine object with power curve from the OpenEnergy Database
turbine library.
dummy_turbine : :class:`~.wind_turbine.WindTurbine`
WindTurbine object with power coefficient curve from example file.
"""
Expand All @@ -233,6 +246,8 @@ def plot_or_print(my_turbine, e126, dummy_turbine):
e126.power_output.plot(legend=True, label='Enercon E126')
my_turbine.power_output.plot(legend=True, label='myTurbine')
dummy_turbine.power_output.plot(legend=True, label='dummyTurbine')
plt.xlabel('Time')
plt.ylabel('Power in W')
plt.show()
else:
print(e126.power_output)
Expand All @@ -241,23 +256,29 @@ def plot_or_print(my_turbine, e126, dummy_turbine):

# plot or print power curve
if plt:
if e126.power_curve is not None:
if e126.power_curve is not False:
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_curve is not None:
if my_turbine.power_curve is not False:
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 dummy_turbine.power_coefficient_curve is not None:
if dummy_turbine.power_coefficient_curve is not False:
dummy_turbine.power_coefficient_curve.plot(
x='wind_speed', y='value', style='*',
title='dummyTurbine power coefficient curve')
plt.xlabel('Wind speed in m/s')
plt.ylabel('Power coefficient')
plt.show()
else:
if e126.power_coefficient_curve is not None:
if e126.power_coefficient_curve is not False:
print(e126.power_coefficient_curve)
if e126.power_curve is not None:
if e126.power_curve is not False:
print(e126.power_curve)


Expand Down

0 comments on commit b6c48fa

Please sign in to comment.