#NEWLINE# def CalculateAverageMaxHR( act , startWpt = None , endWpt = None ) : #NEWLINE# #INDENT# flatWaypoints = act . GetFlatWaypoints ( ) #NEWLINE# maxHR = 0 #NEWLINE# cumulHR = 0 #NEWLINE# samples = 0 #NEWLINE# if ( not startWpt ) : #NEWLINE# #INDENT# startWpt = flatWaypoints [ 0 ] #NEWLINE# #UNINDENT# if ( not endWpt ) : #NEWLINE# #INDENT# endWpt = flatWaypoints [ ( - 1 ) ] #NEWLINE# #UNINDENT# for x in range ( flatWaypoints . index ( startWpt ) , ( flatWaypoints . index ( endWpt ) + 1 ) ) : #NEWLINE# #INDENT# wpt = flatWaypoints [ x ] #NEWLINE# if wpt . HR : #NEWLINE# #INDENT# if ( wpt . HR > maxHR ) : #NEWLINE# #INDENT# maxHR = wpt . HR #NEWLINE# #UNINDENT# cumulHR += wpt . HR #NEWLINE# samples += 1 #NEWLINE# #UNINDENT# #UNINDENT# if ( not samples ) : #NEWLINE# #INDENT# return ( None , None ) #NEWLINE# #UNINDENT# cumulHR = ( cumulHR / samples ) #NEWLINE# return ( x , maxHR )