Skip to content

Commit ea1b43a

Browse files
authored
Updates naming convention for main RAT variables (#194)
* Clarifies code by updating naming convention for variables * Remakes non-polarised test data * Remakes domains test data * Fixes build * Renamed some instances of "problem" as "contrastParams" to match "result" struct * Remakes test data * Renames "problemDef" as "problem" * Clarifies further "problem" variables * Addresses review comments
1 parent da2ad93 commit ea1b43a

112 files changed

Lines changed: 1461 additions & 1488 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3rdParty/mcmcstat/%runDram.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
function [problemDef,problem,result,bayesResults] = runDram(problemDef,problemDefCells,problemDefLimits,priors,controls)
1+
function [problemStruct,problem,result,bayesResults] = runDram(problemStruct,problemCells,problemLimits,priors,controls)
22
debug = 0;
33

44
checks = controls.checks;
5-
[problemDef,fitNames] = packParams(problemDef,problemDefCells,problemDefLimits,checks);
5+
[problemStruct,fitNames] = packParams(problemStruct,problemCells,problemLimits,checks);
66
%fitPriors = packPriors(priors,checks);
77

88
% Seed the Random Number Generator
@@ -15,12 +15,12 @@
1515
%Make uniform priors from the
1616
%min/max limits for now.
1717
prior = {};
18-
lims = problemDef.fitLimits;
18+
lims = problemStruct.fitLimits;
1919
% Get the li
2020

2121
for i = 1:length(fitNames)
2222
name = fitNames{i};
23-
value = problemDef.fitParams(i);
23+
value = problemStruct.fitParams(i);
2424
min = lims(i,1);
2525
max = lims(i,2);
2626
mu = 0;
@@ -51,7 +51,7 @@
5151
burnin = controls.burnin;
5252
adaptint = 100;%controls.adaptint;
5353

54-
problem = {problemDef ; controls ; problemDefLimits ; problemDefCells};
54+
problem = {problemStruct ; controls ; problemLimits ; problemCells};
5555

5656
res = [];
5757
output = runBayes(loop,nsimu,burnin,adaptint,params,problem);
@@ -65,9 +65,9 @@
6565
bayesResults.bestFits = output.bestFits;
6666
bayesResults.predlims = output.predlims;
6767

68-
problemDef.fitParams = output.bestPars;
69-
problemDef = unpackParams(problemDef,controls);
70-
[problem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
68+
problemStruct.fitParams = output.bestPars;
69+
problemStruct = unpackParams(problemStruct,controls);
70+
[problem,result] = reflectivityCalculation(problemStruct,problemCells,controls);
7171

7272
% Pre-processor directives for Matlab Coder.
7373
coder.varsize('problem.ssubs',[Inf 1],[1 0]);

3rdParty/mcmcstat/refModel.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030

3131
pars = theta;
3232

33-
problemDef = problem{1};
33+
problemStruct = problem{1};
3434
controls = problem{2};
35-
problemDefLimits = problem{3};
36-
problemDefCells = problem{4};
35+
problemLimits = problem{3};
36+
problemCells = problem{4};
3737

38-
problemDef.fitParams = pars;
39-
problemDef = unpackParams(problemDef,controls);
40-
[problem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
38+
problemStruct.fitParams = pars;
39+
problemStruct = unpackParams(problemStruct,controls);
40+
[problem,result] = reflectivityCalculation(problemStruct,problemCells,controls);
4141

4242
ySim = result{1}{contrast};
4343

3rdParty/mcmcstat/refModel_scaled.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@
3333

3434

3535

36-
problemDef = problem{1};
36+
problemStruct = problem{1};
3737
controls = problem{2};
38-
problemDefLimits = problem{3};
39-
problemDefCells = problem{4};
38+
problemLimits = problem{3};
39+
problemCells = problem{4};
4040

4141
pars = theta;
42-
constr = problemDef.fitLimits;
42+
constr = problemStruct.fitLimits;
4343
pars = unscalePars(pars,constr);
4444

45-
problemDef.fitParams = pars;
46-
problemDef = unpackParams(problemDef,controls);
47-
[problem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
45+
problemStruct.fitParams = pars;
46+
problemStruct = unpackParams(problemStruct,controls);
47+
[problem,result] = reflectivityCalculation(problemStruct,problemCells,controls);
4848

4949
ySim = result{1}{contrast};
5050

3rdParty/mcmcstat/reflectivity_fitModel.m

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,16 @@
66
pars = theta; % Current parameter values from mcmcstat
77
problem = data.problem; % Struct needed for the calculation
88
%allProblem = data{1}.problem;
9-
problemDef = problem{1};
9+
problemStruct = problem{1};
1010
controls = problem{2};
11-
problemDefLimits = problem{3};
12-
problemDefCells = problem{4};
11+
problemLimits = problem{3};
12+
problemCells = problem{4};
1313

1414

15-
problemDef.fitParams = pars;
16-
problemDef = unpackParams(problemDef,controls);
17-
%setappdata(0,'problem',problem);
18-
%problem = reflectivityCalculation(problem);
19-
[problemDef,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
15+
problemStruct.fitParams = pars;
16+
problemStruct = unpackParams(problemStruct,controls);
17+
[contrastParams,~] = reflectivityCalculation(problemStruct,problemCells,controls);
2018

21-
%problem = getappdata(0,'problem');
22-
ss = problemDef.calculations.sumChi;
19+
ss = contrastParams.calculations.sumChi;
2320

2421
end
25-

3rdParty/mcmcstat/reflectivity_fitModel_scaled.m

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@
44
% Calls reflectivity calculation and returns the value of chisquared.
55
% Scaled version so the parameters need to be unscaled before use.
66

7-
problemDef = problem{1};
7+
problemStruct = problem{1};
88
controls = problem{2};
9-
problemDefLimits = problem{3};
10-
problemDefCells = problem{4};
9+
problemLimits = problem{3};
10+
problemCells = problem{4};
1111

1212
pars = theta; % Current parameter values from mcmcstat
13-
constr = problemDef.fitLimits;
13+
constr = problemStruct.fitLimits;
1414
pars = unscalePars(pars,constr);
1515

16-
problemDef.fitParams = pars;
17-
problemDef = unpackParams(problemDef,controls);
18-
%setappdata(0,'problem',problem);
19-
%problem = reflectivityCalculation(problem);
20-
[problemDef,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
16+
problemStruct.fitParams = pars;
17+
problemStruct = unpackParams(problemStruct,controls);
2118

22-
%problem = getappdata(0,'problem');
23-
ss = problemDef.calculations.sumChi;
19+
[contrastParams,~] = reflectivityCalculation(problemStruct,problemCells,controls);
2420

25-
end
21+
ss = contrastParams.calculations.sumChi;
2622

23+
end

3rdParty/mcmcstat/runBayes.m

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
function output = runBayes(loop,nsimu,burnin,adaptint,params,problem,controls)
22

3-
problemDef = problem{1};
3+
problemStruct = problem{1};
44
controls = problem{2};
5-
problemDefLimits = problem{3};
6-
problemDefCells = problem{4};
5+
problemLimits = problem{3};
6+
problemCells = problem{4};
77

88
display = controls.display;
99

@@ -12,7 +12,7 @@
1212
% We have the same number of 'batches' as contrasts.
1313
% Also need to pass problem in order to access this
1414
% from the subfunctions.
15-
numberOfContrasts = problemDef.numberOfContrasts;
15+
numberOfContrasts = problemStruct.numberOfContrasts;
1616

1717
% Pre-allocate data to keep the compiler happy
1818
% data = cell(1,numberOfContrasts);
@@ -23,7 +23,7 @@
2323
data.data = cell(1,numberOfContrasts);
2424
data.problem = problem;
2525
for i = 1:numberOfContrasts
26-
thisData = problemDefCells{2}{i};
26+
thisData = problemCells{2}{i};
2727
if ~isempty(thisData)
2828
data.data{i} = [thisData(:,:)];
2929
end
@@ -32,8 +32,8 @@
3232

3333
% Make qcov based on the ranges of the parameters
3434
qcov = [];
35-
fitPars = problemDef.fitParams;
36-
fitConstr = problemDef.fitLimits;
35+
fitPars = problemStruct.fitParams;
36+
fitConstr = problemStruct.fitLimits;
3737
nPars = length(fitPars);
3838

3939
for i = 1:nPars
@@ -89,12 +89,12 @@
8989
% out = mcmcpred_compile(results,chain,[],data,problem,500);
9090
% outSld = mcmcpred_compile_sld(results,chain,[],data,problem,500);
9191
%
92-
% problemDef.fitParams = output.bestPars;
93-
% problemDef = unpackParams(problemDef,controls);
94-
% [problem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
92+
% problemStruct.fitParams = output.bestPars;
93+
% problemStruct = unpackParams(problemStruct,controls);
94+
% [problem,result] = reflectivityCalculation(problemStruct,problemCells,controls);
9595
%
9696
% output.bestFits = result{1};
97-
% output.shiftedData = problemDefCells{2};
97+
% output.shiftedData = problemCells{2};
9898
% output.predlims = out;
9999

100100
end

3rdParty/mcmcstat/runDram.m

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
function [problemDef,outProblem,result,bayesResults] = runDram(problemDef,problemDefCells,problemDefLimits,controls,allPriors)
1+
function [problemStruct,outProblem,result,bayesResults] = runDram(problemStruct,problemCells,problemLimits,controls,allPriors)
22

33
%#codegen
44

5-
%coder.varsize('problemDef.contrastBacks',[1 Inf],[0 1]);
5+
%coder.varsize('problemStruct.contrastBacks',[1 Inf],[0 1]);
66

77
checks = controls.checks;
8-
[problemDef,fitNames] = packParams(problemDef,problemDefCells,problemDefLimits,checks);
8+
[problemStruct,fitNames] = packParams(problemStruct,problemCells,problemLimits,checks);
99
%fitPriors = packPriors(priors,checks);
1010

1111
% Seed the Random Number Generator
@@ -15,7 +15,7 @@
1515

1616
%First deal with priors.
1717
prior = {};
18-
lims = problemDef.fitLimits;
18+
lims = problemStruct.fitLimits;
1919

2020
% Preallocate params array to keep the compiler happy
2121
params = cell(length(fitNames),1);
@@ -117,7 +117,7 @@
117117
for i = 1:length(fitNames)
118118
coder.varsize('name',[1 Inf],[0 1]);
119119
name = fitNames{i};
120-
value = problemDef.fitParams(i);
120+
value = problemStruct.fitParams(i);
121121
min = lims(i,1);
122122
max = lims(i,2);
123123

@@ -149,13 +149,13 @@
149149
burnin = controls.burnin;
150150
adaptint = 100;%controls.adaptint;
151151

152-
problem = {problemDef ; controls ; problemDefLimits ; problemDefCells};
152+
problem = {problemStruct ; controls ; problemLimits ; problemCells};
153153

154154
output = runBayes(loop,nsimu,burnin,adaptint,params,problem,controls);
155155

156-
[problemDef,outProblem,result,bayesResults] = processBayes(output,problem);
156+
[problemStruct,outProblem,result,bayesResults] = processBayes(output,problem);
157157

158-
% problemDef.fitParams = bayesResults.bestPars_Mean;
158+
% problemStruct.fitParams = bayesResults.bestPars_Mean;
159159

160160

161161
% Post processing of Bayes
@@ -170,17 +170,17 @@
170170
% bestPars_mean = output.results.mean;
171171
%
172172
% % Calulate Max best fit curves
173-
% problemDef.fitParams = bestPars_max;
174-
% problemDef = unpackParams(problemDef,controls);
175-
% [outProblem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
173+
% problemStruct.fitParams = bestPars_max;
174+
% problemStruct = unpackParams(problemStruct,controls);
175+
% [outProblem,result] = reflectivityCalculation(problemStruct,problemCells,controls);
176176
% bestFitMax_Ref = result(1);
177177
% bestFitMax_Sld = result(5);
178178
% bestFitMax_chi = outProblem.calculations.sumChi;
179179
%
180180
% % Calculate 'mean' best fit curves
181-
% problemDef.fitParams = bestPars_mean;
182-
% problemDef = unpackParams(problemDef,controls);
183-
% [outProblem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
181+
% problemStruct.fitParams = bestPars_mean;
182+
% problemStruct = unpackParams(problemStruct,controls);
183+
% [outProblem,result] = reflectivityCalculation(problemStruct,problemCells,controls);
184184
% bestFitMean_Ref = result(1);
185185
% bestFitMean_Sld = result(5);
186186
% bestFitMean_chi = outProblem.calculations.sumChi;

3rdParty/mcmcstat/sldModel.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424

2525
pars = theta;
2626

27-
problemDef = problem{1};
27+
problemStruct = problem{1};
2828
controls = problem{2};
29-
problemDefLimits = problem{3};
30-
problemDefCells = problem{4};
29+
problemLimits = problem{3};
30+
problemCells = problem{4};
3131
controls.calcSldDuringFit = true;
3232

33-
problemDef.fitParams = pars;
34-
problemDef = unpackParams(problemDef,controls);
35-
[~,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
33+
problemStruct.fitParams = pars;
34+
problemStruct = unpackParams(problemStruct,controls);
35+
[~,result] = reflectivityCalculation(problemStruct,problemCells,controls);
3636

3737
sld = result{5}{contrast};
3838

3rdParty/paramonte/pmLogFunction.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
properties
44

5-
problemDef;
6-
problemDefCells;
7-
problemDefLimits;
5+
problemStruct;
6+
problemCells;
7+
problemLimits;
88
priors;
99
controls;
1010
scaled;
@@ -16,7 +16,7 @@
1616

1717
function logFuncVal = get(obj,pars)
1818

19-
problem = obj.problemDef;
19+
problem = obj.problemStruct;
2020
problem.fitParams = pars;
2121

2222
if obj.scaled
@@ -25,7 +25,7 @@
2525

2626
problem = unpackParams(problem,obj.controls);
2727

28-
[outProblem,~] = reflectivityCalculation_mex(problem,obj.problemDefCells,obj.controls);
28+
[outProblem,~] = reflectivityCalculation_mex(problem,obj.problemCells,obj.controls);
2929
chi = outProblem.calculations.sumChi;
3030
logFuncVal = -chi/2;
3131

0 commit comments

Comments
 (0)