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)
| 761 | |
| 762 | |
| 763 | def 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 | |
| 793 | def fit_pixel_per_file_no_multi(dir_path, file_prefix, fileID, param, interpath, save_spectrum=True): |
nothing calls this directly
no test coverage detected