|
10 | 10 |
|
11 | 11 | import logging |
12 | 12 | from windpowerlib import wind_speed, density, power_output, tools |
13 | | - |
| 13 | +import pandas as pd |
14 | 14 |
|
15 | 15 | class ModelChain(object): |
16 | 16 | r"""Model to determine the output of a wind turbine |
@@ -136,13 +136,17 @@ def rho_hub(self, weather, data_height): |
136 | 136 | if 'temp_air_2' not in weather: |
137 | 137 | weather['temp_air_2'] = None |
138 | 138 | data_height['temp_air_2'] = None |
139 | | - # Select temperature closer to hub height using smallest_difference() |
140 | | - values = tools.smallest_difference( |
141 | | - data_height['temp_air'], data_height['temp_air_2'], |
142 | | - self.wind_turbine.hub_height, weather['temp_air'], |
143 | | - weather['temp_air_2']) |
144 | | - temp_air_height = values[0] |
145 | | - temp_air_closest = values[1] |
| 139 | + temp_air_height = data_height['temp_air'] |
| 140 | + temp_air_closest = weather['temp_air'] |
| 141 | + else: |
| 142 | + # Select temperature closer to hub height using |
| 143 | + # smallest_difference() |
| 144 | + temp_air_height, temp_air_closest = tools.smallest_difference( |
| 145 | + pd.DataFrame(data={'temp_air': [weather['temp_air'], |
| 146 | + weather['temp_air_2']]}, |
| 147 | + index=[data_height['temp_air'], |
| 148 | + data_height['temp_air_2']]), |
| 149 | + self.wind_turbine.hub_height, 'temp_air') |
146 | 150 | # Check if temperature data is at hub height. |
147 | 151 | if temp_air_height == self.wind_turbine.hub_height: |
148 | 152 | logging.debug('Using given temperature at hub height.') |
@@ -204,13 +208,16 @@ def v_wind_hub(self, weather, data_height): |
204 | 208 | if 'v_wind_2' not in weather: |
205 | 209 | weather['v_wind_2'] = None |
206 | 210 | data_height['v_wind_2'] = None |
207 | | - # Select wind speed closer to hub height using smallest_difference() |
208 | | - values = tools.smallest_difference( |
209 | | - data_height['v_wind'], data_height['v_wind_2'], |
210 | | - self.wind_turbine.hub_height, weather['v_wind'], |
211 | | - weather['v_wind_2']) |
212 | | - v_wind_height = values[0] |
213 | | - v_wind_closest = values[1] |
| 211 | + v_wind_height = data_height['v_wind'] |
| 212 | + v_wind_closest = weather['v_wind'] |
| 213 | + else: |
| 214 | + # Select wind speed closer to hub height using smallest_difference() |
| 215 | + v_wind_height, v_wind_closest = tools.smallest_difference( |
| 216 | + pd.DataFrame(data={'v_wind': [weather['v_wind'], |
| 217 | + weather['v_wind_2']]}, |
| 218 | + index=[data_height['v_wind'], |
| 219 | + data_height['v_wind_2']]), |
| 220 | + self.wind_turbine.hub_height, 'v_wind') |
214 | 221 | # Check if wind speed data is at hub height. |
215 | 222 | if v_wind_height == self.wind_turbine.hub_height: |
216 | 223 | logging.debug('Using given wind speed at hub height.') |
|
0 commit comments