MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / modify_peak_height

Method modify_peak_height

pyxrf/model/parameters.py:735–769  ·  view source on GitHub ↗

Modify the height of the emission line. Parameters ---------- new_maxv: float New maximum value for the emission line `self.e_name`

(self, maxv_new)

Source from the content-addressed store, hash-verified

733 return {"key_area": key_area, "key_dcenter": key_dcenter, "key_dsigma": key_dsigma}
734
735 def modify_peak_height(self, maxv_new):
736 """
737 Modify the height of the emission line.
738
739 Parameters
740 ----------
741 new_maxv: float
742 New maximum value for the emission line `self.e_name`
743 """
744
745 ignored_peaks = {"escape"}
746 if self.e_name in ignored_peaks:
747 msg = f"Height of the '{self.e_name}' peak can not be changed."
748 raise RuntimeError(msg)
749
750 if self.e_name not in self.EC.element_dict:
751 msg = (
752 f"Attempt to modify maximum value for the emission line '{self.e_name},'\n"
753 f"which is not currently selected."
754 )
755 raise RuntimeError(msg)
756
757 key = self._generate_param_keys(self.e_name)["key_area"]
758 maxv_current = self.EC.element_dict[self.e_name].maxv
759
760 coef = maxv_new / maxv_current if maxv_current > 0 else 0
761 # Only 'maxv' needs to be updated.
762 self.EC.element_dict[self.e_name].maxv = maxv_new
763 # The following function updates 'spectrum', 'area' and 'norm'.
764 self.EC.update_peak_ratio()
765
766 # Some of the parameters are represented only in EC, not in 'self.param_new'.
767 # (particularly "background" and "elastic")
768 if key:
769 self.param_new[key]["value"] *= coef
770
771 def _compute_fwhm_base(self, energy):
772 # Computes 'sigma' value based on default parameters and peak energy (for Userpeaks)

Callers 1

Calls 2

_generate_param_keysMethod · 0.95
update_peak_ratioMethod · 0.80

Tested by

no test coverage detected