Files
nappMATLAB-toolbox/beamtime/documentedExampleScripts/gaussFit.m
T

59 lines
2.6 KiB
Matlab
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
%% Fitting spectra with Gauss
%
% The nappFitGaussXps.m allows to set-up your own model reflecting the
% physics of your peaks. Here is an example. Check the documentation. This
% needs some test-and try.
%% SES #0157 Ar2p (gas-phase reference)
%
% * Core level: Ar 2p, file 0157157_Ar2p_850eV.
% * Model: Gaussian spin–orbit doublet, splitting fixed at 2.2 eV, area ratio 0.5.
% * Peak 1 area: initial 1e5; lower bound 10; upper bound Inf.
% * Peak 1 width: initial 0.5 eV; bounds 0.5–3 eV.
% * Peak 1 position: initial 603 eV; bounds 602–604 eV.
% * Background: linear, 8 eV window below and 5 eV above the peak.
clc
close all
tmpDataSelection = month(FileList.lastModifiedDatenum) == 11 ...
& year(FileList.lastModifiedDatenum) == 2025 ...
& ~contains(FileList.sample,"(bad data)") ...
& ~contains(FileList.name,"Survey") ...
& ~contains(FileList.name,"Resonant") ...
& startsWith(FileList.name,"0157") ...
& contains(FileList.name, "Ar2p");
FileList = nappGenerateSpectra(FileList,tmpDataSelection);
disp(FileList(tmpDataSelection,{'name','lastModifiedDatestr','scientaPassEnergy_eV'}))
% Defining the mode as 'widthPositionAreaRatio', the first element of the input
% parameters defines the first peak (initial value, upper and lower bond for
% fitting) in absolute terms. The second element is then the area ratio
% relative to the first, and the position relative to the first.
tmpFitParameters.peakArea = [1e5 0.5 0.1 0.1 0.1] ;
tmpFitParameters.peakWidth = 0.5;
tmpFitParameters.peakPos = [603 -2.2 10 10 10];
tmpFitParameters.peakAreaUpperBond = [Inf 0.5 0.1 0.1 0.1];
tmpFitParameters.peakWidthUpperBond = [3 NaN NaN NaN NaN];
tmpFitParameters.peakPosUpperBond = [604 -2.2 10 10 10];
tmpFitParameters.peakAreaLowerBond = [10 0.5 0.1 0.1 0.1];
tmpFitParameters.peakWidthLowerBond = [0.5 NaN NaN NaN NaN];
tmpFitParameters.peakPosLowerBond = [602 -2.2 0.1 0.1 0.1];
% spectrum range
tmpFitParameters.backgroundRange = [8 5];
FileList= nappFitGaussXps(FileList,tmpFitParameters,tmpDataSelection,...
'energyScale','kinetic','mode','widthPositionAreaRatio','showFigures','on');
%% RESULTS – SES 0157 Ar2p (gas-phase reference)
% The gas‑phase Ar2p reference is well described by the doublet: peak 1 at
% 603.0 eV and peak 2 at 600.8 eV (FWHM ≈ 1.2 eV, width 1.0 eV) match both
% the height and the base of the experimental lines. The residuals are very small and essentially
% structureless over the full fit range, indicating that, in contrast to
% the Cl2p fits, a simple Gaussian doublet provides an excellent and
% internally consistent description of the Ar2p line shape.