Commit 3412bb06 authored by Sebastian Lenz's avatar Sebastian Lenz 💻

added another NLS variant for using the whole selection

parent aaeabf45
No preview for this file type
......@@ -252,7 +252,7 @@ function ddT2_Callback(hObject, eventdata, handles)
delay = get(handles.ddT2, 'value');
spec = reshape(handles.data_fit_full(delay,:,:),[handles.sizex,handles.sizey])';
contourf(handles.probe_axis, handles.pump_axis, spec, 12);
contourf(handles.probe_axis, handles.pump_axis, spec, linspace(min(min(spec)),max(max(spec)), 25) );
hold on;
lsa_colormap_rwb3D;
colorbar;
......@@ -427,6 +427,8 @@ switch popup_sel_index
selMethod = '2DG';
case 8
selMethod = 'NLS';
case 9
selMethod = 'NLSbox';
otherwise
selMethod = 'ivCLS';
end
......@@ -448,15 +450,15 @@ end
err = false;
warning('off','all')
try
%try
plotdata = lsa_performFit(selMethod,handles.data_fit_full,delayrange,handles.xrange,handles.yrange,handles.probe_axis,handles.pump_axis,handles.actual_delays,get(handles.ddExp, 'value'),weighted,get(handles.cbCenter,'Value'),[logFit,logParts]);
catch e
fprintf(2,'The identifier was:\n%s\n',e.identifier);
fprintf(2,'There was an error! The message was:\n%s\n',e.message);
plotdata = [];
errordlg('Something went wrong with the fit!','Fit error!','modal');
err = true;
end
%catch e
% fprintf(2,'The identifier was:\n%s\n',e.identifier);
% fprintf(2,'There was an error! The message was:\n%s\n',e.message);
% plotdata = [];
% errordlg('Something went wrong with the fit!','Fit error!','modal');
% err = true;
%end
warning('on','all')
if logFit ~= -1
......
......@@ -2,7 +2,7 @@
% Author: Sebastian Lenz
%
function [mdl,slicedats,slices] = lsa_NLS(spec, xrange, yrange, probe_range, pump_range)
function [mdl,slicedats,slices] = lsa_NLS(spec, xrange, yrange, probe_range, pump_range, constraint)
ind = 1:size(yrange,2);
slicemdls = cell(1, size(yrange,2));
......@@ -16,7 +16,11 @@ function [mdl,slicedats,slices] = lsa_NLS(spec, xrange, yrange, probe_range, pum
param = [0,(Pmax-Pmin)/2,(pi)/(probe_range(Imin)-probe_range(Imax)),0.1];
modelfun = @(b,x)b(1)+b(2).*sin(b(3).*x+b(4));
slicemdl = NonLinearModel.fit(probe_range(Imax:Imin), y(:,Imax:Imin), modelfun, param);
if constraint
slicemdl = NonLinearModel.fit(probe_range(Imax:Imin), y(:,Imax:Imin), modelfun, param);
else
slicemdl = NonLinearModel.fit(probe_range, y, modelfun, param);
end
slices = [slices;spec(yrange(row),:)];
slicedats{1,row} = slicemdl;
zerofun = @(x)modelfun(slicemdl.Coefficients.Estimate,x);
......
......@@ -374,7 +374,13 @@ function [plotdata] = lsa_performFit(type,spectra,delayrange,xrange,yrange,probe
end
end
case 'NLS'
case {'NLS', 'NLSbox'}
if type == "NLSbox"
constraint = false;
else
disp('blubb')
constraint = true;
end
if logParts
fprintf(logfids(2),"Fit type: NLS\n");
fprintf(logfids(2),"This log shows fit models for every slice at every delay time\n\n");
......@@ -389,7 +395,7 @@ function [plotdata] = lsa_performFit(type,spectra,delayrange,xrange,yrange,probe
wgt = zeros(length,1);
for delay = 1:length
spec = reshape(spectra(delayrange(delay),:,:),[sizex,sizey])';
[mdl,slicedats,slices] = lsa_NLS(spec, xrange, yrange, probe_range, pump_range);
[mdl,slicedats,slices] = lsa_NLS(spec, xrange, yrange, probe_range, pump_range, constraint);
corrs(delay) = mdl.Coefficients.Estimate(2);
errs(delay) = mdl.Coefficients.SE(2);
......
......@@ -377,7 +377,7 @@ switch handles.plotdata.type
surf(handles.axPart,handles.probe_range,handles.pump_range,spec(handles.plotdata.yrange,handles.plotdata.xrange),'FaceAlpha',0.5);
surf(handles.axPart,handles.probe_range,handles.pump_range,handles.plotdata.debugplots(delay).gauss(handles.plotdata.yrange,handles.plotdata.xrange),'FaceColor','red','FaceAlpha',0.5);
case 'NLS'
case {'NLS', 'NLSbox'}
h = scatter(handles.axSpec, handles.plotdata.debugplots(delay).centers,handles.pump_range,'Marker','o','MarkerEdgeColor',[.75 0 .75],'MarkerFaceColor',[.75 0 .75]);
set(h, 'SizeData',8);
ypred = handles.plotdata.debugplots(delay).line(handles.plotdata.pump_axis);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment