def setup_element_model(self, elemental_line, default_area=1e5):

        incident_energy = self.incident_energy
        parameter = self.params

        all_element_mod = None
        # global parameters
        param_hints_to_copy = ['e_offset', 'e_linear', 'e_quadratic',
                               'fwhm_offset', 'fwhm_fanoprime']

        if elemental_line in K_LINE:
            element = elemental_line.split('_')[0]
            e = Element(element)
            if e.cs(incident_energy)['ka1'] == 0:
                logger.debug('%s Ka emission line is not activated '
                             'at this energy %f', element, incident_energy)
                return

            logger.debug(' --- Started building %s peak. ---', element)

            for num, item in enumerate(e.emission_line.all[:4]):
                line_name = item[0]
                val = item[1]

                if e.cs(incident_energy)[line_name] == 0:
                    continue

                element_mod = ElementModel(prefix=str(element)+'_'+str(line_name)+'_')

                # copy the fixed parameters from the Compton model
                _copy_model_param_hints(element_mod, self.compton_param,
                                        param_hints_to_copy)

                element_mod.set_param_hint('epsilon', value=self.epsilon,
                                         vary=False)

                area_name = str(element)+'_'+str(line_name)+'_area'
                if area_name in parameter:
                    default_area = parameter[area_name]['value']

                if line_name == 'ka1':
                    element_mod.set_param_hint('area', value=default_area, vary=True, min=0)
                    element_mod.set_param_hint('delta_center', value=0, vary=False)
                    element_mod.set_param_hint('delta_sigma', value=0, vary=False)
                elif line_name == 'ka2':
                    element_mod.set_param_hint('area', value=default_area, vary=True,
                                             expr=str(element)+'_ka1_'+'area')
                    element_mod.set_param_hint('delta_sigma', value=0, vary=False,
                                             expr=str(element)+'_ka1_'+'delta_sigma')
                    element_mod.set_param_hint('delta_center', value=0, vary=False,
                                             expr=str(element)+'_ka1_'+'delta_center')
                else:
                    element_mod.set_param_hint('area', value=default_area, vary=True,
                                             expr=str(element)+'_ka1_'+'area')
                    element_mod.set_param_hint('delta_center', value=0, vary=False)
                    element_mod.set_param_hint('delta_sigma', value=0, vary=False)

                # area needs to be adjusted
                if area_name in parameter:
                    _set_parameter_hint(area_name, parameter[area_name], element_mod)

                element_mod.set_param_hint('center', value=val, vary=False)
                ratio_v = e.cs(incident_energy)[line_name]/e.cs(incident_energy)['ka1']
                element_mod.set_param_hint('ratio', value=ratio_v, vary=False)
                element_mod.set_param_hint('ratio_adjust', value=1, vary=False)
                logger.debug(' {0} {1} peak is at energy {2} with'
                             ' branching ratio {3}.'. format(element, line_name, val, ratio_v))

                # position needs to be adjusted
                pos_name = element + '_' + str(line_name)+'_delta_center'
                if pos_name in parameter:
                    _set_parameter_hint('delta_center', parameter[pos_name],
                                        element_mod)

                # width needs to be adjusted
                width_name = element + '_' + str(line_name)+'_delta_sigma'
                if width_name in parameter:
                    _set_parameter_hint('delta_sigma', parameter[width_name],
                                        element_mod)

                # branching ratio needs to be adjusted
                ratio_name = element + '_' + str(line_name) + '_ratio_adjust'
                if ratio_name in parameter:
                    _set_parameter_hint('ratio_adjust', parameter[ratio_name],
                                        element_mod)

                if all_element_mod:
                    all_element_mod += element_mod
                else:
                    all_element_mod = element_mod
            logger.debug('Finished building element peak for %s', element)

        elif elemental_line in L_LINE:
            element = elemental_line.split('_')[0]
            e = Element(element)
            if e.cs(incident_energy)['la1'] == 0:
                logger.debug('{0} La1 emission line is not activated '
                             'at this energy {1}'.format(element,
                                                         incident_energy))
                return

            for num, item in enumerate(e.emission_line.all[4:-4]):

                line_name = item[0]
                val = item[1]

                if e.cs(incident_energy)[line_name] == 0:
                    continue

                element_mod = ElementModel(prefix=str(element)+'_'+str(line_name)+'_')

                # copy the fixed parameters from the Compton model
                _copy_model_param_hints(element_mod, self.compton_param,
                                        param_hints_to_copy)

                element_mod.set_param_hint('epsilon', value=self.epsilon, vary=False)

                area_name = str(element)+'_'+str(line_name)+'_area'
                if area_name in parameter:
                    default_area = parameter[area_name]['value']

                if line_name == 'la1':
                    element_mod.set_param_hint('area', value=default_area, vary=True)
                else:
                    element_mod.set_param_hint('area', value=default_area, vary=True,
                                             expr=str(element)+'_la1_'+'area')

                # area needs to be adjusted
                if area_name in parameter:
                    _set_parameter_hint(area_name, parameter[area_name], element_mod)

                element_mod.set_param_hint('center', value=val, vary=False)
                element_mod.set_param_hint('sigma', value=1, vary=False)
                element_mod.set_param_hint('ratio',
                                         value=e.cs(incident_energy)[line_name]/e.cs(incident_energy)['la1'],
                                         vary=False)

                element_mod.set_param_hint('delta_center', value=0, vary=False)
                element_mod.set_param_hint('delta_sigma', value=0, vary=False)
                element_mod.set_param_hint('ratio_adjust', value=1, vary=False)

                # position needs to be adjusted
                pos_name = element+'_'+str(line_name)+'_delta_center'
                if pos_name in parameter:
                    _set_parameter_hint('delta_center', parameter[pos_name],
                                        element_mod)

                # width needs to be adjusted
                width_name = element+'_'+str(line_name)+'_delta_sigma'
                if width_name in parameter:
                    _set_parameter_hint('delta_sigma', parameter[width_name],
                                        element_mod)

                # branching ratio needs to be adjusted
                ratio_name = element+'_'+str(line_name)+'_ratio_adjust'
                if ratio_name in parameter:
                    _set_parameter_hint('ratio_adjust', parameter[ratio_name],
                                        element_mod)
                if all_element_mod:
                    all_element_mod += element_mod
                else:
                    all_element_mod = element_mod

        elif elemental_line in M_LINE:
            element = elemental_line.split('_')[0]
            e = Element(element)
            if e.cs(incident_energy)['ma1'] == 0:
                logger.debug('{0} ma1 emission line is not activated '
                             'at this energy {1}'.format(element, incident_energy))
                return

            for num, item in enumerate(e.emission_line.all[-4:]):

                line_name = item[0]
                val = item[1]

                if e.cs(incident_energy)[line_name] == 0:
                    continue

                element_mod = ElementModel(prefix=str(element)+'_'+str(line_name)+'_')

                # copy the fixed parameters from the Compton model
                _copy_model_param_hints(element_mod, self.compton_param,
                                        param_hints_to_copy)

                element_mod.set_param_hint('epsilon', value=self.epsilon, vary=False)

                area_name = str(element)+'_'+str(line_name)+'_area'
                if area_name in parameter:
                    default_area = parameter[area_name]['value']

                if line_name == 'ma1':
                    element_mod.set_param_hint('area', value=default_area, vary=True)
                else:
                    element_mod.set_param_hint('area', value=default_area, vary=True,
                                             expr=str(element)+'_ma1_'+'area')

                # area needs to be adjusted
                if area_name in parameter:
                    _set_parameter_hint(area_name, parameter[area_name], element_mod)

                element_mod.set_param_hint('center', value=val, vary=False)
                element_mod.set_param_hint('sigma', value=1, vary=False)
                element_mod.set_param_hint('ratio',
                                         value=e.cs(incident_energy)[line_name]/e.cs(incident_energy)['ma1'],
                                         vary=False)

                element_mod.set_param_hint('delta_center', value=0, vary=False)
                element_mod.set_param_hint('delta_sigma', value=0, vary=False)
                element_mod.set_param_hint('ratio_adjust', value=1, vary=False)

                if area_name in parameter:
                    _set_parameter_hint(area_name, parameter[area_name], element_mod)

                # position needs to be adjusted
                pos_name = element+'_'+str(line_name)+'_delta_center'
                if pos_name in parameter:
                    _set_parameter_hint('delta_center', parameter[pos_name],
                                        element_mod)

                # width needs to be adjusted
                width_name = element+'_'+str(line_name)+'_delta_sigma'
                if width_name in parameter:
                    _set_parameter_hint('delta_sigma', parameter[width_name],
                                        element_mod)

                # branching ratio needs to be adjusted
                ratio_name = element+'_'+str(line_name)+'_ratio_adjust'
                if ratio_name in parameter:
                    _set_parameter_hint('ratio_adjust', parameter[ratio_name],
                                        element_mod)

                if all_element_mod:
                    all_element_mod += element_mod
                else:
                    all_element_mod = element_mod

        elif 'user' in elemental_line.lower(): #user peak
            logger.debug('Started setting up user peak: {}'.format(
                elemental_line))

            e_cen = 5  # user peak is set 5 keV every time, this value is not important

            pre_name = elemental_line + '_'
            element_mod = ElementModel(prefix=pre_name)

            # copy the fixed parameters from the Compton model
            _copy_model_param_hints(element_mod, self.compton_param,
                                    param_hints_to_copy)

            element_mod.set_param_hint('epsilon', value=self.epsilon, vary=False)

            area_name = pre_name + 'area'
            if area_name in parameter:
                default_area = parameter[area_name]['value']

            element_mod.set_param_hint('area', value=default_area, vary=True, min=0)
            element_mod.set_param_hint('delta_center', value=0, vary=False)
            element_mod.set_param_hint('delta_sigma', value=0, vary=False)
            element_mod.set_param_hint('center', value=e_cen, vary=False)
            element_mod.set_param_hint('ratio', value=1.0, vary=False)
            element_mod.set_param_hint('ratio_adjust', value=1, vary=False)

            # area needs to be adjusted
            if area_name in parameter:
                _set_parameter_hint(area_name, parameter[area_name], element_mod)

            # position needs to be adjusted
            pos_name = pre_name + 'delta_center'
            if pos_name in parameter:
                _set_parameter_hint('delta_center', parameter[pos_name],
                                    element_mod)

            # width needs to be adjusted
            width_name = pre_name + 'delta_sigma'
            if width_name in parameter:
                _set_parameter_hint('delta_sigma', parameter[width_name],
                                    element_mod)

            # branching ratio needs to be adjusted
            ratio_name = pre_name + 'ratio_adjust'
            if ratio_name in parameter:
                _set_parameter_hint('ratio_adjust', parameter[ratio_name],
                                    element_mod)

            all_element_mod = element_mod

        else:
            logger.debug('Started setting up pileup peaks for {}'.format(
                elemental_line))

            element_line1, element_line2 = elemental_line.split('-')

            e1_cen = get_line_energy(element_line1)
            e2_cen = get_line_energy(element_line2)

            # no '-' allowed in prefix name in lmfit
            pre_name = 'pileup_' + elemental_line.replace('-', '_') + '_'
            element_mod = ElementModel(prefix=pre_name)

            # copy the fixed parameters from the Compton model
            _copy_model_param_hints(element_mod, self.compton_param,
                                    param_hints_to_copy)

            element_mod.set_param_hint('epsilon', value=self.epsilon, vary=False)

            area_name = pre_name + 'area'
            if area_name in self.params:
                default_area = self.params[area_name]['value']

            element_mod.set_param_hint('area', value=default_area, vary=True, min=0)
            element_mod.set_param_hint('delta_center', value=0, vary=False)
            element_mod.set_param_hint('delta_sigma', value=0, vary=False)

            # area needs to be adjusted
            if area_name in self.params:
                _set_parameter_hint(area_name, self.params[area_name], element_mod)

            element_mod.set_param_hint('center', value=e1_cen+e2_cen, vary=False)
            element_mod.set_param_hint('ratio', value=1.0, vary=False)
            element_mod.set_param_hint('ratio_adjust', value=1, vary=False)

            # position needs to be adjusted
            pos_name = pre_name + 'delta_center'
            if pos_name in self.params:
                _set_parameter_hint('delta_center', self.params[pos_name],
                                    element_mod)

            # width needs to be adjusted
            width_name = pre_name + 'delta_sigma'
            if width_name in self.params:
                _set_parameter_hint('delta_sigma', self.params[width_name],
                                    element_mod)

            # branching ratio needs to be adjusted
            ratio_name = pre_name + 'ratio_adjust'
            if ratio_name in self.params:
                _set_parameter_hint('ratio_adjust', self.params[ratio_name],
                                    element_mod)

            all_element_mod = element_mod
        return all_element_mod
Validates the data given in value.
dataset/ETHPy150Open scikit-beam/scikit-beam/skbeam/core/fitting/xrf_model.py/ModelSpectrum.setup_element_model--crossover with--dataset/ETHPy150Open rwl/muntjac/muntjac/data/validators/null_validator.py/NullValidator.validate