|
33 | 33 | "import os\n", |
34 | 34 | "import pandas as pd\n", |
35 | 35 | "\n", |
36 | | - "from windpowerlib import modelchain\n", |
| 36 | + "from windpowerlib.modelchain import ModelChain\n", |
| 37 | + "from windpowerlib.wind_turbine import WindTurbine\n", |
37 | 38 | "from windpowerlib import wind_turbine as wt" |
38 | 39 | ] |
39 | 40 | }, |
|
65 | 66 | "In order to use the windpowerlib you need to at least provide wind speed data for the time frame you want to analyse.\n", |
66 | 67 | "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", |
67 | 68 | "\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." |
69 | 70 | ] |
70 | 71 | }, |
71 | 72 | { |
|
98 | 99 | " Returns\n", |
99 | 100 | " -------\n", |
100 | 101 | " 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", |
108 | 109 | "\n", |
109 | 110 | " \"\"\"\n", |
110 | 111 | "\n", |
|
162 | 163 | "# get power coefficient curves\n", |
163 | 164 | "# write names of wind turbines for which power coefficient curves are provided\n", |
164 | 165 | "# 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", |
166 | 167 | "# find all Enercons in 'turbines' DataFrame\n", |
167 | 168 | "print(turbines[turbines[\"turbine_id\"].str.contains(\"ENERCON\")])" |
168 | 169 | ] |
|
180 | 181 | " 'nominal_power': 3e6, # in W\n", |
181 | 182 | " 'hub_height': 105, # in m\n", |
182 | 183 | " '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", |
187 | 188 | " } \n", |
188 | 189 | "# initialise WindTurbine object\n", |
189 | | - "my_turbine = wt.WindTurbine(**myTurbine)" |
| 190 | + "my_turbine = WindTurbine(**myTurbine)" |
190 | 191 | ] |
191 | 192 | }, |
192 | 193 | { |
|
198 | 199 | "outputs": [], |
199 | 200 | "source": [ |
200 | 201 | "# 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", |
203 | 204 | "enerconE126 = {\n", |
204 | 205 | " 'turbine_name': 'ENERCON E 126 7500', # turbine name as in register\n", |
205 | 206 | " 'hub_height': 135, # in m\n", |
206 | 207 | " 'rotor_diameter': 127 # in m\n", |
207 | 208 | " }\n", |
208 | 209 | "# initialise WindTurbine object\n", |
209 | | - "e126 = wt.WindTurbine(**enerconE126)" |
| 210 | + "e126 = WindTurbine(**enerconE126)" |
210 | 211 | ] |
211 | 212 | }, |
212 | 213 | { |
|
227 | 228 | "# power output calculation for my_turbine\n", |
228 | 229 | "# initialise ModelChain with default parameters and use run_model\n", |
229 | 230 | "# 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", |
231 | 232 | "# write power output timeseries to WindTurbine object\n", |
232 | 233 | "my_turbine.power_output = mc_my_turbine.power_output" |
233 | 234 | ] |
|
241 | 242 | "# power output calculation for e126\n", |
242 | 243 | "# own specifications for ModelChain setup\n", |
243 | 244 | "modelchain_data = {\n", |
244 | | - " 'obstacle_height': 0, # default: 0\n", |
245 | 245 | " 'wind_speed_model': 'logarithmic', # 'logarithmic' (default),\n", |
246 | 246 | " # 'hellman' or\n", |
247 | 247 | " # '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", |
249 | 250 | " 'temperature_model': 'linear_gradient', # 'linear_gradient' (def.) or\n", |
250 | 251 | " # 'interpolation_extrapolation'\n", |
251 | 252 | " 'power_output_model': 'power_curve', # 'power_curve' (default) or\n", |
252 | 253 | " # 'power_coefficient_curve'\n", |
253 | 254 | " 'density_correction': True, # False (default) or True\n", |
| 255 | + " 'obstacle_height': 0, # default: 0\n", |
254 | 256 | " 'hellman_exp': None} # None (default) or None\n", |
255 | 257 | "\n", |
256 | 258 | "# initialise ModelChain with own specifications and use run_model method to\n", |
257 | 259 | "# 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", |
259 | 261 | " weather)\n", |
260 | 262 | "# write power output timeseries to WindTurbine object\n", |
261 | 263 | "e126.power_output = mc_e126.power_output" |
|
308 | 310 | "source": [ |
309 | 311 | "# plot power (coefficient) curves\n", |
310 | 312 | "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", |
313 | 317 | " 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", |
316 | 321 | " 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", |
319 | 326 | " 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", |
322 | 330 | " plt.show()" |
323 | 331 | ] |
324 | 332 | }, |
|
0 commit comments