Skip to content

Commit 869d7e9

Browse files
committed
p_values and cp_values as pd.Series
1 parent c69f778 commit 869d7e9

File tree

3 files changed

+23
-28
lines changed

3 files changed

+23
-28
lines changed

tests/test_power_output.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def test_power_coefficient_curve(self):
1313
parameters = {'wind_speed': pd.Series(data=[2.0, 5.5, 7.0]),
1414
'density': pd.Series(data=[1.3, 1.3, 1.3]),
1515
'rotor_diameter': 80,
16-
'cp_values': pd.DataFrame(data={'cp': [0.3, 0.4, 0.5]},
17-
index=[4.0, 5.0, 6.0])}
16+
'cp_values': pd.Series([0.3, 0.4, 0.5],
17+
index=[4.0, 5.0, 6.0])}
1818

1919
# Test wind_speed as pd.Series with density as pd.Series and np.array
2020
power_output_exp = pd.Series(data=[0.0, 244615.399, 0.0],
@@ -40,8 +40,8 @@ def test_cp_curve_density_corrected(self):
4040
parameters = {'wind_speed': pd.Series(data=[2.0, 5.5, 7.0]),
4141
'density': pd.Series(data=[1.3, 1.3, 1.3]),
4242
'rotor_diameter': 80,
43-
'cp_values': pd.DataFrame(data={'cp': [0.3, 0.4, 0.5]},
44-
index=[4.0, 5.0, 6.0])}
43+
'cp_values': pd.Series([0.3, 0.4, 0.5],
44+
index=[4.0, 5.0, 6.0])}
4545

4646
# Test wind_speed as pd.Series with density as pd.Series and np.array
4747
power_output_exp = pd.Series(data=[0.0, 262869.785, 0.0],
@@ -65,8 +65,8 @@ def test_cp_curve_density_corrected(self):
6565

6666
def test_power_curve(self):
6767
parameters = {'wind_speed': pd.Series(data=[2.0, 5.5, 7.0]),
68-
'p_values': pd.DataFrame(data={'p': [300, 400, 500]},
69-
index=[4.0, 5.0, 6.0])}
68+
'p_values': pd.Series([300, 400, 500],
69+
index=[4.0, 5.0, 6.0])}
7070

7171
# Test wind_speed as pd.Series
7272
power_output_exp = pd.Series(data=[0.0, 450.0, 0.0],
@@ -82,8 +82,8 @@ def test_power_curve(self):
8282
def test_p_curve_density_corrected(self):
8383
parameters = {'wind_speed': pd.Series(data=[2.0, 5.5, 7.0]),
8484
'density': pd.Series(data=[1.3, 1.3, 1.3]),
85-
'p_values': pd.DataFrame(data={'p': [300, 400, 500]},
86-
index=[4.0, 5.0, 6.0])}
85+
'p_values': pd.Series([300, 400, 500],
86+
index=[4.0, 5.0, 6.0])}
8787

