Skip to content

Commit 1d57622

Browse files
committed
Adapt basic example
1 parent 3167fa3 commit 1d57622

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

example/basic_example.py

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ def initialise_wind_turbines():
8484
and/or power coefficient curve data from data files provided by the
8585
windpowerlib, as done for the 'enerconE126'.
8686
Execute ``windpowerlib.wind_turbine.get_turbine_types()`` or
87-
``windpowerlib.wind_turbine.get_turbine_types(filename='cp_curves.csv')``
88-
to get a list of all wind turbines for which power and power coefficient
89-
curves respectively are provided.
87+
``windpowerlib.wind_turbine.get_turbine_types(
88+
filename='power_coefficient_curves.csv')`` to get a list of all wind
89+
turbines for which power and power coefficient curves respectively are
90+
provided.
9091
9192
Returns
9293
-------
@@ -101,17 +102,17 @@ def initialise_wind_turbines():
101102
'nominal_power': 3e6, # in W
102103
'hub_height': 105, # in m
103104
'rotor_diameter': 90, # in m
104-
'p_values': pd.Series(
105-
data=[p * 1000 for p in [
106-
0.0, 26.0, 180.0, 1500.0, 3000.0, 3000.0]], # in W
107-
index=[0.0, 3.0, 5.0, 10.0, 15.0, 25.0]) # in m/s
105+
'power_curve': pd.DataFrame(
106+
data={'values': [p * 1000 for p in [
107+
0.0, 26.0, 180.0, 1500.0, 3000.0, 3000.0]], # in W
108+
'wind_speed': [0.0, 3.0, 5.0, 10.0, 15.0, 25.0]}) # in m/s
108109
}
109110
# initialise WindTurbine object
110111
my_turbine = wt.WindTurbine(**myTurbine)
111112

112113
# specification of wind turbine where power curve is provided
113-
# if you want to use the power coefficient curve add {'fetch_curve': 'cp'}
114-
# to the dictionary
114+
# if you want to use the power coefficient curve add
115+
# {'fetch_curve': 'power_coefficient_curve'} to the dictionary
115116
enerconE126 = {
116117
'turbine_name': 'ENERCON E 126 7500', # turbine name as in register
117118
'hub_height': 135, # in m
@@ -159,7 +160,8 @@ def calculate_power_output(weather, my_turbine, e126):
159160
'wind_speed_model': 'logarithmic', # 'logarithmic' (default),
160161
# 'hellman' or
161162
# 'interpolation_extrapolation'
162-
'density_model': 'ideal_gas', # 'barometric' (default) or 'ideal_gas'
163+
'density_model': 'ideal_gas', # 'barometric' (default), 'ideal_gas' or
164+
# 'interpolation_extrapolation'
163165
'temperature_model': 'linear_gradient', # 'linear_gradient' (def.) or
164166
# 'interpolation_extrapolation'
165167
'power_output_model': 'power_curve', # 'power_curve' (default) or
@@ -200,24 +202,29 @@ def plot_or_print(my_turbine, e126):
200202

201203
# plot or print power (coefficient) curve
202204
if plt:
203-
if e126.cp_values is not None:
204-
e126.cp_values.plot(style='*', title='Enercon E126')
205+
if e126.power_coefficient_curve is not None:
206+
e126.power_coefficient_curve.plot(
207+
x='wind_speed', y='values', style='*',
208+
title='Enercon E126 power coefficient curve')
205209
plt.show()
206-
if e126.p_values is not None:
207-
e126.p_values.plot(style='*', title='Enercon E126')
210+
if e126.power_curve is not None:
211+
e126.power_curve.plot(x='wind_speed', y='values', style='*',
212+
title='Enercon E126 power curve')
208213
plt.show()
209-
if my_turbine.cp_values is not None:
210-
my_turbine.cp_values.plot(style='*', title='myTurbine')
214+
if my_turbine.power_coefficient_curve is not None:
215+
my_turbine.power_coefficient_curve.plot(
216+
x='wind_speed', y='values', style='*',
217+
title='myTurbine power coefficient curve')
211218
plt.show()
212-
if my_turbine.p_values is not None:
213-
my_turbine.p_values.plot(style='*', title='myTurbine')
219+
if my_turbine.power_curve is not None:
220+
my_turbine.power_curve.plot(x='wind_speed', y='values', style='*',
221+
title='myTurbine power curve')
214222
plt.show()
215223
else:
216-
if e126.cp_values is not None:
217-
print(e126.cp_values)
218-
if e126.p_values is not None:
219-
print("The P value at a wind speed of 5 m/s: {0}".format(
220-
e126.p_values.p[5.0]))
224+
if e126.power_coefficient_curve is not None:
225+
print(e126.power_coefficient_curve)
226+
if e126.power_curve is not None:
227+
print(e126.power_curve)
221228

222229

223230
def run_basic_example():

0 commit comments

Comments
 (0)