#NEWLINE# def add_param( self , kind , element , constraint = None ) : #NEWLINE# #INDENT# '\n        Create a Parameter controlling peak position, width,\n        branching ratio, or area.\n\n        Parameters\n        ----------\n        kind : {\'pos\', \'width\', \'ratio\', \'area\'}\n        element : str\n            element name\n        constraint : {\'lo\', \'hi\', \'lohi\', \'fixed\', \'none\'}, optional\n            default "bound strategy" (fitting constraints)\n\n        .. note:: Element that can be add include elemental peak, pileup peak and user peak.\n        User peak is a fake peak, but can be used as a quick replacement for pileup peaks,\n        escape peaks or other unknown peaks due to detector defects or scattering process.\n        ' #NEWLINE# if ( element not in self . element_list ) : #NEWLINE# #INDENT# self . element_list . append ( element ) #NEWLINE# self . element_linenames . extend ( get_activated_lines ( self . params [ 'coherent_sct_energy' ] [ 'value' ] , [ element ] ) ) #NEWLINE# #UNINDENT# if ( kind == 'area' ) : #NEWLINE# #INDENT# return self . _add_area_param ( element , constraint ) #NEWLINE# #UNINDENT# PARAM_SUFFIXES = { #NEWLINE# #INDENT# 'pos' : 'delta_center' , #NEWLINE# 'width' : 'delta_sigma' , #NEWLINE# 'ratio' : 'ratio_adjust' , #NEWLINE# #UNINDENT# } #NEWLINE# param_suffix = PARAM_SUFFIXES [ kind ] #NEWLINE# if ( len ( element ) <= 4 ) : #NEWLINE# #INDENT# ( element , line ) = element . split ( '_' ) #NEWLINE# transitions = TRANSITIONS_LOOKUP [ line ] #NEWLINE# linenames = [ '{0}_{1}' . format ( element , t ) for t in new_pos ] #NEWLINE# for linename in linenames : #NEWLINE# #INDENT# if ( linename not in self . element_linenames ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# param_name = '_' . join ( ( str ( linename ) , param_suffix ) ) #NEWLINE# new_pos = PARAM_DEFAULTS [ kind ] . copy ( ) #NEWLINE# if ( constraint is not None ) : #NEWLINE# #INDENT# self . _element_strategy [ param_name ] = constraint #NEWLINE# #UNINDENT# self . params . update ( { #NEWLINE# #INDENT# param_name : new_pos , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'user' in element . lower ( ) ) : #NEWLINE# #INDENT# param_name = '_' . join ( ( element , param_suffix ) ) #NEWLINE# new_pos = PARAM_DEFAULTS [ kind ] . copy ( ) #NEWLINE# if ( constraint is not None ) : #NEWLINE# #INDENT# self . _element_strategy [ param_name ] = constraint #NEWLINE# #UNINDENT# self . params . update ( { #NEWLINE# #INDENT# param_name : new_pos , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# linename = ( 'pileup_' + element . replace ( '-' , '_' ) ) #NEWLINE# param_name = ( linename + param_suffix ) #NEWLINE# new_pos = PARAM_DEFAULTS [ kind ] . copy ( ) #NEWLINE# if ( constraint is not None ) : #NEWLINE# #INDENT# self . _element_strategy [ param_name ] = constraint #NEWLINE# #UNINDENT# self . params . update ( { #NEWLINE# #INDENT# param_name : new_pos , #NEWLINE# #UNINDENT# } )