Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,15 @@ The basic usage of the windpowerlib is shown in the `ModelChain example <http://
* `ModelChain example (Python script) <https://raw.githubusercontent.com/wind-python/windpowerlib/master/example/modelchain_example.py>`_
* `ModelChain example (Jupyter notebook) <https://raw.githubusercontent.com/wind-python/windpowerlib/master/example/modelchain_example.ipynb>`_

To run the example you need the example weather and turbine data used:
To run the example you need example weather that is downloaded automatically and can also be downloaded here:

* `Example weather data file <https://raw.githubusercontent.com/wind-python/windpowerlib/master/example/weather.csv>`_
* `Example power curve data file <https://raw.githubusercontent.com/wind-python/windpowerlib/master/example/data/example_power_curves.csv>`_
* `Example power coefficient curve data file <https://raw.githubusercontent.com/wind-python/windpowerlib/master/example/data/example_power_coefficient_curves.csv>`_
* `Example nominal power data file <https://raw.githubusercontent.com/wind-python/windpowerlib/master/example/data/example_turbine_data.csv>`_

To run the examples locally you have to install windpowerlib. To run the notebook you also need to install `notebook` using pip3. To launch jupyter notebook type ``jupyter notebook`` in the terminal.
To run the examples locally you 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 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. In order to reproduce the figures in a notebook you need to install `matplotlib`.

Further functionalities, like the modelling of wind farms and wind turbine clusters, are shown in the `TurbineClusterModelChain example <http://windpowerlib.readthedocs.io/en/stable/turbine_cluster_modelchain_example_notebook.html>`_. As the ModelChain example it is available as jupyter notebook and as python script. The weather and turbine datadata used 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 <http://windpowerlib.readthedocs.io/en/stable/turbine_cluster_modelchain_example_notebook.html>`_. As the ModelChain example it is available as jupyter notebook and as python script. The weather used in this example is the same as in the ModelChain example.

* `TurbineClusterModelChain example (Python script) <https://raw.githubusercontent.com/wind-python/windpowerlib/master/example/turbine_cluster_modelchain_example.py>`_
* `TurbineClusterModelChain example (Jupyter notebook) <https://raw.githubusercontent.com/wind-python/windpowerlib/master/example/turbine_cluster_modelchain_example.ipynb>`_
Expand Down
261 changes: 134 additions & 127 deletions example/modelchain_example.ipynb

Large diffs are not rendered by default.

46 changes: 22 additions & 24 deletions example/modelchain_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ def get_weather_data(filename="weather.csv", **kwargs):

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 file is located in the example folder of the
windpowerlib. The height in m for which the data applies is specified in
the second row.
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
----------
Expand All @@ -51,18 +52,19 @@ def get_weather_data(filename="weather.csv", **kwargs):
----------------
datapath : str, optional
Path where the weather data file is stored.
Default: 'windpowerlib/example'.
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).
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.

"""

Expand All @@ -71,6 +73,7 @@ def get_weather_data(filename="weather.csv", **kwargs):

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")
Expand All @@ -85,10 +88,8 @@ def get_weather_data(filename="weather.csv", **kwargs):
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 time zone
weather_df.index = weather_df.index.tz_convert("Europe/Berlin")

return weather_df

Expand Down Expand Up @@ -197,8 +198,7 @@ def calculate_power_output(weather, my_turbine, e126, my_turbine2):
"""

# ************************************************************************
# **** Data is provided in the oedb turbine library **********************
# **** ModelChain with non-default specifications
# **** ModelChain with non-default specifications ************************
modelchain_data = {
"wind_speed_model": "logarithmic", # 'logarithmic' (default),
# 'hellman' or
Expand All @@ -207,8 +207,8 @@ def calculate_power_output(weather, my_turbine, e126, my_turbine2):
# 'interpolation_extrapolation'
"temperature_model": "linear_gradient", # 'linear_gradient' (def.) or
# 'interpolation_extrapolation'
"power_output_model": "power_curve", # 'power_curve' (default) or
# 'power_coefficient_curve'
"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,
Expand All @@ -220,17 +220,15 @@ def calculate_power_output(weather, my_turbine, e126, my_turbine2):
e126.power_output = mc_e126.power_output

# ************************************************************************
# **** Specification of wind turbine with your own data ******************
# **** ModelChain with default parameter
# **** ModelChain with default parameter *********************************
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

# ************************************************************************
# **** Specification of wind turbine with data in own file ***************
# **** Using "power_coefficient_curve" as "power_output_model".
# **** ModelChain with non-default value for "wind_speed_model" **********
mc_example_turbine = ModelChain(
my_turbine2, power_output_model="power_curve"
my_turbine2, wind_speed_model="hellman"
).run_model(weather)
my_turbine2.power_output = mc_example_turbine.power_output

Expand Down
3 changes: 0 additions & 3 deletions example/power_coefficient_curves.csv

This file was deleted.

3 changes: 0 additions & 3 deletions example/power_curves.csv

This file was deleted.

2 changes: 1 addition & 1 deletion example/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_modelchain_example_flh(self):
mc_e.calculate_power_output(weather, my_turbine, e126, dummy_turbine)

assert_allclose(
2764.194772, (e126.power_output.sum() / e126.nominal_power), 0.01
2730.142, (e126.power_output.sum() / e126.nominal_power), 0.01
)
Comment on lines 24 to 26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that the new value is correct? Why is the old value wrong?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's because I changed the power_output_model to "power_coefficient_curve". And I changed the power output model because I wanted one example showing how to use the power coefficient curve. At an earlier point the power coefficient curve was used when calculating the feed-in for my_turbine2, but we now only provide its power curve.

assert_allclose(
1882.7567,
Expand Down
23 changes: 6 additions & 17 deletions example/turbine_cluster_modelchain_example.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/turbine_cluster_modelchain_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def run_example():

"""
weather = mc_e.get_weather_data("weather.csv")
my_turbine, e126, dummy_turbine = mc_e.initialize_wind_turbines()
my_turbine, e126, my_turbine2 = mc_e.initialize_wind_turbines()
example_farm, example_farm_2 = initialize_wind_farms(my_turbine, e126)
example_cluster = initialize_wind_turbine_cluster(
example_farm, example_farm_2
Expand Down
5 changes: 0 additions & 5 deletions example/turbine_data.csv

This file was deleted.