@@ -20,9 +20,6 @@ class ModelChain(object):
2020 wind_turbine : WindTurbine
2121 A :class:`~.wind_turbine.WindTurbine` object representing the wind
2222 turbine.
23- obstacle_height : float
24- Height of obstacles in the surrounding area of the wind turbine in m.
25- Set `obstacle_height` to zero for wide spread obstacles. Default: 0.
2623 wind_speed_model : string
2724 Parameter to define which model to use to calculate the wind speed at
2825 hub height. Valid options are 'logarithmic', 'hellman' and
@@ -42,6 +39,9 @@ class ModelChain(object):
4239 density_correction : boolean
4340 If the parameter is True the density corrected power curve is used for
4441 the calculation of the turbine power output. Default: False.
42+ obstacle_height : float
43+ Height of obstacles in the surrounding area of the wind turbine in m.
44+ Set `obstacle_height` to zero for wide spread obstacles. Default: 0.
4545 hellman_exp : float
4646 The Hellman exponent, which combines the increase in wind speed due to
4747 stability of atmospheric conditions and surface roughness into one
@@ -52,9 +52,6 @@ class ModelChain(object):
5252 wind_turbine : WindTurbine
5353 A :class:`~.wind_turbine.WindTurbine` object representing the wind
5454 turbine.
55- obstacle_height : float
56- Height of obstacles in the surrounding area of the wind turbine in m.
57- Set `obstacle_height` to zero for wide spread obstacles. Default: 0.
5855 wind_speed_model : string
5956 Parameter to define which model to use to calculate the wind speed at
6057 hub height. Valid options are 'logarithmic', 'hellman' and
@@ -78,6 +75,9 @@ class ModelChain(object):
7875 The Hellman exponent, which combines the increase in wind speed due to
7976 stability of atmospheric conditions and surface roughness into one
8077 constant. Default: None.
78+ obstacle_height : float
79+ Height of obstacles in the surrounding area of the wind turbine in m.
80+ Set `obstacle_height` to zero for wide spread obstacles. Default: 0.
8181 power_output : pandas.Series
8282 Electrical power output of the wind turbine in W.
8383
@@ -98,12 +98,12 @@ class ModelChain(object):
9898 """
9999
100100 def __init__ (self , wind_turbine ,
101- obstacle_height = 0 ,
102101 wind_speed_model = 'logarithmic' ,
103102 temperature_model = 'linear_gradient' ,
104103 density_model = 'barometric' ,
105104 power_output_model = 'power_curve' ,
106105 density_correction = False ,
106+ obstacle_height = 0 ,
107107 hellman_exp = None ):
108108
109109 self .wind_turbine = wind_turbine
@@ -145,29 +145,28 @@ def temperature_hub(self, weather_df):
145145 temperature(s) closest to the hub height are used.
146146
147147 """
148- try :
148+ if self . wind_turbine . hub_height in weather_df [ 'temperature' ] :
149149 temperature_hub = weather_df ['temperature' ][
150150 self .wind_turbine .hub_height ]
151- except :
152- if self .temperature_model == 'linear_gradient' :
153- logging .debug ('Calculating temperature using temperature '
154- 'gradient.' )
155- closest_height = weather_df ['temperature' ].columns [
156- min (range (len (weather_df ['temperature' ].columns )),
157- key = lambda i : abs (weather_df ['temperature' ].columns [i ] -
158- self .wind_turbine .hub_height ))]
159- temperature_hub = temperature .linear_gradient (
160- weather_df ['temperature' ][closest_height ], closest_height ,
161- self .wind_turbine .hub_height )
162- elif self .temperature_model == 'interpolation_extrapolation' :
163- logging .debug ('Calculating temperature using linear inter- or '
164- 'extrapolation.' )
165- temperature_hub = tools .linear_interpolation_extrapolation (
166- weather_df ['temperature' ], self .wind_turbine .hub_height )
167- else :
168- raise ValueError ("'{0}' is an invalid value. " .format (
169- self .temperature_model ) + "`temperature_model` must be "
170- "'linear_gradient' or 'interpolation_extrapolation'." )
151+ elif self .temperature_model == 'linear_gradient' :
152+ logging .debug ('Calculating temperature using temperature '
153+ 'gradient.' )
154+ closest_height = weather_df ['temperature' ].columns [
155+ min (range (len (weather_df ['temperature' ].columns )),
156+ key = lambda i : abs (weather_df ['temperature' ].columns [i ] -
157+ self .wind_turbine .hub_height ))]
158+ temperature_hub = temperature .linear_gradient (
159+ weather_df ['temperature' ][closest_height ], closest_height ,
160+ self .wind_turbine .hub_height )
161+ elif self .temperature_model == 'interpolation_extrapolation' :
162+ logging .debug ('Calculating temperature using linear inter- or '
163+ 'extrapolation.' )
164+ temperature_hub = tools .linear_interpolation_extrapolation (
165+ weather_df ['temperature' ], self .wind_turbine .hub_height )
166+ else :
167+ raise ValueError ("'{0}' is an invalid value. " .format (
168+ self .temperature_model ) + "`temperature_model` must be "
169+ "'linear_gradient' or 'interpolation_extrapolation'." )
171170 return temperature_hub
172171
173172 def density_hub (self , weather_df ):
@@ -269,43 +268,42 @@ def wind_speed_hub(self, weather_df):
269268 wind speed(s) closest to the hub height are used.
270269
271270 """
272- try :
271+ if self . wind_turbine . hub_height in weather_df [ 'wind_speed' ] :
273272 wind_speed_hub = weather_df ['wind_speed' ][
274273 self .wind_turbine .hub_height ]
275- except :
276- if self .wind_speed_model == 'logarithmic' :
277- logging .debug ('Calculating wind speed using logarithmic wind '
278- 'profile.' )
279- closest_height = weather_df ['wind_speed' ].columns [
280- min (range (len (weather_df ['wind_speed' ].columns )),
281- key = lambda i : abs (weather_df ['wind_speed' ].columns [i ] -
282- self .wind_turbine .hub_height ))]
283- wind_speed_hub = wind_speed .logarithmic_profile (
284- weather_df ['wind_speed' ][closest_height ], closest_height ,
285- self .wind_turbine .hub_height ,
286- weather_df ['roughness_length' ].ix [:, 0 ],
287- self .obstacle_height )
288- elif self .wind_speed_model == 'hellman' :
289- logging .debug ('Calculating wind speed using hellman equation.' )
290- closest_height = weather_df ['wind_speed' ].columns [
291- min (range (len (weather_df ['wind_speed' ].columns )),
292- key = lambda i : abs (weather_df ['wind_speed' ].columns [i ] -
293- self .wind_turbine .hub_height ))]
294- wind_speed_hub = wind_speed .hellman (
295- weather_df ['wind_speed' ][closest_height ], closest_height ,
296- self .wind_turbine .hub_height ,
297- weather_df ['roughness_length' ].ix [:, 0 ],
298- self .hellman_exp )
299- elif self .wind_speed_model == 'interpolation_extrapolation' :
300- logging .debug ('Calculating wind speed using linear inter- or '
301- 'extrapolation.' )
302- wind_speed_hub = tools .linear_interpolation_extrapolation (
303- weather_df ['wind_speed' ], self .wind_turbine .hub_height )
304- else :
305- raise ValueError ("'{0}' is an invalid value. " .format (
306- self .wind_speed_model ) + "`wind_speed_model` must be "
307- "'logarithmic', 'hellman' or "
308- "'interpolation_extrapolation'." )
274+ elif self .wind_speed_model == 'logarithmic' :
275+ logging .debug ('Calculating wind speed using logarithmic wind '
276+ 'profile.' )
277+ closest_height = weather_df ['wind_speed' ].columns [
278+ min (range (len (weather_df ['wind_speed' ].columns )),
279+ key = lambda i : abs (weather_df ['wind_speed' ].columns [i ] -
280+ self .wind_turbine .hub_height ))]
281+ wind_speed_hub = wind_speed .logarithmic_profile (
282+ weather_df ['wind_speed' ][closest_height ], closest_height ,
283+ self .wind_turbine .hub_height ,
284+ weather_df ['roughness_length' ].ix [:, 0 ],
285+ self .obstacle_height )
286+ elif self .wind_speed_model == 'hellman' :
287+ logging .debug ('Calculating wind speed using hellman equation.' )
288+ closest_height = weather_df ['wind_speed' ].columns [
289+ min (range (len (weather_df ['wind_speed' ].columns )),
290+ key = lambda i : abs (weather_df ['wind_speed' ].columns [i ] -
291+ self .wind_turbine .hub_height ))]
292+ wind_speed_hub = wind_speed .hellman (
293+ weather_df ['wind_speed' ][closest_height ], closest_height ,
294+ self .wind_turbine .hub_height ,
295+ weather_df ['roughness_length' ].ix [:, 0 ],
296+ self .hellman_exp )
297+ elif self .wind_speed_model == 'interpolation_extrapolation' :
298+ logging .debug ('Calculating wind speed using linear inter- or '
299+ 'extrapolation.' )
300+ wind_speed_hub = tools .linear_interpolation_extrapolation (
301+ weather_df ['wind_speed' ], self .wind_turbine .hub_height )
302+ else :
303+ raise ValueError ("'{0}' is an invalid value. " .format (
304+ self .wind_speed_model ) + "`wind_speed_model` must be "
305+ "'logarithmic', 'hellman' or "
306+ "'interpolation_extrapolation'." )
309307 return wind_speed_hub
310308
311309 def turbine_power_output (self , wind_speed_hub , density_hub ):
@@ -347,7 +345,8 @@ def turbine_power_output(self, wind_speed_hub, density_hub):
347345 'curve.' )
348346 return (power_output .power_coefficient_curve (
349347 wind_speed_hub ,
350- self .wind_turbine .power_coefficient_curve ['wind_speed' ],
348+ self .wind_turbine .power_coefficient_curve [
349+ 'wind_speed' ],
351350 self .wind_turbine .power_coefficient_curve ['values' ],
352351 self .wind_turbine .rotor_diameter , density_hub ,
353352 self .density_correction ))
0 commit comments