Skip to content

Commit dd3cd3a

Browse files
committed
fetch_curve as input to function and no attribute of wind_turbine
1 parent db4663b commit dd3cd3a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

windpowerlib/wind_turbine.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,14 @@ def __init__(self, name, hub_height, rotor_diameter=None,
108108
self.power_coefficient_curve = power_coefficient_curve
109109
self.power_curve = power_curve
110110
self.nominal_power = nominal_power
111-
self.fetch_curve = fetch_curve
112111
self.coordinates = coordinates
113112

114113
self.power_output = None
115114

116115
if self.power_coefficient_curve is None and self.power_curve is None:
117-
self.fetch_turbine_data()
116+
self.fetch_turbine_data(fetch_curve)
118117

119-
# ToDo: Have fetch_curve as an input to this function.
120-
def fetch_turbine_data(self):
118+
def fetch_turbine_data(self, fetch_curve):
121119
r"""
122120
Fetches data of the requested wind turbine.
123121
@@ -186,22 +184,22 @@ def restructure_data():
186184
data = np.vstack((data, np.array(
187185
[float(col), float(wpp_df[col])])))
188186
data = np.delete(data, 0, 0)
189-
if self.fetch_curve == 'power_curve':
187+
if fetch_curve == 'power_curve':
190188
df = pd.DataFrame(data, columns=['wind_speed', 'power'])
191-
if self.fetch_curve == 'power_coefficient_curve':
189+
if fetch_curve == 'power_coefficient_curve':
192190
df = pd.DataFrame(data, columns=['wind_speed',
193191
'power coefficient'])
194192
nominal_power = wpp_df['p_nom'].iloc[0]
195193
return df, nominal_power
196-
if self.fetch_curve == 'power_curve':
194+
if fetch_curve == 'power_curve':
197195
filename = 'power_curves.csv'
198196
self.power_curve, p_nom = restructure_data()
199-
elif self.fetch_curve == 'power_coefficient_curve':
197+
elif fetch_curve == 'power_coefficient_curve':
200198
filename = 'power_coefficient_curves.csv'
201199
self.power_coefficient_curve, p_nom = restructure_data()
202200
else:
203201
raise ValueError("'{0}' is an invalid value. ".format(
204-
self.fetch_curve) + "`fetch_curve` must be " +
202+
fetch_curve) + "`fetch_curve` must be " +
205203
"'power_curve' or 'power_coefficient_curve'.")
206204
if self.nominal_power is None:
207205
self.nominal_power = p_nom

0 commit comments

Comments
 (0)