Bugfixes to the fitting of the radial spectral distribution.

This commit is contained in:
Karthik 2025-10-17 10:53:18 +02:00
parent 195191d5f1
commit 36d57e5973
7 changed files with 12 additions and 14 deletions

View File

@ -86,7 +86,7 @@ function [fitResults, rawCurves] = fitTwoGaussianCurvesToRadialSpectralDistribut
sigma2_guess = 0.1 * kSecondary;
p0 = [A1_guess, mu1_guess, sigma1_guess, A2_guess, mu2_guess, sigma2_guess];
else
p0 = [opts.AmplitudeRange(2), 0, 0.1, 0.01, opts.KRhoRange(2)/3, 0.1];
p0 = [opts.AmplitudeRange(2), 0, 0.1, 0.001, opts.KRhoRange(2)/2, 0.1];
end
lb = [0, 0, 1e-6, 0, opts.PositionThreshold, 1e-6];
@ -95,7 +95,7 @@ function [fitResults, rawCurves] = fitTwoGaussianCurvesToRadialSpectralDistribut
'MaxFunctionEvaluations',1e4,'MaxIterations',1e4);
pFit = lsqcurvefit(twoGauss, p0, kVals(:), x(:), lb, ub, optsLSQ);
if pFit(4) <= 1e-3
if pFit(4) <= 1e-4
pFit(4) = 0;
pFit(5:6) = NaN;
end

View File

@ -203,8 +203,6 @@ function runInteractiveASDTwoGaussianFitGUI(spectral_analysis_results)
end
end
set(gca, 'YScale', 'log');
title(hAx,sprintf('Curve %d / %d', idx, Ncurves),'FontSize',16);
legend(hAx,'Location','northeast','FontSize',14);
hold(hAx,'off');

View File

@ -32,7 +32,7 @@ function runInteractiveRSDTwoGaussianFitGUI(spectral_analysis_results)
% Default fit parameters
params.KRhoRange = [0, 3];
params.AmplitudeRange = [0, 0.5];
params.AmplitudeRange = [0, 0.3];
params.ResidualThreshold = 0.15;
params.PositionThreshold = 0.5;
params.AmplitudeThreshold = 0.015;

View File

@ -117,7 +117,7 @@ Plotter.plotSpectralCurves( ...
spectral_analysis_results.S_k_all, ... % radial spectral curves
spectral_analysis_results.k_rho_vals, ... % corresponding k_rho values
'KRhoRange', [0, 3], ... % truncate curves to 0 <= k_rho <= 3
'AmplitudeRange', [0, 0.5], ... % truncate curves to y >= 0 (all amplitudes)
'AmplitudeRange', [0, 0.3], ... % truncate curves to y >= 0 (all amplitudes)
'ResidualThreshold', 0.15, ... % maximum allowed residual
'PositionThreshold', 0.5, ... % minimum separation between peaks
'AmplitudeThreshold', 0.015); % minimum secondary peak fraction
@ -149,7 +149,7 @@ Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'A2', ...
'NormalizeHistogram', true, ...
'Colormap', @Colormaps.coolwarm, ...
'XLim', [min(scan_reference_values), max(scan_reference_values)], ...
'YLim', [0, 0.06]);
'YLim', [0, 0.025]);
%% ------------------ 4. Plot fit parameters - position ------------------
Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'mu2', ...
@ -167,7 +167,7 @@ Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'mu2', ...
'NormalizeHistogram', true, ...
'Colormap', @Colormaps.coolwarm, ...
'XLim', [min(scan_reference_values), max(scan_reference_values)], ...
'YLim', [1, 2]);
'YLim', [0, 3]);
%% ------------------ 5. Plot fit parameters - width ------------------
Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'sigma2', ...
'Title', options.titleString, ...

View File

@ -149,7 +149,7 @@ Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'A2', ...
'NormalizeHistogram', true, ...
'Colormap', @Colormaps.coolwarm, ...
'XLim', [min(scan_reference_values), max(scan_reference_values)], ...
'YLim', [0, 0.025]);
'YLim', [0, 0.055]);
%% ------------------ 4. Plot fit parameters - position ------------------
Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'mu2', ...
@ -167,7 +167,7 @@ Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'mu2', ...
'NormalizeHistogram', true, ...
'Colormap', @Colormaps.coolwarm, ...
'XLim', [min(scan_reference_values), max(scan_reference_values)], ...
'YLim', [1, 2]);
'YLim', [0, 2]);
%% ------------------ 5. Plot fit parameters - width ------------------
Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'sigma2', ...
'Title', options.titleString, ...

View File

@ -149,7 +149,7 @@ Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'A2', ...
'NormalizeHistogram', true, ...
'Colormap', @Colormaps.coolwarm, ...
'XLim', [min(scan_reference_values), max(scan_reference_values)], ...
'YLim', [0, 0.06]);
'YLim', [0, 0.025]);
%% ------------------ 4. Plot fit parameters - position ------------------
Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'mu2', ...
@ -167,7 +167,7 @@ Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'mu2', ...
'NormalizeHistogram', true, ...
'Colormap', @Colormaps.coolwarm, ...
'XLim', [min(scan_reference_values), max(scan_reference_values)], ...
'YLim', [1, 2]);
'YLim', [0, 2]);
%% ------------------ 5. Plot fit parameters - width ------------------
Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'sigma2', ...
'Title', options.titleString, ...

View File

@ -149,7 +149,7 @@ Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'A2', ...
'NormalizeHistogram', true, ...
'Colormap', @Colormaps.coolwarm, ...
'XLim', [min(scan_reference_values), max(scan_reference_values)], ...
'YLim', [0, 0.06]);
'YLim', [0, 0.055]);
%% ------------------ 4. Plot fit parameters - position ------------------
Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'mu2', ...
@ -167,7 +167,7 @@ Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'mu2', ...
'NormalizeHistogram', true, ...
'Colormap', @Colormaps.coolwarm, ...
'XLim', [min(scan_reference_values), max(scan_reference_values)], ...
'YLim', [1, 2]);
'YLim', [0, 2]);
%% ------------------ 5. Plot fit parameters - width ------------------
Plotter.plotFitParameterPDF(fitResults, scan_reference_values, 'sigma2', ...
'Title', options.titleString, ...