diff --git a/beamtime/nappFitGaussXps.m b/beamtime/nappFitGaussXps.m index ec505a7..2929179 100644 --- a/beamtime/nappFitGaussXps.m +++ b/beamtime/nappFitGaussXps.m @@ -577,7 +577,7 @@ expectedTableVariable = {'spectrum_counts','spectrum_countsPerSecond','spe defaultMode = 'widthPosition'; expectedMode = {'unconstrained','widthPosition','position','width','widthPositionShirley', ... 'positionShirley','widthShirley','unconstrainedAndWidthPosition','gasAndTwoAcidBasePairs',... - 'widthPositionAreaRatio','widthPositionAmineAreaRatio','TwoSpinOrbitDoublet','TwoSpinOrbitDoubletPseudoVoigtShirley'}; + 'widthPositionAreaRatio','widthPositionAmineAreaRatio','TwoSpinOrbitDoublet','TwoSpinOrbitDoubletPseudoVoigtShirley','GasAndSurfaceSpinOrbitDoublet'}; defaultTableSelection = true(size(DataTable,1),1); defaultShowFigures = 'on'; expectedShowFigures = {'on','off'}; @@ -1771,6 +1771,54 @@ for iuz = 1 initialParameterVector = [initialParameterVector, 0, 0]; lowerBoundsParameterVector = [lowerBoundsParameterVector, -Inf, -Inf]; upperBoundsParameterVector = [upperBoundsParameterVector, Inf, Inf]; + elseif matches(p.Results.mode,'GasAndSurfaceSpinOrbitDoublet') + %% GasAndSurfaceSpinOrbitDoublet + + modelDefinitionFunction = @(currentParameterVector,energyValues)... + gaussPeak(energyValues, currentParameterVector(1),currentParameterVector(2), currentParameterVector(3)) ... % Gauss peak 1 + + gaussPeak(energyValues, currentParameterVector(1)*FitParameter.peakArea(1,2), currentParameterVector(2), currentParameterVector(3)+FitParameter.peakPos(1,2))... % Gauss peak 2 + + gaussPeak(energyValues, currentParameterVector(4),currentParameterVector(5), currentParameterVector(6))... % Gauss peak 3 + + gaussPeak(energyValues, currentParameterVector(4)*FitParameter.peakArea(1,4),currentParameterVector(5),currentParameterVector(6)+FitParameter.peakPos(1,4)) ... % Gauss peak 4 + + linearBackground(energyValues,currentParameterVector(7), currentParameterVector(8)); + + initialParameterVector = []; + lowerBoundsParameterVector = []; + upperBoundsParameterVector = []; + + % #1: Area 1 + initialParameterVector = [initialParameterVector, FitParameter.peakArea(1, 1)]; + lowerBoundsParameterVector = [lowerBoundsParameterVector, FitParameter.peakAreaLowerBound(1, 1)]; + upperBoundsParameterVector = [upperBoundsParameterVector, FitParameter.peakAreaUpperBound(1, 1)]; + + % #2: Width 1+2 + initialParameterVector = [initialParameterVector, FitParameter.peakWidth(1, 1)]; + lowerBoundsParameterVector = [lowerBoundsParameterVector, FitParameter.peakWidthLowerBound(1, 1)]; + upperBoundsParameterVector = [upperBoundsParameterVector, FitParameter.peakWidthUpperBound(1, 1)]; + + % #3: Pos 1 + initialParameterVector = [initialParameterVector, FitParameter.peakPos(1, 1)]; + lowerBoundsParameterVector = [lowerBoundsParameterVector, FitParameter.peakPosLowerBound(1, 1)]; + upperBoundsParameterVector = [upperBoundsParameterVector, FitParameter.peakPosUpperBound(1, 1)]; + + % #4: Area 3 + initialParameterVector = [initialParameterVector, FitParameter.peakArea(1, 3)]; + lowerBoundsParameterVector = [lowerBoundsParameterVector, FitParameter.peakAreaLowerBound(1, 3)]; + upperBoundsParameterVector = [upperBoundsParameterVector, FitParameter.peakAreaUpperBound(1, 3)]; + + % #5: Width 3+4 + initialParameterVector = [initialParameterVector, FitParameter.peakWidth(1, 2)]; + lowerBoundsParameterVector = [lowerBoundsParameterVector, FitParameter.peakWidthLowerBound(1, 1)]; + upperBoundsParameterVector = [upperBoundsParameterVector, FitParameter.peakWidthUpperBound(1, 1)]; + + % #6 Pos 3 + initialParameterVector = [initialParameterVector, FitParameter.peakPos(1, 3)]; + lowerBoundsParameterVector = [lowerBoundsParameterVector, FitParameter.peakPosLowerBound(1, 3)]; + upperBoundsParameterVector = [upperBoundsParameterVector, FitParameter.peakPosUpperBound(1, 3)]; + + % #7 & #8 Background: slope, intercept + initialParameterVector = [initialParameterVector, 0, 0]; + lowerBoundsParameterVector = [lowerBoundsParameterVector, -Inf, -Inf]; + upperBoundsParameterVector = [upperBoundsParameterVector, Inf, Inf]; elseif matches(p.Results.mode,'TwoSpinOrbitDoubletPseudoVoigtShirley') %% TwoSpinOrbitDoubletPseudoVoigtShirley @@ -2543,7 +2591,7 @@ for iii= 1 pos3 = currentParameterVector(3)+currentParameterVector(5); area4 = currentParameterVector(4)*FitParameter.peakArea(1,2); width4 = currentParameterVector(2); - pos4 = currentParameterVector(3)+currentParameterVector(5)++FitParameter.peakPos(1,2); + pos4 = currentParameterVector(3)+currentParameterVector(5)+FitParameter.peakPos(1,2); slope = currentParameterVector(6); intercept = currentParameterVector(7); @@ -2555,6 +2603,34 @@ for iii= 1 % Background resultsBkgrd = [slope, intercept]; + elseif matches(p.Results.mode, 'GasAndSurfaceSpinOrbitDoublet') + %% GasAndSurfaceSpinOrbitDoublet + % ===== GAUSSIAN + LINEAR ===== + + % Extract parameters + area1 = currentParameterVector(1); + width1 = currentParameterVector(2); + pos1 = currentParameterVector(3); + area2 = currentParameterVector(1)*FitParameter.peakArea(1,2); + width2 = currentParameterVector(2); + pos2 = currentParameterVector(3)+FitParameter.peakPos(1,2); + area3 = currentParameterVector(4); + width3 = currentParameterVector(5); + pos3 = currentParameterVector(6); + area4 = currentParameterVector(4)*FitParameter.peakArea(1,4); + width4 = currentParameterVector(5); + pos4 = currentParameterVector(6)+FitParameter.peakPos(1,4); + slope = currentParameterVector(7); + intercept = currentParameterVector(8); + + % Results: areas, positions, FWHM + resultsPeakArea = [area1, area2, area3, area4]; + resultsPeakPos = [pos1, pos2, pos3, pos4]; + resultsPeakFWHM = [width1, width2, width3, width4]; + + % Background + resultsBkgrd = [slope, intercept]; + elseif matches(p.Results.mode, 'TwoSpinOrbitDoubletPseudoVoigtShirley') %% TwoSpinOrbitDoubletPseudoVoigtShirley % ===== PSEUDO-VOIGT + SHIRLEY ===== @@ -2571,7 +2647,7 @@ for iii= 1 pos3 = currentParameterVector(3)+currentParameterVector(5); area4 = currentParameterVector(4)*FitParameter.peakArea(1,2); width4 = currentParameterVector(2); - pos4 = currentParameterVector(3)+currentParameterVector(5)++FitParameter.peakPos(1,2); + pos4 = currentParameterVector(3)+currentParameterVector(5)+FitParameter.peakPos(1,2); % Results: areas, positions, FWHM resultsPeakArea = [area1, area2, area3, area4]; @@ -2797,14 +2873,20 @@ end %% Print Results if matches(p.Results.showFigures,'on') - disp(DataTable(p.Results.tableSelection,["name","peakPosition","peakArea","peakFWHM"])) + disp(DataTable(p.Results.tableSelection,["name","peakPosition"])) + disp(DataTable(p.Results.tableSelection,["name","peakArea"])) + disp(DataTable(p.Results.tableSelection,["name","peakFWHM"])) disp(DataTable(p.Results.tableSelection,["name","peakBackground"])) try - disp(DataTable(p.Results.tableSelection,["name","peakEta",])) + if ~isnan(DataTable(p.Results.tableSelection,:).peakEta(1)) + disp(DataTable(p.Results.tableSelection,["name","peakEta",])) + end catch end try - disp(DataTable(p.Results.tableSelection,["name","peakShirleyK"])) + if ~isnan(DataTable(p.Results.tableSelection,:).peakShirleyK(1)) + disp(DataTable(p.Results.tableSelection,["name","peakShirleyK"])) + end catch end