Skip to content

Commit 826f740

Browse files
committed
Adapt notebook to new names of p_values and cp_values
1 parent 050cac5 commit 826f740

File tree

1 file changed

+38
-30
lines changed

1 file changed

+38
-30
lines changed

example/basic_example.ipynb

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"import os\n",
3434
"import pandas as pd\n",
3535
"\n",
36-
"from windpowerlib import modelchain\n",
36+
"from windpowerlib.modelchain import ModelChain\n",
37+
"from windpowerlib.wind_turbine import WindTurbine\n",
3738
"from windpowerlib import wind_turbine as wt"
3839
]
3940
},
@@ -65,7 +66,7 @@
6566
"In order to use the windpowerlib you need to at least provide wind speed data for the time frame you want to analyse.\n",
6667
"The function below imports example weather data from the weather.csv file provided along with the windpowerlib. 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.\n",
6768
"\n",
68-
"To find out which weather data in which units need to be provided in order to use the ModelChain or other functions of the windpowerlib see the individual function documentation."
69+
"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."
6970
]
7071
},
7172
{
@@ -98,13 +99,13 @@
9899
" Returns\n",
99100
" -------\n",
100101
" weather_df : pandas.DataFrame\n",
101-
" DataFrame with time series for wind speed `wind_speed` in m/s,\n",
102-
" temperature `temperature` in K, roughness length `roughness_length`\n",
103-
" in m, and pressure `pressure` in Pa.\n",
104-
" The columns of the DataFrame are a MultiIndex where the first level\n",
105-
" contains the variable name (e.g. wind_speed) and the second level\n",
106-
" contains the height at which it applies (e.g. 10, if it was\n",
107-
" measured at a height of 10 m).\n",
102+
" DataFrame with time series for wind speed `wind_speed` in m/s,\n",
103+
" temperature `temperature` in K, roughness length `roughness_length`\n",
104+
" in m, and pressure `pressure` in Pa.\n",
105+
" The columns of the DataFrame are a MultiIndex where the first level\n",
106+
" contains the variable name (e.g. wind_speed) and the second level\n",
107+
" contains the height at which it applies (e.g. 10, if it was\n",
108+
" measured at a height of 10 m).\n",
108109
"\n",
109110
" \"\"\"\n",
110111
"\n",
@@ -162,7 +163,7 @@
162163
"# get power coefficient curves\n",
163164
"# write names of wind turbines for which power coefficient curves are provided\n",
164165
"# to 'turbines' DataFrame\n",
165-
"turbines = wt.get_turbine_types(filename='cp_curves.csv', print_out=False)\n",
166+
"turbines = wt.get_turbine_types(filename='power_coefficient_curves.csv', print_out=False)\n",
166167
"# find all Enercons in 'turbines' DataFrame\n",
167168
"print(turbines[turbines[\"turbine_id\"].str.contains(\"ENERCON\")])"
168169
]
@@ -180,13 +181,13 @@
180181
" 'nominal_power': 3e6, # in W\n",
181182
" 'hub_height': 105, # in m\n",
182183
" 'rotor_diameter': 90, # in m\n",
183-
" 'p_values': pd.Series(\n",
184-
" data=[p * 1000 for p in [\n",
185-
" 0.0, 26.0, 180.0, 1500.0, 3000.0, 3000.0]], # in W\n",
186-
" index=[0.0, 3.0, 5.0, 10.0, 15.0, 25.0]) # in m/s\n",
184+
" 'power_curve': pd.DataFrame(\n",
185+
" data={'values': [p * 1000 for p in [\n",
186+
" 0.0, 26.0, 180.0, 1500.0, 3000.0, 3000.0]], # in W\n",
187+
" 'wind_speed': [0.0, 3.0, 5.0, 10.0, 15.0, 25.0]}) # in m/s\n",
187188
" } \n",
188189
"# initialise WindTurbine object\n",
189-
"my_turbine = wt.WindTurbine(**myTurbine)"
190+
"my_turbine = WindTurbine(**myTurbine)"
190191
]
191192
},
192193
{
@@ -198,15 +199,15 @@
198199
"outputs": [],
199200
"source": [
200201
"# specification of wind turbine where power curve is provided\n",
201-
"# if you want to use the power coefficient curve add {'fetch_curve': 'cp'}\n",
202-
"# to the dictionary\n",
202+
"# if you want to use the power coefficient curve add\n",
203+
"# {'fetch_curve': 'power_coefficient_curve'} to the dictionary\n",
203204
"enerconE126 = {\n",
204205
" 'turbine_name': 'ENERCON E 126 7500', # turbine name as in register\n",
205206
" 'hub_height': 135, # in m\n",
206207
" 'rotor_diameter': 127 # in m\n",
207208
" }\n",
208209
"# initialise WindTurbine object\n",
209-
"e126 = wt.WindTurbine(**enerconE126)"
210+
"e126 = WindTurbine(**enerconE126)"
210211
]
211212
},
212213
{
@@ -227,7 +228,7 @@
227228
"# power output calculation for my_turbine\n",
228229
"# initialise ModelChain with default parameters and use run_model\n",
229230
"# method to calculate power output\n",
230-
"mc_my_turbine = modelchain.ModelChain(my_turbine).run_model(weather)\n",
231+
"mc_my_turbine = ModelChain(my_turbine).run_model(weather)\n",
231232
"# write power output timeseries to WindTurbine object\n",
232233
"my_turbine.power_output = mc_my_turbine.power_output"
233234
]
@@ -241,21 +242,22 @@
241242
"# power output calculation for e126\n",
242243
"# own specifications for ModelChain setup\n",
243244
"modelchain_data = {\n",
244-
" 'obstacle_height': 0, # default: 0\n",
245245
" 'wind_speed_model': 'logarithmic', # 'logarithmic' (default),\n",
246246
" # 'hellman' or\n",
247247
" # 'interpolation_extrapolation'\n",
248-
" 'density_model': 'ideal_gas', # 'barometric' (default) or 'ideal_gas'\n",
248+
" 'density_model': 'ideal_gas', # 'barometric' (default), 'ideal_gas'\n",
249+
" # or 'interpolation_extrapolation'\n",
249250
" 'temperature_model': 'linear_gradient', # 'linear_gradient' (def.) or\n",
250251
" # 'interpolation_extrapolation'\n",
251252
" 'power_output_model': 'power_curve', # 'power_curve' (default) or\n",
252253
" # 'power_coefficient_curve'\n",
253254
" 'density_correction': True, # False (default) or True\n",
255+
" 'obstacle_height': 0, # default: 0\n",
254256
" 'hellman_exp': None} # None (default) or None\n",
255257
"\n",
256258
"# initialise ModelChain with own specifications and use run_model method to\n",
257259
"# calculate power output\n",
258-
"mc_e126 = modelchain.ModelChain(e126, **modelchain_data).run_model(\n",
260+
"mc_e126 = ModelChain(e126, **modelchain_data).run_model(\n",
259261
" weather)\n",
260262
"# write power output timeseries to WindTurbine object\n",
261263
"e126.power_output = mc_e126.power_output"
@@ -308,17 +310,23 @@
308310
"source": [
309311
"# plot power (coefficient) curves\n",
310312
"if plt:\n",
311-
" if e126.cp_values is not None:\n",
312-
" e126.cp_values.plot(style='*', title='Enercon E126')\n",
313+
" if e126.power_coefficient_curve is not None:\n",
314+
" e126.power_coefficient_curve.plot(\n",
315+
" x='wind_speed', y='values', style='*',\n",
316+
" title='Enercon E126 power coefficient curve')\n",
313317
" plt.show()\n",
314-
" if e126.p_values is not None:\n",
315-
" e126.p_values.plot(style='*', title='Enercon E126')\n",
318+
" if e126.power_curve is not None:\n",
319+
" e126.power_curve.plot(x='wind_speed', y='values', style='*',\n",
320+
" title='Enercon E126 power curve')\n",
316321
" plt.show()\n",
317-
" if my_turbine.cp_values is not None:\n",
318-
" my_turbine.cp_values.plot(style='*', title='myTurbine')\n",
322+
" if my_turbine.power_coefficient_curve is not None:\n",
323+
" my_turbine.power_coefficient_curve.plot(\n",
324+
" x='wind_speed', y='values', style='*',\n",
325+
" title='myTurbine power coefficient curve')\n",
319326
" plt.show()\n",
320-
" if my_turbine.p_values is not None:\n",
321-
" my_turbine.p_values.plot(style='*', title='myTurbine')\n",
327+
" if my_turbine.power_curve is not None:\n",
328+
" my_turbine.power_curve.plot(x='wind_speed', y='values', style='*',\n",
329+
" title='myTurbine power curve')\n",
322330
" plt.show()"
323331
]
324332
},

0 commit comments

Comments
 (0)