Skip to content

Commit 0cb1e37

Browse files
committed
Add comments
1 parent 29a1d7f commit 0cb1e37

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

windpowerlib/tools.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ def smallest_difference(data_frame, comp_value, column_name):
4040
as float, pd.Series or np.array.
4141
4242
"""
43+
# Calculate difference to comp_value for all indices of data_frame
4344
diff = []
4445
for index in sorted(data_frame.index):
4546
diff.append(abs(comp_value - index))
47+
# Find smallest difference
4648
closest_value = sorted(data_frame.index)[diff.index(min(diff))]
4749
corresp_value = data_frame[column_name][closest_value]
4850
return (closest_value, corresp_value)
@@ -92,11 +94,14 @@ def linear_extra_interpolation(data_frame, requested_height, column_name):
9294
place
9395
9496
"""
97+
# Get closest index of data_frame to requested_height
9598
height_2, value_2 = smallest_difference(data_frame, requested_height,
9699
column_name)
100+
# Drop row with closest index to requested_height and get second closest
97101
data_frame_2 = data_frame.drop(height_2)
98102
height_1, value_1 = smallest_difference(data_frame_2, requested_height,
99103
column_name)
104+
# Interpolation
100105
interpolant = ((value_2 - value_1) / (height_2 - height_1) *
101106
(requested_height - height_1) + value_1)
102107
return interpolant

0 commit comments

Comments
 (0)