#NEWLINE# def get_slopes( self ) : #NEWLINE# #INDENT# 'Compute slopes by reach using values in strtop (streambed top) and rchlen (reach length)\n        columns of reach_data. The slope for a reach n is computed as strtop(n+1) - strtop(n) / rchlen(n).\n        Slopes for outlet reaches are assumed to be equal to slope of previous reach. ' #NEWLINE# slopes = ( np . append ( np . diff ( self . reach_data . strtop ) , 0 ) / self . reach_data . rchlen ) #NEWLINE# last_reaches = np . append ( ( np . diff ( self . reach_data . iseg ) == 1 ) , True ) #NEWLINE# last_reach_data = self . reach_data [ last_reaches ] #NEWLINE# last_reaches_outreach_elevs = [ ( self . reach_data . strtop [ ( o - 1 ) ] if ( o != 0 ) else 0 ) for o in last_reach_data . outreach ] #NEWLINE# second_to_last_reaches = np . append ( last_reaches [ 1 : ] , False ) #NEWLINE# slopes [ last_reaches ] = [ ( slopes [ second_to_last_reaches ] [ i ] if ( last_reaches_outreach_elevs [ i ] == 0 ) else ( ( last_reaches_outreach_elevs [ i ] - last_reach_data . strtop [ i ] ) / last_reach_data . rchlen [ i ] ) ) for i in range ( len ( last_reach_data ) ) ] #NEWLINE# self . reach_data [ 'slope' ] = ( slopes * ( - 1 ) )