#NEWLINE# def add_roi( self , name = '' , left = 0 , right = 0 , bgr_width = 3 , counts = None , sort = True , to_mcas = True ) : #NEWLINE# #INDENT# 'add an ROI to the sum spectra' #NEWLINE# name = name . strip ( ) #NEWLINE# roi = ROI ( name = name , left = left , right = right , bgr_width = bgr_width , counts = counts ) #NEWLINE# rnames = [ r . name . lower ( ) for r in self . rois ] #NEWLINE# if ( name . lower ( ) in rnames ) : #NEWLINE# #INDENT# iroi = rnames . index ( name . lower ( ) ) #NEWLINE# self . rois [ iroi ] = roi #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . rois . append ( roi ) #NEWLINE# #UNINDENT# if sort : #NEWLINE# #INDENT# self . rois . sort ( ) #NEWLINE# #UNINDENT# if to_mcas : #NEWLINE# #INDENT# mca0 = self . __get_mca0 ( ) #NEWLINE# slo0 = mca0 . slope #NEWLINE# off0 = mca0 . offset #NEWLINE# mca0 . add_roi ( name = name , left = left , right = right , bgr_width = bgr_width ) #NEWLINE# for mca in self . mcas : #NEWLINE# #INDENT# if ( mca != mca0 ) : #NEWLINE# #INDENT# xleft = int ( ( 0.5 + ( ( ( off0 + ( left * slo0 ) ) - mca . offset ) / mca . slope ) ) ) #NEWLINE# xright = int ( ( 0.5 + ( ( ( off0 + ( right * slo0 ) ) - mca . offset ) / mca . slope ) ) ) #NEWLINE# mca . add_roi ( name = name , left = xleft , right = xright , bgr_width = bgr_width )