Skip to content

Commit

Permalink
Unify variable naming convention (#182)
Browse files Browse the repository at this point in the history
* Renames contrasts variables in target functions

* Renames fields in "problemDef" struct

* Replaces "nbair" with "bulkIn and "nbsub" with "bulkOut"

* Renames variables in tests

* Changes "sf" to "scalefactor" in target functions

* Changes "qshift" to "qzshift" in target functions

* Tidies up "backSort.m" routine

* Renames "nba" and "nbs" to "bulkIn" and "bulkOut" respectively in target functions

* Restores use of "nba" and "nbs" as inputs in "processCustomFuncion.m" to address bug

* Renames "nba" and "nbs" to "bulkIn" and "bulkOut" respectively in utilities

* Fixes typos

* Addresses review comments and fixes bugs

* Tidies up code
  • Loading branch information
DrPaulSharp authored Dec 1, 2023
1 parent 84306bc commit d30a44c
Show file tree
Hide file tree
Showing 79 changed files with 1,232 additions and 1,304 deletions.
10 changes: 5 additions & 5 deletions 3rdParty/mcmcstat/%runDram.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@

% Pre-processor directives for Matlab Coder.
coder.varsize('problem.ssubs',[Inf 1],[1 0]);
coder.varsize('problem.backgrounds',[Inf 1],[1 0]);
coder.varsize('problem.qshifts',[Inf 1],[1 0]);
coder.varsize('problem.backgroundParams',[Inf 1],[1 0]);
coder.varsize('problem.qzshifts',[Inf 1],[1 0]);
coder.varsize('problem.scalefactors',[Inf 1],[1 0]);
coder.varsize('problem.nbairs',[Inf 1],[1 0]);
coder.varsize('problem.nbsubs',[Inf 1],[1 0]);
coder.varsize('problem.resolutions',[Inf 1],[1 0]);
coder.varsize('problem.bulkIn',[Inf 1],[1 0]);
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]);
Expand Down
10 changes: 5 additions & 5 deletions API/RATMain.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
preAlloc = zeros(numberOfContrasts,1);

problem = struct('ssubs',preAlloc,...
'backgrounds',preAlloc,...
'qshifts',preAlloc,...
'backgroundParams',preAlloc,...
'qzshifts',preAlloc,...
'scalefactors',preAlloc,...
'nbairs',preAlloc,...
'nbsubs',preAlloc,...
'resolutions',preAlloc,...
'bulkIn',preAlloc,...
'bulkOut',preAlloc,...
'resolutionParams',preAlloc,...
'calculations',struct('all_chis',preAlloc,'sum_chi',0),...
'allSubRough',preAlloc,...
'resample',preAlloc);
Expand Down
12 changes: 6 additions & 6 deletions API/parseClassToStructs.m
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,12 @@
problemDef.contrastBulkIns = inputStruct.contrastBulkIns;
problemDef.contrastBulkOuts = inputStruct.contrastBulkOuts;
problemDef.contrastResolutions = contrastRes;
problemDef.backs = inputStruct.backgroundParamValues; %inputStruct.backgrounds; % **** note backPar workaround (todo) ****
problemDef.shifts = inputStruct.qzshiftValues;
problemDef.sf = inputStruct.scalefactorValues;
problemDef.nba = inputStruct.bulkInValues;
problemDef.nbs = inputStruct.bulkOutValues;
problemDef.res = inputStruct.resolutionParamValues; %inputStruct.resolutions; % **** note resolutionParam workaround (todo) ****
problemDef.backgroundParams = inputStruct.backgroundParamValues; %inputStruct.backgrounds; % **** note backPar workaround (todo) ****
problemDef.qzshifts = inputStruct.qzshiftValues;
problemDef.scalefactors = inputStruct.scalefactorValues;
problemDef.bulkIn = inputStruct.bulkInValues;
problemDef.bulkOut = inputStruct.bulkOutValues;
problemDef.resolutionParams = inputStruct.resolutionParamValues; %inputStruct.resolutions; % **** note resolutionParam workaround (todo) ****
problemDef.params = inputStruct.paramValues;
problemDef.numberOfLayers = inputStruct.numberOfLayers;
problemDef.modelType = inputStruct.modelType;
Expand Down
51 changes: 26 additions & 25 deletions API/parseOutToProjectClass.m
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
function outProblemDef = parseOutToProjectClass(problemDefInput,outProblemStruct)


%Reconstruct the problemDef class as an output
%Using the outputs from the calculation(s)
outProblemDef = problemDefInput;

%(1) Parameters
pars = outProblemStruct.params;
for i = 1:length(pars)
outProblemDef.setParameterValue(i,pars(i));
params = outProblemStruct.params;
for i = 1:length(params)
outProblemDef.setParameterValue(i,params(i));
end

%(2) Backgrounds
backs = outProblemStruct.backs;
for i = 1:length(backs)
outProblemDef.setBackgroundParamValue(i,backs(i));
backgroundParams = outProblemStruct.backgroundParams;
for i = 1:length(backgroundParams)
outProblemDef.setBackgroundParamValue(i,backgroundParams(i));
end

