@@ -286,18 +286,22 @@ def _get_power_output(
286286 :numpy:`numpy.array`
287287 Electrical power output of the wind turbine in W.
288288 """
289- power_output = np .empty (len (wind_speed ), dtype = np .float )
289+ # Calculate the power curves for each timestep using vectors
290+ # NOTE: power_curves_per_ts.shape = [len(wind_speed), len(density)]
291+ power_curves_per_ts = (
292+ (1.225 / density ).reshape (- 1 , 1 )
293+ ** np .interp (power_curve_wind_speeds , [7.5 , 12.5 ], [1 / 3 , 2 / 3 ])
294+ ) * power_curve_wind_speeds
290295
291- for i in range (len (wind_speed )):
292- power_output [i ] = np .interp (
293- wind_speed [i ],
294- power_curve_wind_speeds
295- * (1.225 / density [i ])
296- ** (
297- np .interp (power_curve_wind_speeds , [7.5 , 12.5 ], [1 / 3 , 2 / 3 ])
298- ),
299- power_curve_values ,
300- left = 0 ,
301- right = 0 ,
296+ # Create the interpolation function
297+ def interp_func (w_speed , p_curves ):
298+ return np .interp (
299+ w_speed , p_curves , power_curve_values , left = 0 , right = 0
302300 )
301+
302+ # Calculate the power output by mapping the arrays to the interp function
303+ power_output = np .array (
304+ list (map (interp_func , wind_speed , power_curves_per_ts ))
305+ )
306+
303307 return power_output
0 commit comments