Skip to content

Commit 8199005

Browse files
committed
Raise error if 'temp_air_2' not in weather
1 parent 784a8ff commit 8199005

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

windpowerlib/modelchain.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,15 @@ def rho_hub(self, weather, data_height):
162162
weather['temp_air'], data_height['temp_air'],
163163
self.wind_turbine.hub_height)
164164
elif self.temperature_model == 'interpolation':
165-
logging.debug('Calculating temperature using interpolation.')
166-
temp_hub = density.temperature_interpol(
167-
weather['temp_air'], weather['temp_air_2'],
168-
data_height['temp_air'], data_height['temp_air_2'],
169-
self.wind_turbine.hub_height)
165+
try:
166+
logging.debug('Calculating temperature using interpolation.')
167+
temp_hub = density.temperature_interpol(
168+
weather['temp_air'], weather['temp_air_2'],
169+
data_height['temp_air'], data_height['temp_air_2'],
170+
self.wind_turbine.hub_height)
171+
except TypeError:
172+
raise KeyError("No 'temp_air_2' in `weather`, but needed " +
173+
"for interpolation.")
170174
else:
171175
raise ValueError("'{0}' is an invalid value.".format(
172176
self.temperature_model) + "`temperature_model` " +

0 commit comments

Comments
 (0)