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

Function fit_each_pixel_with_nnls

pyxrf/model/command_tools.py:763–790  ·  view source on GitHub ↗

Fit a spectrum with a linear model. Parameters ---------- data : array spectrum intensity param : dict fitting parameters elemental_lines : list, optional e.g., ['Na_K', Mg_K', 'Pt_M'] refers to the K lines of Sodium, the K lines of M

(data, params, elemental_lines=None, incident_energy=None, weights=None)

Source from the content-addressed store, hash-verified

761
762
763def fit_each_pixel_with_nnls(data, params, elemental_lines=None, incident_energy=None, weights=None):
764 """
765 Fit a spectrum with a linear model.
766
767 Parameters
768 ----------
769 data : array
770 spectrum intensity
771 param : dict
772 fitting parameters
773 elemental_lines : list, optional
774 e.g., ['Na_K', Mg_K', 'Pt_M'] refers to the
775 K lines of Sodium, the K lines of Magnesium, and the M
776 lines of Platinum. If elemental_lines is set as None,
777 all the possible lines activated at given energy will be used.
778 """
779 param = copy.deepcopy(params)
780 if incident_energy is not None:
781 param["coherent_sct_amplitude"]["value"] = incident_energy
782 # cut data into proper range
783 low = param["non_fitting_values"]["energy_bound_low"]["value"]
784 high = param["non_fitting_values"]["energy_bound_high"]["value"]
785 a0 = param["e_offset"]["value"]
786 a1 = param["e_linear"]["value"]
787 x, y = define_range(data, low, high, a0, a1)
788 # pixel fitting
789 _, result_dict, area_dict = linear_spectrum_fitting(x, y, elemental_lines=elemental_lines, weights=weights)
790 return result_dict
791
792
793def fit_pixel_per_file_no_multi(dir_path, file_prefix, fileID, param, interpath, save_spectrum=True):

Callers

nothing calls this directly

Calls 1

define_rangeFunction · 0.85

Tested by

no test coverage detected