Skip to content
Merged
10 changes: 5 additions & 5 deletions 3rdParty/mcmcstat/%runDram.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
%Make uniform priors from the
%min/max limits for now.
prior = {};
lims = problemDef.fitconstr;
lims = problemDef.fitLimits;
% Get the li

for i = 1:length(fitNames)
name = fitNames{i};
value = problemDef.fitpars(i);
value = problemDef.fitParams(i);
min = lims(i,1);
max = lims(i,2);
mu = 0;
Expand Down Expand Up @@ -65,7 +65,7 @@
bayesResults.bestFits = output.bestFits;
bayesResults.predlims = output.predlims;

problemDef.fitpars = output.bestPars;
problemDef.fitParams = output.bestPars;
problemDef = unpackParams(problemDef,controls);
[problem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);

Expand All @@ -78,8 +78,8 @@
coder.varsize('problem.bulkOut',[Inf 1],[1 0]);
coder.varsize('problem.resolutionParams',[Inf 1],[1 0]);
coder.varsize('problem.ssubs',[Inf 1],[1 0]);
coder.varsize('problem.calculations.all_chis',[Inf 1],[1 0]);
coder.varsize('problem.calculations.sum_chi',[1 1],[0 0]);
coder.varsize('problem.calculations.allChis',[Inf 1],[1 0]);
coder.varsize('problem.calculations.sumChi',[1 1],[0 0]);
coder.varsize('problem.allSubRough',[Inf 1],[1 0]);

%Result coder definitions....
Expand Down
4 changes: 2 additions & 2 deletions 3rdParty/mcmcstat/refModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
% We need to reverse this correction, and actually return the simulation
% corrected for the scalefactor. We have to do this because the scalefactor
% is in itself one of our fitting parameters (no need to correct the data -
% problem.shifted_data contains the corrected data, but
% problem.shiftedData contains the corrected data, but
% problem.data is a record of the original).

if isempty(varargin)
Expand Down Expand Up @@ -35,7 +35,7 @@
problemDefLimits = problem{3};
problemDefCells = problem{4};

problemDef.fitpars = pars;
problemDef.fitParams = pars;
problemDef = unpackParams(problemDef,controls);
[problem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);

Expand Down
6 changes: 3 additions & 3 deletions 3rdParty/mcmcstat/refModel_scaled.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
% We need to reverse this correction, and actually return the simulation
% corrected for the scalefactor. We have to do this because the scalefactor
% is in itself one of our fitting parameters (no need to correct the data -
% problem.shifted_data contains the corrected data, but
% problem.shiftedData contains the corrected data, but
% problem.data is a record of the original). Also, in this version the
% input parameters are scaled, so they need to be unscaled befor the
% calculation
Expand Down Expand Up @@ -39,10 +39,10 @@
problemDefCells = problem{4};

pars = theta;
constr = problemDef.fitconstr;
constr = problemDef.fitLimits;
pars = unscalePars(pars,constr);

problemDef.fitpars = pars;
problemDef.fitParams = pars;
problemDef = unpackParams(problemDef,controls);
[problem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);

Expand Down
4 changes: 2 additions & 2 deletions 3rdParty/mcmcstat/reflectivity_fitModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
problemDefCells = problem{4};


problemDef.fitpars = pars;
problemDef.fitParams = pars;
problemDef = unpackParams(problemDef,controls);
%setappdata(0,'problem',problem);
%problem = reflectivityCalculation(problem);
[problemDef,result] = reflectivityCalculation(problemDef,problemDefCells,controls);

%problem = getappdata(0,'problem');
ss = problemDef.calculations.sum_chi;
ss = problemDef.calculations.sumChi;

end

6 changes: 3 additions & 3 deletions 3rdParty/mcmcstat/reflectivity_fitModel_scaled.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
problemDefCells = problem{4};