%(3) Scalefactors
scales = outProblemStruct.sf;
for i = 1:length(scales)
outProblemDef.setScalefactor(i,'value',scales(i));
scalefactors = outProblemStruct.scalefactors;
for i = 1:length(scalefactors)
outProblemDef.setScalefactor(i,'value',scalefactors(i));
end

%(4) Qzshifts
% shifts = outProblemStruct.shifts;
% outProblemDef.qzshifts = shifts;
qzshifts = outProblemStruct.qzshifts;
for i = 1:length(qzshifts)
outProblemDef.setQzshift(i,'value',qzshifts(i));
end

%(4) Nbairs
nbairs = outProblemStruct.nba;
for i = 1:length(nbairs)
outProblemDef.setBulkIn(i,'value',nbairs(i));
%(5) Bulk In
bulkIns = outProblemStruct.bulkIn;
for i = 1:length(bulkIns)
outProblemDef.setBulkIn(i,'value',bulkIns(i));
end

%(5) Nbsubs
nbsubs = outProblemStruct.nbs;
for i = 1:length(nbsubs)
outProblemDef.setBulkOut(i,'value',nbsubs(i));
%(6) Bulk Out
bulkOuts = outProblemStruct.bulkOut;
for i = 1:length(bulkOuts)
outProblemDef.setBulkOut(i,'value',bulkOuts(i));
end

%(5) Resolutions
resol = outProblemStruct.res;
for i = 1:length(resol)
outProblemDef.setResolutionParam(i,'value',resol(i));
%(7) Resolutions
resolutionParams = outProblemStruct.resolutionParams;
for i = 1:length(resolutionParams)
outProblemDef.setResolutionParam(i,'value',resolutionParams(i));
end

% (6) Domain ratio
% (8) Domain ratio
if strcmpi(outProblemStruct.TF,'domains')
domainRatios = outProblemStruct.domainRatio;
for i = 1:length(domainRatios)
Expand Down
12 changes: 6 additions & 6 deletions compile/fullCompile/makeCompileArgsFull.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
ARGS_1_1.contrastBulkIns = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.contrastBulkOuts = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.contrastResolutions = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.backs = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.shifts = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.sf = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.nba = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.nbs = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.res = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.backgroundParams = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.qzshifts = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.scalefactors = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.bulkIn = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.bulkOut = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.resolutionParams = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.params = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.numberOfLayers = coder.typeof(0);
ARGS_1_1.modelType = coder.typeof('X',[1 maxArraySize],[0 1]);
Expand Down
12 changes: 6 additions & 6 deletions compile/reflectivityCalculation/makeCompileArgs.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
ARGS_1_1.contrastBulkIns = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.contrastBulkOuts = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.contrastResolutions = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.backs = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.shifts = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.sf = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.nba = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.nbs = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.res = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.backgroundParams = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.qzshifts = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.scalefactors = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.bulkIn = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.bulkOut = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.resolutionParams = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.params = coder.typeof(0,[1 maxArraySize],[0 1]);
ARGS_1_1.numberOfLayers = coder.typeof(0);
ARGS_1_1.modelType = coder.typeof('X',[1 maxArraySize],[0 1]);
Expand Down
18 changes: 9 additions & 9 deletions minimisers/generalUtils/checkBounds.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@

fitWhichBacks = problem.fitBackgrounds;
fittingBacks = problem.backs(find(fitWhichBacks));
fittingBacksConstr = problem.backs_constr(find(fitWhichBacks),:);
fittingBacksConstr = problem.backgroundParamLimits(find(fitWhichBacks),:);
fittingBacksNames = problem.backgroundParamNames(find(fitWhichBacks));

fitWhichScales = problem.fitScalefactor;
fittingScales = problem.scalefac(find(fitWhichScales));
fittingScalesConstr = problem.scale_constr(find(fitWhichScales),:);
fittingScalesNames = problem.scalesNames(find(fitWhichScales));
fittingScalesConstr = problem.scalefactorLimits(find(fitWhichScales),:);
fittingScalesNames = problem.scalefactorNames(find(fitWhichScales));

fitWhichShifts = problem.fitQzshift;
fittingShifts = problem.shifts_horisontal(find(fitWhichShifts));
fittingShiftsConstr = problem.shifts_constr(find(fitWhichShifts),:);
fittingShiftsNames = problem.shiftsNames(find(fitWhichShifts));
fittingShifts = problem.qzshifts(find(fitWhichShifts));
fittingShiftsConstr = problem.qzshiftLimit(find(fitWhichShifts),:);
fittingShiftsNames = problem.qzshiftNames(find(fitWhichShifts));

fitWhichNbas = problem.fitBulkIn;
fittingNbas = problem.nba(find(fitWhichNbas));
fittingNbaConstr = problem.nbairs_constr(find(fitWhichNbas),:);
fittingNbaNames = problem.nbaNames(find(fitWhichNbas));
fittingNbas = problem.bulkIn(find(fitWhichNbas));
fittingNbaConstr = problem.bulkInLimits(find(fitWhichNbas),:);
fittingNbaNames = problem.bulkInNames(find(fitWhichNbas));


fittingParams = [fittingParams(:) ; fittingBacks(:) ; fittingScales(:) ; fittingShifts(:) ; fittingNbas(:)];
Expand Down
Loading

0 comments on commit d30a44c

Please sign in to comment.