Skip to content

Commit c743574

Browse files
committed
Delete parameter from smallest_difference() in tools
1 parent fc7935c commit c743574

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

windpowerlib/modelchain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def rho_hub(self, weather, data_height):
158158
temp_air_closest = values.corresp_value
159159
# Check if temperature data is at hub height.
160160
if temp_air_height == self.wind_turbine.hub_height:
161-
logging.debug('Using given temperature ' + values.logging_string)
161+
logging.debug('Using given temperature at hub height.')
162162
temp_hub = temp_air_closest
163163
# Calculation of temperature in K at hub height.
164164
elif self.temperature_model == 'gradient':
@@ -236,7 +236,7 @@ def v_wind_hub(self, weather, data_height):
236236
v_wind_closest = values.corresp_value
237237
# Check if wind speed data is at hub height.
238238
if v_wind_height == self.wind_turbine.hub_height:
239-
logging.debug('Using given wind speed ' + values.logging_string)
239+
logging.debug('Using given wind speed at hub height.')
240240
v_wind = v_wind_closest
241241
# Calculation of wind speed in m/s at hub height.
242242
elif self.wind_model == 'logarithmic':

windpowerlib/tools.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,17 @@ def smallest_difference(value_1, value_2, comp_value, corresp_1, corresp_2):
3737
3838
Returns
3939
-------
40-
Tuple(float, float, string)
41-
Value closer to comparing value as float, corresponding value as
42-
float and a string for logging.debug.
40+
Tuple(float, float,)
41+
Value closer to comparing value as float and its corresponding value as
42+
float.
4343
"""
4444
if (value_2 is not None and corresp_2 is not None):
45-
if value_1 == comp_value:
45+
if abs(value_1 - comp_value) <= abs(value_2 - comp_value):
4646
closest_value = value_1
47-
logging_string = '(at hub height).'
48-
elif value_2 == comp_value:
49-
closest_value = value_2
50-
logging_string = '(2) (at hub height).'
51-
elif abs(value_1 - comp_value) <= abs(value_2 - comp_value):
52-
closest_value = value_1
53-
logging_string = None
5447
else:
5548
closest_value = value_2
56-
logging_string = None
5749
else:
5850
closest_value = value_1
59-
logging_string = None
60-
if value_1 == comp_value:
61-
logging_string = '(at hub height).'
6251

6352
# Select correponding value
6453
if closest_value == value_1:
@@ -68,5 +57,5 @@ def smallest_difference(value_1, value_2, comp_value, corresp_1, corresp_2):
6857
# Store values in a named tuple
6958
return_tuple = collections.namedtuple('selected_values',
7059
['closest_value',
71-
'corresp_value', 'logging_string'])
72-
return return_tuple(closest_value, corresp_value, logging_string)
60+
'corresp_value'])
61+
return return_tuple(closest_value, corresp_value)

0 commit comments

Comments
 (0)