Skip to content

Commit 83aad33

Browse files
Birgit SchachlerBirgit Schachler
authored andcommitted
Merge branch 'features/revise_example' into features/improve_documentation
Conflicts: example/basic_example.ipynb
2 parents 32357c0 + 1cb6248 commit 83aad33

File tree

4 files changed

+49
-15
lines changed

4 files changed

+49
-15
lines changed

doc/example.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. currentmodule:: example
2+
3+
.. autosummary::
4+
:toctree: temp/
5+
6+
basic_example.get_weather_data
7+
basic_example.initialise_wind_turbines
8+
basic_example.calculate_power_output
9+
basic_example.plot_or_print
10+
basic_example.run_basic_example

doc/modules.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,12 @@ Methods of the ModelChain object.
9393

9494
modelchain.ModelChain.rho_hub
9595
modelchain.ModelChain.v_wind_hub
96-
modelchain.ModelChain.turbine_power_output
96+
modelchain.ModelChain.turbine_power_output
97+
98+
99+
Example
100+
==============
101+
102+
The basic example consists of the following functions.
103+
104+
.. include:: example.rst

example/basic_example.ipynb

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99
"This example shows you the basic usage of the windpowerlib. \n",
1010
"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 feedin timeseries.\n",
1111
"\n",
12-
"But first of all you need to import the packages needed for the different steps."
12+
"Before you start you have to import the packages needed for these steps."
13+
]
14+
},
15+
{
16+
"cell_type": "markdown",
17+
"metadata": {},
18+
"source": [
19+
"### Import necessary packages and modules"
1320
]
1421
},
1522
{
@@ -163,9 +170,10 @@
163170
"wt.get_turbine_types(print_out=False)\n",
164171
"\n",
165172
"# get power coefficient curves\n",
166-
"# write names of wind turbines for which power coefficient curves are provided to 'turbines' DataFrame\n",
173+
"# write names of wind turbines for which power coefficient curves are provided\n",
174+
"# to 'turbines' DataFrame\n",
167175
"turbines = wt.get_turbine_types(filename='cp_curves.csv', print_out=False)\n",
168-
"# find all Vestas in 'turbines' DataFrame\n",
176+
"# find all Enercons in 'turbines' DataFrame\n",
169177
"print(turbines[turbines[\"turbine_id\"].str.contains(\"ENERCON\")])"
170178
]
171179
},
@@ -177,14 +185,16 @@
177185
},
178186
"outputs": [],
179187
"source": [
180-
"# specification of own wind turbine (Note: power coefficient values and nominal power have to be in Watt)\n",
188+
"# specification of own wind turbine (Note: power coefficient values and\n",
189+
"# nominal power have to be in Watt)\n",
181190
"myTurbine = {\n",
182191
" 'turbine_name': 'myTurbine',\n",
183192
" 'nominal_power': 3e6, # in W\n",
184193
" 'hub_height': 105, # in m\n",
185194
" 'd_rotor': 90, # in m\n",
186195
" 'p_values': pd.DataFrame(\n",
187-
" data={'p': [p * 1000 for p in [0.0, 26.0, 180.0, 1500.0, 3000.0, 3000.0]]}, # in W\n",
196+
" data={'p': [p * 1000 for p in\n",
197+
" [0.0, 26.0, 180.0, 1500.0, 3000.0, 3000.0]]}, # in W\n",
188198
" index=[0.0, 3.0, 5.0, 10.0, 15.0, 25.0]) # in m/s\n",
189199
" } \n",
190200
"# initialise WindTurbine object\n",
@@ -200,7 +210,8 @@
200210
"outputs": [],
201211
"source": [
202212
"# specification of wind turbine where power curve is provided\n",
203-
"# if you want to use the power coefficient curve add {'fetch_curve': 'cp'} to the dictionary\n",
213+
"# if you want to use the power coefficient curve add {'fetch_curve': 'cp'}\n",
214+
"# to the dictionary\n",
204215
"enerconE126 = {\n",
205216
" 'turbine_name': 'ENERCON E 126 7500', # turbine name as in register\n",
206217
" 'hub_height': 135, # in m\n",
@@ -226,7 +237,8 @@
226237
"outputs": [],
227238
"source": [
228239
"# power output calculation for my_turbine\n",
229-
"# initialise ModelChain with default parameters and use run_model method to calculate power output\n",
240+
"# initialise ModelChain with default parameters and use run_model\n",
241+
"# method to calculate power output\n",
230242
"mc_my_turbine = modelchain.ModelChain(my_turbine).run_model(\n",
231243
" weather, data_height)\n",
232244
"# write power output timeseries to WindTurbine object\n",
@@ -248,7 +260,8 @@
248260
" 'power_output_model': 'p_values', # 'p_values' (default) or 'cp_values'\n",
249261
" 'density_corr': True, # False (default) or True\n",
250262
" 'hellman_exp': None} # None (default) or None\n",
251-
"# initialise ModelChain with own specifications and use run_model method to calculate power output\n",
263+
"# initialise ModelChain with own specifications and use run_model method to\n",
264+
"# calculate power output\n",
252265
"mc_e126 = modelchain.ModelChain(e126, **modelchain_data).run_model(\n",
253266
" weather, data_height)\n",
254267
"# write power output timeseries to WindTurbine object\n",

example/basic_example.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,18 @@ def read_weather_data(filename, datetime_column='time_index',
104104
return (weather, data_height)
105105

106106

107-
# TODO markdown for code snippet
108107
def initialise_wind_turbines():
109108
r"""
110109
Initialises two :class:`~.wind_turbine.WindTurbine` objects.
111110
112111
Function shows two ways to initialise a WindTurbine object. You can either
113112
specify your own turbine, as done below for 'myTurbine', or fetch power
114113
and/or power coefficient curve data from data files provided by the
115-
windpowerlib, as done for the 'enerconE126'. Execute
116-
windpowerlib.wind_turbine.get_turbine_types() or
117-
windpowerlib.wind_turbine.get_turbine_types(filename='cp_curves.csv')
118-
to get a list of all wind turbines for which power or power coefficient
119-
curves, respectively, are provided.
114+
windpowerlib, as done for the 'enerconE126'.
115+
Execute ``windpowerlib.wind_turbine.get_turbine_types()`` or
116+
``windpowerlib.wind_turbine.get_turbine_types(filename='cp_curves.csv')``
117+
to get a list of all wind turbines for which power and power coefficient
118+
curves respectively are provided.
120119
121120
Returns
122121
-------
@@ -251,6 +250,10 @@ def plot_or_print(my_turbine, e126):
251250

252251

253252
def run_basic_example():
253+
r"""
254+
Run the basic example.
255+
256+
"""
254257
weather, data_height = get_weather_data('weather.csv')
255258
my_turbine, e126 = initialise_wind_turbines()
256259
calculate_power_output(weather, data_height, my_turbine, e126)

0 commit comments

Comments
 (0)