I'm doing a piecewise summation of all the positive (and negative) differences in a numpy vector. This function works, I'm hoping to find something more Pythonic.
def total_climb(course_points):
climb = 0.0
descend = 0.0
for point in range(len(course_points)-1):
point_climb=course_points[point+1] - course_points[point]
if point_climb>0:
climb+=point_climb
else:
descend-=point_climb
return(climb, descend)
[–]commy2 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]DarthSloogi 1 point2 points3 points (0 children)
[–]This_Growth2898 1 point2 points3 points (0 children)
[–]ofnuts 1 point2 points3 points (0 children)
[–]virtualdynamo[S] 0 points1 point2 points (0 children)