#NEWLINE# def spectralFlux( spectra , rectify = False ) : #NEWLINE# #INDENT# '\n    Compute the spectral flux between consecutive spectra\n    ' #NEWLINE# spectralFlux = [ ] #NEWLINE# flux = 0 #NEWLINE# for bin in spectra [ 0 ] : #NEWLINE# #INDENT# flux = ( flux + abs ( bin ) ) #NEWLINE# #UNINDENT# spectralFlux . append ( flux ) #NEWLINE# for s in range ( 1 , len ( spectra ) ) : #NEWLINE# #INDENT# prevSpectrum = spectra [ ( s - 1 ) ] #NEWLINE# spectrum = spectra [ s ] #NEWLINE# flux = 0 #NEWLINE# for bin in range ( 0 , len ( spectrum ) ) : #NEWLINE# #INDENT# diff = ( abs ( spectrum [ bin ] ) - abs ( prevSpectrum [ bin ] ) ) #NEWLINE# if ( rectify and ( diff < 0 ) ) : #NEWLINE# #INDENT# diff = 0 #NEWLINE# #UNINDENT# flux = ( flux + diff ) #NEWLINE# #UNINDENT# spectralFlux . append ( flux ) #NEWLINE# #UNINDENT# return spectralFlux