8888
# Test wind_speed as pd.Series with density as pd.Series and np.array
8989
power_output_exp = pd.Series(data=[0.0, 461.00290572, 0.0],

windpowerlib/power_output.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ def power_coefficient_curve(wind_speed, density, rotor_diameter, cp_values):
2727
Density of air at hub height in kg/m³.
2828
rotor_diameter : float
2929
Rotor diameter in m.
30-
cp_values : pandas.DataFrame
30+
cp_values : pandas.Series
3131
Power coefficient curve of the wind turbine.
32-
Indices are the wind speeds of the power coefficient curve in m/s, the
33-
corresponding power coefficient values are in the column 'cp'.
32+
Indices are the wind speeds of the power coefficient curve in m/s.
3433
3534
Returns
3635
-------
@@ -61,7 +60,7 @@ def power_coefficient_curve(wind_speed, density, rotor_diameter, cp_values):
6160
Wirtschaftlichkeit". 4. Auflage, Springer-Verlag, 2008, p. 542
6261
6362
"""
64-
cp_time_series = np.interp(wind_speed, cp_values.index, cp_values.cp,
63+
cp_time_series = np.interp(wind_speed, cp_values.index, cp_values,
6564
left=0, right=0)
6665
# Convert density to np.array if wind_speed is np.array
6766
if isinstance(wind_speed, np.ndarray) and isinstance(density, pd.Series):
@@ -92,10 +91,9 @@ def cp_curve_density_corr(wind_speed, density, rotor_diameter, cp_values):
9291
Density of air at hub height in kg/m³.
9392
rotor_diameter : float
9493
Rotor diameter in m.
95-
cp_values : pandas.DataFrame
94+
cp_values : pandas.Series
9695
Power coefficient curve of the wind turbine.
97-
Indices are the wind speeds of the power coefficient curve in m/s, the
98-
corresponding power coefficient values are in the column 'cp'.
96+
Indices are the wind speeds of the power coefficient curve in m/s.
9997
10098
Returns
10199
-------
@@ -115,9 +113,8 @@ def cp_curve_density_corr(wind_speed, density, rotor_diameter, cp_values):
115113
116114
"""
117115
p_values = (1 / 8 * 1.225 * rotor_diameter ** 2 * np.pi *
118-
np.power(cp_values.index, 3) * cp_values.cp)
119-
p_values = pd.DataFrame(data=np.array(p_values), index=cp_values.index,
120-
columns=['p'])
116+
np.power(cp_values.index, 3) * cp_values)
117+
p_values = pd.Series(np.array(p_values), index=cp_values.index)
121118
return p_curve_density_corr(wind_speed, density, p_values)
122119

123120

@@ -133,10 +130,9 @@ def power_curve(wind_speed, p_values):
133130
----------
134131
wind_speed : pandas.Series or numpy.array
135132
Wind speed at hub height in m/s.
136-
p_values : pandas.DataFrame
133+
p_values : pandas.Series
137134
Power curve of the wind turbine.
138-
Indices are the wind speeds of the power curve in m/s, the
139-
corresponding power values in W are in the column 'p'.
135+
Indices are the wind speeds of the power curve in m/s.
140136
141137
Returns
142138
-------
@@ -150,7 +146,7 @@ def power_curve(wind_speed, p_values):
150146
and below the minimum wind speed given in the power curve is zero.
151147
152148
"""
153-
power_output = np.interp(wind_speed, p_values.index, p_values.p,
149+
power_output = np.interp(wind_speed, p_values.index, p_values,
154150
left=0, right=0)
155151
# Power_output as pd.Series if wind_speed is pd.Series
156152
if isinstance(wind_speed, pd.Series):
@@ -173,10 +169,9 @@ def p_curve_density_corr(wind_speed, density, p_values):
173169
Wind speed time series at hub height in m/s.
174170
density : pandas.Series or numpy.array
175171
Density of air at hub height in kg/m³.
176-
p_values : pandas.DataFrame
172+
p_values : pandas.Series
177173
Power curve of the wind turbine.
178-
Indices are the wind speeds of the power curve in m/s, the
179-
corresponding power values in W are in the column 'p'.
174+
Indices are the wind speeds of the power curve in m/s.
180175
181176
Returns
182177
-------
@@ -231,7 +226,7 @@ def p_curve_density_corr(wind_speed, density, p_values):
231226
p_values.index * (1.225 / density[i])**(
232227
np.interp(p_values.index,
233228
[7.5, 12.5], [1/3, 2/3])),
234-
p_values.p, left=0, right=0))
229+
p_values, left=0, right=0))
235230
for i in range(len(wind_speed))]
236231
# Power_output as pd.Series if wind_speed is pd.Series
237232
if isinstance(wind_speed, pd.Series):

windpowerlib/wind_turbine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ def restructure_data():
173173
[float(col), float(wpp_df[col])])))
174174
data = np.delete(data, 0, 0)
175175
df = pd.DataFrame(data, columns=['v_wind', self.fetch_curve])
176-
df.set_index('v_wind', drop=True, inplace=True)
176+
series = pd.Series(df[self.fetch_curve], index=df['v_wind'])
177177
nominal_power = wpp_df['p_nom'].iloc[0] * 1000.0 # kW to W
178-
return df, nominal_power
178+
return series, nominal_power
179179
if self.fetch_curve == 'p':
180180
filename = 'p_curves.csv'
181181
p_values, p_nom = restructure_data()

0 commit comments

Comments
 (0)