pars = theta; % Current parameter values from mcmcstat
constr = problemDef.fitconstr;
constr = problemDef.fitLimits;
pars = unscalePars(pars,constr);

problemDef.fitpars = pars;
problemDef.fitParams = pars;
problemDef = unpackParams(problemDef,controls);
%setappdata(0,'problem',problem);
%problem = reflectivityCalculation(problem);
[problemDef,result] = reflectivityCalculation(problemDef,problemDefCells,controls);

%problem = getappdata(0,'problem');
ss = problemDef.calculations.sum_chi;
ss = problemDef.calculations.sumChi;

end

6 changes: 3 additions & 3 deletions 3rdParty/mcmcstat/runBayes.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

% Make qcov based on the ranges of the parameters
qcov = [];
fitPars = problemDef.fitpars;
fitConstr = problemDef.fitconstr;
fitPars = problemDef.fitParams;
fitConstr = problemDef.fitLimits;
nPars = length(fitPars);

for i = 1:nPars
Expand Down Expand Up @@ -89,7 +89,7 @@
% out = mcmcpred_compile(results,chain,[],data,problem,500);
% outSld = mcmcpred_compile_sld(results,chain,[],data,problem,500);
%
% problemDef.fitpars = output.bestPars;
% problemDef.fitParams = output.bestPars;
% problemDef = unpackParams(problemDef,controls);
% [problem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
%
Expand Down
14 changes: 7 additions & 7 deletions 3rdParty/mcmcstat/runDram.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

%First deal with priors.
prior = {};
lims = problemDef.fitconstr;
lims = problemDef.fitLimits;

% Preallocate params array to keep the compiler happy
params = cell(length(fitNames),1);
Expand Down Expand Up @@ -117,7 +117,7 @@
for i = 1:length(fitNames)
coder.varsize('name',[1 Inf],[0 1]);
name = fitNames{i};
value = problemDef.fitpars(i);
value = problemDef.fitParams(i);
min = lims(i,1);
max = lims(i,2);

Expand Down Expand Up @@ -155,7 +155,7 @@

[problemDef,outProblem,result,bayesResults] = processBayes(output,problem);

% problemDef.fitpars = bayesResults.bestPars_Mean;
% problemDef.fitParams = bayesResults.bestPars_Mean;


% Post processing of Bayes
Expand All @@ -170,20 +170,20 @@
% bestPars_mean = output.results.mean;
%
% % Calulate Max best fit curves
% problemDef.fitpars = bestPars_max;
% problemDef.fitParams = bestPars_max;
% problemDef = unpackParams(problemDef,controls);
% [outProblem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
% bestFitMax_Ref = result(1);
% bestFitMax_Sld = result(5);
% bestFitMax_chi = outProblem.calculations.sum_chi;
% bestFitMax_chi = outProblem.calculations.sumChi;
%
% % Calculate 'mean' best fit curves
% problemDef.fitpars = bestPars_mean;
% problemDef.fitParams = bestPars_mean;
% problemDef = unpackParams(problemDef,controls);
% [outProblem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
% bestFitMean_Ref = result(1);
% bestFitMean_Sld = result(5);
% bestFitMean_chi = outProblem.calculations.sum_chi;
% bestFitMean_chi = outProblem.calculations.sumChi;
%
% % 2. Reflectivity and SLD shading
% predIntRef = mcmcpred_compile(output.results,output.chain,[],output.data,problem,500);
Expand Down
2 changes: 1 addition & 1 deletion 3rdParty/mcmcstat/sldModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
problemDefCells = problem{4};
controls.calcSldDuringFit = true;

problemDef.fitpars = pars;
problemDef.fitParams = pars;
problemDef = unpackParams(problemDef,controls);
[~,result] = reflectivityCalculation(problemDef,problemDefCells,controls);

Expand Down
6 changes: 3 additions & 3 deletions 3rdParty/paramonte/pmLogFunction.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
function logFuncVal = get(obj,pars)

problem = obj.problemDef;
problem.fitpars = pars;
problem.fitParams = pars;

if obj.scaled
problem = unscalePars(problem);
Expand All @@ -26,7 +26,7 @@
problem = unpackParams(problem,obj.controls);

[outProblem,~] = reflectivityCalculation_mex(problem,obj.problemDefCells,obj.controls);
chi = outProblem.calculations.sum_chi;
chi = outProblem.calculations.sumChi;
logFuncVal = -chi/2;

% Check to catch any strange NaNs
Expand All @@ -37,7 +37,7 @@
% Now apply the priors where necessary.
priorfun = @(th,mu,sig) sum(((th-mu)./sig).^2);

val = priorfun(problem.fitpars,obj.priors(:,1),obj.priors(:,2));
val = priorfun(problem.fitParams,obj.priors(:,1),obj.priors(:,2));

logFuncVal = logFuncVal + val;

Expand Down
6 changes: 3 additions & 3 deletions 3rdParty/paramonte/processParamonteRuns.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
% only take last part of chain...
scaledChain = chain((end-npoints):end,:);

limits = problemDef.fitconstr;
limits = problemDef.fitLimits;
rows = size(scaledChain,1);

for i = 1:rows
Expand All @@ -49,8 +49,8 @@

result = parseResultToStruct(outProblemStruct,result);

if isfield(problemDef,'fitpars')
result.bestFitPars = problemDef.fitpars;
if isfield(problemDef,'fitParams')
result.bestFitPars = problemDef.fitParams;
end

result = mergeStructs(result,bayesResults);
Expand Down
12 changes: 6 additions & 6 deletions 3rdParty/paramonte/runParamonte.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
logFunc = pmLogFunction();

[problemDef,fitNames,fitPriors] = packParamsPriors(problemDef,problemDefCells,problemDefLimits,priors,controls.checks);
nDims = length(problemDef.fitpars);
testPars = problemDef.fitpars;
nDims = length(problemDef.fitParams);
testPars = problemDef.fitParams;

% Scale the parameters
problemDef = scalePars(problemDef);
Expand Down Expand Up @@ -56,7 +56,7 @@
% if isfield(pmPars,'stVec')
% pmpd.spec.startPointVec = pmPars.stVec;
% else
% pmpd.spec.startPointVec = problemDef.fitpars; % Maybe dependent on scaling?
% pmpd.spec.startPointVec = problemDef.fitParams; % Maybe dependent on scaling?
% end

% if isfield(pmPars,'burninAdapt')
Expand All @@ -70,8 +70,8 @@
name = pmPars.name;
pmpd.reportEnabled = false;
pmpd.spec.outputFileName = sprintf("./paramonte_out/%s",name);%,datestr(now,30));
pmpd.spec.domainLowerLimitVec = scaledMins;%problemDef.fitconstr(:,1);
pmpd.spec.domainUpperLimitVec = scaledMaxs;%problemDef.fitconstr(:,2);
pmpd.spec.domainLowerLimitVec = scaledMins;%problemDef.fitLimits(:,1);
pmpd.spec.domainUpperLimitVec = scaledMaxs;%problemDef.fitLimits(:,2);
pmpd.spec.overwriteRequested = true;
pmpd.spec.scaleFactor = pmPars.scalefactor; %1e-4;
pmpd.spec.sampleRefinementCount = pmPars.chainSize;
Expand Down Expand Up @@ -101,7 +101,7 @@
% % Get out the chain, and unscale it.....
% scaledChain = chainTable{2:end,8:end};
%
% limits = problemDef.fitconstr;
% limits = problemDef.fitLimits;
% rows = size(scaledChain,1);
%
% for i = 1:rows
Expand Down
6 changes: 3 additions & 3 deletions 3rdParty/paramonte/scalePars.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function problem = scalePars(problem)

limits = problem.fitconstr;
vals = problem.fitpars;
limits = problem.fitLimits;
vals = problem.fitParams;

scaled = (vals(:) - limits(:,1))./(limits(:,2)-limits(:,1));

problem.fitpars = scaled;
problem.fitParams = scaled;
%problem.unscaledPars = vals;

end
6 changes: 3 additions & 3 deletions 3rdParty/paramonte/unscalePars.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
function problem = unscalePars(problem)

limits = problem.fitconstr;
scaled = problem.fitpars;
limits = problem.fitLimits;
scaled = problem.fitParams;

unscaled = (scaled.*(limits(:,2)-limits(:,1)))+limits(:,1);

problem.fitpars = unscaled;
problem.fitParams = unscaled;

end
6 changes: 3 additions & 3 deletions API/RAT.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
%Call the main RAT routine...

% If display is not silent print a
% line confirminf RAT is starting
% line confirming RAT is starting
if ~strcmpi(controls.display,'off')
fprintf('Starting RAT ________________________________________________________________________________________________\n\n');
end
Expand All @@ -37,8 +37,8 @@

result = parseResultToStruct(problem,result);

if isfield(outProblemStruct,'fitpars')
result.bestFitPars = outProblemStruct.fitpars;
if isfield(outProblemStruct,'fitParams')
result.bestFitPars = outProblemStruct.fitParams;
end

if any((strcmpi(controls.procedure,{'bayes','NS','dream'})))
Expand Down
2 changes: 1 addition & 1 deletion API/RATMain.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'bulkIn',preAlloc,...
'bulkOut',preAlloc,...
'resolutionParams',preAlloc,...
'calculations',struct('all_chis',preAlloc,'sum_chi',0),...
'calculations',struct('allChis',preAlloc,'sumChi',0),...
'allSubRough',preAlloc,...
'resample',preAlloc);

Expand Down
8 changes: 4 additions & 4 deletions API/parseClassToStructs.m
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,10 @@
end

% Initialise the lists of fitting parameters
problemDef.fitpars = [];
problemDef.otherpars = [];
problemDef.fitconstr = [];
problemDef.otherconstr = [];
problemDef.fitParams = [];
problemDef.otherParams = [];
problemDef.fitLimits = [];
problemDef.otherLimits = [];


%% Now deal with the controls class
Expand Down
6 changes: 3 additions & 3 deletions API/parseResultToStruct.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function result = parseResultToStruct(problem,results)

result.reflectivity = results{1}; % Reflectivity art points
result.Simulation = results{2}; % Reflectivity between sim limits
result.shifted_data = results{3}; % Data corrected for sfs
result.layerSlds = results{4}; % Layers if defined (i.e. not custolXY)
result.simulation = results{2}; % Reflectivity between sim limits
result.shiftedData = results{3}; % Data corrected for sfs
result.layerSlds = results{4}; % Layers if defined (i.e. not customXY)
result.sldProfiles = results{5}; % Calculated SLD profiles
result.allLayers = results{6}; % Resampled layers

Expand Down
3 changes: 1 addition & 2 deletions API/projectClass/backgroundsClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
% in the object.
%
% names = background.getNames();
backsTable = obj.backgrounds.varTable;
names = backsTable{:,1};
names = obj.backgrounds.varTable{:,1};
end

function obj = addBackground(obj, varargin)
Expand Down
2 changes: 1 addition & 1 deletion API/projectClass/resolutionsClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function setResolution(obj, row, varargin)
% Changes the value of a given resolution in the table. Expects the
% index or name of resolution and keyword/value pairs to set.
%
% resolution.setResolution(1, 'name', 'res 1', 'type', 'constant', 'value1', 'param_name');
% resolution.setResolution(1, 'name', 'resolution 1', 'type', 'constant', 'value1', 'param_name');
if isText(row)
row = obj.resolutions.findRowIndex(row, obj.getNames(), 'Unrecognised resolution');
elseif isnumeric(row)
Expand Down
Loading