@@ -34,7 +34,7 @@ def cp_curve(v_wind, rho_hub, d_rotor, cp_values):
3434
3535 Returns
3636 -------
37- pandas.Series
37+ pandas.Series or numpy.array
3838 Electrical power output of the wind turbine in W.
3939
4040 Notes
@@ -60,17 +60,18 @@ def cp_curve(v_wind, rho_hub, d_rotor, cp_values):
6060
6161 """
6262 # cp time series
63- cp_series = np .interp (v_wind , cp_values .index , cp_values .cp ,
64- left = 0 , right = 0 )
63+ cp_time_series = np .interp (v_wind , cp_values .index , cp_values .cp ,
64+ left = 0 , right = 0 )
65+ # Convert rho_hub to np.array if v_wind is np.array
66+ if (isinstance (v_wind , np .ndarray ) and isinstance (rho_hub , pd .Series )):
67+ rho_hub = np .array (rho_hub )
6568 power_output = (1 / 8 * rho_hub * d_rotor ** 2 * np .pi
66- * np .power (v_wind , 3 ) * cp_series )
67- # Set index for time series
68- try :
69- series_index = v_wind .index
70- except AttributeError :
71- series_index = range (1 , len (power_output )+ 1 )
72- return pd .Series (data = power_output , index = series_index ,
73- name = 'feedin_wind_turbine' )
69+ * np .power (v_wind , 3 ) * cp_time_series )
70+ # Power_output as pd.Series if v_wind is pd.Series
71+ if isinstance (v_wind , pd .Series ):
72+ power_output = pd .Series (data = power_output , index = v_wind .index ,
73+ name = 'feedin_wind_turbine' )
74+ return power_output
7475
7576
7677def cp_curve_density_corr (v_wind , rho_hub , d_rotor , cp_values ):
@@ -87,16 +88,16 @@ def cp_curve_density_corr(v_wind, rho_hub, d_rotor, cp_values):
8788 Wind speed at hub height in m/s.
8889 rho_hub : pandas.Series or numpy.array
8990 Density of air at hub height in kg/m³.
91+ d_rotor : float
92+ Diameter of the rotor in m.
9093 cp_values : pandas.DataFrame
9194 Power coefficient curve of the wind turbine.
9295 Indices are the wind speeds of the power coefficient curve in m/s, the
9396 corresponding power coefficient values are in the column 'cp'.
94- d_rotor : float
95- Diameter of the rotor in m.
9697
9798 Returns
9899 -------
99- pandas.Series
100+ pandas.Series or numpy.array
100101 Electrical power of the wind turbine in W.
101102
102103 Notes
@@ -116,7 +117,7 @@ def cp_curve_density_corr(v_wind, rho_hub, d_rotor, cp_values):
116117 return p_curve_density_corr (v_wind , rho_hub , p_values )
117118
118119
119- def p_curve (p_values , v_wind ):
120+ def p_curve (v_wind , p_values ):
120121 r"""
121122 Calculates the turbine power output using a power curve.
122123
@@ -126,16 +127,16 @@ def p_curve(p_values, v_wind):
126127
127128 Parameters
128129 ----------
130+ v_wind : pandas.Series or numpy.array
131+ Wind speed at hub height in m/s.
129132 p_values : pandas.DataFrame
130133 Power curve of the wind turbine.
131134 Indices are the wind speeds of the power curve in m/s, the
132135 corresponding power values in W are in the column 'p'.
133- v_wind : pandas.Series or numpy.array
134- Wind speed at hub height in m/s.
135136
136137 Returns
137138 -------
138- pandas.Series
139+ pandas.Series or numpy.array
139140 Electrical power output of the wind turbine in W.
140141
141142 Notes
@@ -146,13 +147,11 @@ def p_curve(p_values, v_wind):
146147 """
147148 power_output = np .interp (v_wind , p_values .index , p_values .p ,
148149 left = 0 , right = 0 )
149- # Set index for time series
150- try :
151- series_index = v_wind .index
152- except AttributeError :
153- series_index = range (1 , len (power_output )+ 1 )
154- return pd .Series (data = power_output , index = series_index ,
155- name = 'feedin_wind_turbine' )
150+ # Power_output as pd.Series if v_wind is pd.Series
151+ if isinstance (v_wind , pd .Series ):
152+ power_output = pd .Series (data = power_output , index = v_wind .index ,
153+ name = 'feedin_wind_turbine' )
154+ return power_output
156155
157156
158157def p_curve_density_corr (v_wind , rho_hub , p_values ):
@@ -176,7 +175,7 @@ def p_curve_density_corr(v_wind, rho_hub, p_values):
176175
177176 Returns
178177 -------
179- pandas.Series
178+ pandas.Series or numpy.array
180179 Electrical power output of the wind turbine in W.
181180
182181 Notes
@@ -219,17 +218,19 @@ def p_curve_density_corr(v_wind, rho_hub, p_values):
219218 at Reiner Lemoine Institute, 2014, p. 13
220219
221220 """
221+ # Convert rho_hub to np.array if v_wind is np.array
222+ if (isinstance (v_wind , np .ndarray ) and isinstance (rho_hub , pd .Series )):
223+ rho_hub = np .array (rho_hub )
222224 power_output = [(np .interp (v_wind [i ],
223225 p_values .index * (1.225 / rho_hub [i ])** (
224226 np .interp (p_values .index ,
225227 [7.5 , 12.5 ], [1 / 3 , 2 / 3 ])),
226228 p_values .p , left = 0 , right = 0 ))
227229 for i in range (len (v_wind ))]
228-
229- # Set index for time series
230- try :
231- series_index = v_wind .index
232- except AttributeError :
233- series_index = range (1 , len (power_output )+ 1 )
234- return pd .Series (data = power_output , index = series_index ,
235- name = 'feedin_wind_turbine' )
230+ # Power_output as pd.Series if v_wind is pd.Series
231+ if isinstance (v_wind , pd .Series ):
232+ power_output = pd .Series (data = power_output , index = v_wind .index ,
233+ name = 'feedin_wind_turbine' )
234+ else :
235+ power_output = np .array (power_output )
236+ return power_output
0 commit comments