diff --git a/3rdParty/mcmcstat/%runDram.m b/3rdParty/mcmcstat/%runDram.m index ea9934224..dee7564dc 100644 --- a/3rdParty/mcmcstat/%runDram.m +++ b/3rdParty/mcmcstat/%runDram.m @@ -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]); diff --git a/API/RATMain.m b/API/RATMain.m index 11d2651f7..e32415670 100644 --- a/API/RATMain.m +++ b/API/RATMain.m @@ -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); diff --git a/API/parseClassToStructs.m b/API/parseClassToStructs.m index 3304f444f..c3db5504d 100644 --- a/API/parseClassToStructs.m +++ b/API/parseClassToStructs.m @@ -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; diff --git a/API/parseOutToProjectClass.m b/API/parseOutToProjectClass.m index 6ebd0498e..17dd6f318 100644 --- a/API/parseOutToProjectClass.m +++ b/API/parseOutToProjectClass.m @@ -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) diff --git a/compile/fullCompile/makeCompileArgsFull.m b/compile/fullCompile/makeCompileArgsFull.m index 23c2c5b03..80722c9ea 100644 --- a/compile/fullCompile/makeCompileArgsFull.m +++ b/compile/fullCompile/makeCompileArgsFull.m @@ -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]); diff --git a/compile/reflectivityCalculation/makeCompileArgs.m b/compile/reflectivityCalculation/makeCompileArgs.m index 3eecfc89e..f1b376b0f 100644 --- a/compile/reflectivityCalculation/makeCompileArgs.m +++ b/compile/reflectivityCalculation/makeCompileArgs.m @@ -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]); diff --git a/minimisers/generalUtils/checkBounds.m b/minimisers/generalUtils/checkBounds.m index 9ad1493f6..62617fea3 100644 --- a/minimisers/generalUtils/checkBounds.m +++ b/minimisers/generalUtils/checkBounds.m @@ -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(:)]; diff --git a/minimisers/generalUtils/packParams.m b/minimisers/generalUtils/packParams.m index c68cd8dcc..98bb641e6 100644 --- a/minimisers/generalUtils/packParams.m +++ b/minimisers/generalUtils/packParams.m @@ -1,192 +1,169 @@ function [problemDef,fitNames] = packParams(problemDef,problemDefCells,limits,checks) -%Separate out the params array into fitting -%and unfitting arrays. - - -%problem = getappdata(0,'problem'); - -% controls.checks.fitParam = ones(length(problem.params),1); -% controls.checks.fitBackgroundParam = ones(length(problem.backs),1); -% controls.checks.fitScalefactor = ones(length(problem.scalefac),1); -% controls.checks.fitBulkIn = ones(length(problem.nba),1); -% controls.checks.fitBulkOut = ones(length(problem.nbs),1); -% controls.checks.fitResolutionParam = ones(length(problem.resolution),1); - -% calculation.limits.param = problem.constr; -% calculation.limits.backgroundParam = problem.backs_constr; -% calculation.limits.scalefactor = problem.scale_constr; -% calculation.limits.qzshift = problem.shifts_constr; -% calculation.limits.bulkIn = problem.nbairs_constr; -% calculation.limits.bulkOut = problem.nbsubs_constr; -% calculation.limits.resolutionParam = problem.resolution_constr; - - - -%We need to pack the parameters into seperate vectors -%of those that are being fitted, and those that are -%held constant. -numberOfFitted = sum(checks.fitParam) + ... - sum(checks.fitBackgroundParam) + ... - sum(checks.fitScalefactor) + ... - sum(checks.fitQzshift) + ... - sum(checks.fitBulkIn) + ... - sum(checks.fitBulkOut) + ... - sum(checks.fitResolutionParam) + ... - sum(checks.fitDomainRatio); - -numberOfTotal = length(problemDef.params) + ... - length(problemDef.backs) + ... - length(problemDef.sf) + ... - length(problemDef.shifts) + ... - length(problemDef.nba) + ... - length(problemDef.nbs) + ... - length(problemDef.res) + ... - length(problemDef.domainRatio); - -fitpars = problemDef.fitpars;%zeros(numberOfFitted,1); -otherpars = zeros((numberOfTotal-numberOfFitted),1); -fitconstr = zeros(numberOfFitted,2); -otherconstr = zeros((numberOfTotal-numberOfFitted),2); -%limits = problemDef.limits; -fitNames = cell(numberOfFitted,1); -for i = 1:numberOfFitted - fitNames{i} = ''; -end - -fitCounter = 1; -otherCounter = 1; -for n = 1:length(checks.fitParam) - if checks.fitParam(n) == 1 - fitpars(fitCounter) = problemDef.params(n); - fitconstr(fitCounter,1) = limits.param(n,1); - fitconstr(fitCounter,2) = limits.param(n,2); - fitNames{fitCounter} = problemDefCells{7}{n}; - fitCounter = fitCounter + 1; - - else - otherpars(otherCounter) = problemDef.params(n); - otherconstr(otherCounter,1) = limits.param(n,1); - otherconstr(otherCounter,2) = limits.param(n,2); - otherCounter = otherCounter + 1; + %We need to pack the parameters into seperate vectors + %of those that are being fitted, and those that are + %held constant. + numberOfFitted = sum(checks.fitParam) + ... + sum(checks.fitBackgroundParam) + ... + sum(checks.fitScalefactor) + ... + sum(checks.fitQzshift) + ... + sum(checks.fitBulkIn) + ... + sum(checks.fitBulkOut) + ... + sum(checks.fitResolutionParam) + ... + sum(checks.fitDomainRatio); + + numberOfTotal = length(problemDef.params) + ... + length(problemDef.backgroundParams) + ... + length(problemDef.scalefactors) + ... + length(problemDef.qzshifts) + ... + length(problemDef.bulkIn) + ... + length(problemDef.bulkOut) + ... + length(problemDef.resolutionParams) + ... + length(problemDef.domainRatio); + + fitpars = problemDef.fitpars;%zeros(numberOfFitted,1); + otherpars = zeros((numberOfTotal-numberOfFitted),1); + fitconstr = zeros(numberOfFitted,2); + otherconstr = zeros((numberOfTotal-numberOfFitted),2); + %limits = problemDef.limits; + fitNames = cell(numberOfFitted,1); + for i = 1:numberOfFitted + fitNames{i} = ''; end -end - -%Also do the same for backgrounds... -for n = 1:length(checks.fitBackgroundParam) - if checks.fitBackgroundParam(n) == 1 - fitpars(fitCounter) = problemDef.backs(n); - fitconstr(fitCounter,1) = limits.backgroundParam(n,1); - fitconstr(fitCounter,2) = limits.backgroundParam(n,2); - fitNames{fitCounter} = problemDefCells{8}{n}; - fitCounter = fitCounter + 1; - else - otherpars(otherCounter) = problemDef.backs(n); - otherconstr(otherCounter,1) = limits.backgroundParam(n,1); - otherconstr(otherCounter,2) = limits.backgroundParam(n,2); - otherCounter = otherCounter + 1; + + fitCounter = 1; + otherCounter = 1; + for n = 1:length(checks.fitParam) + if checks.fitParam(n) == 1 + fitpars(fitCounter) = problemDef.params(n); + fitconstr(fitCounter,1) = limits.param(n,1); + fitconstr(fitCounter,2) = limits.param(n,2); + fitNames{fitCounter} = problemDefCells{7}{n}; + fitCounter = fitCounter + 1; + + else + otherpars(otherCounter) = problemDef.params(n); + otherconstr(otherCounter,1) = limits.param(n,1); + otherconstr(otherCounter,2) = limits.param(n,2); + otherCounter = otherCounter + 1; + end end -end - -%..also for the scale factors -for n = 1:length(checks.fitScalefactor) - if checks.fitScalefactor(n) == 1 - fitpars(fitCounter) = problemDef.sf(n); - fitconstr(fitCounter,1) = limits.scalefactor(n,1); - fitconstr(fitCounter,2) = limits.scalefactor(n,2); - fitNames{fitCounter} = problemDefCells{9}{n}; - fitCounter = fitCounter + 1; - else - otherpars(otherCounter) = problemDef.sf(n); - otherconstr(otherCounter,1) = limits.scalefactor(n,1); - otherconstr(otherCounter,2) = limits.scalefactor(n,2); - otherCounter = otherCounter + 1; + + %Also do the same for backgrounds... + for n = 1:length(checks.fitBackgroundParam) + if checks.fitBackgroundParam(n) == 1 + fitpars(fitCounter) = problemDef.backgroundParams(n); + fitconstr(fitCounter,1) = limits.backgroundParam(n,1); + fitconstr(fitCounter,2) = limits.backgroundParam(n,2); + fitNames{fitCounter} = problemDefCells{8}{n}; + fitCounter = fitCounter + 1; + else + otherpars(otherCounter) = problemDef.backgroundParams(n); + otherconstr(otherCounter,1) = limits.backgroundParam(n,1); + otherconstr(otherCounter,2) = limits.backgroundParam(n,2); + otherCounter = otherCounter + 1; + end end -end - -%Need qshifts -for n = 1:length(checks.fitQzshift) - if checks.fitQzshift(n) == 1 - fitpars(fitCounter) = problemDef.shifts(n); - fitconstr(fitCounter,1) = limits.qzshift(n,1); - fitconstr(fitCounter,2) = limits.qzshift(n,2); - fitNames{fitCounter} = problemDefCells{10}{n}; - fitCounter = fitCounter + 1; - else - otherpars(otherCounter) = problemDef.shifts(n); - otherconstr(otherCounter,1) = limits.qzshift(n,1); - otherconstr(otherCounter,2) = limits.qzshift(n,2); - otherCounter = otherCounter + 1; - end -end - -%Nbairs -for n = 1:length(checks.fitBulkIn) - if checks.fitBulkIn(n) == 1 - fitpars(fitCounter) = problemDef.nba(n); - fitconstr(fitCounter,1) = limits.bulkIn(n,1); - fitconstr(fitCounter,2) = limits.bulkIn(n,2); - fitNames{fitCounter} = problemDefCells{11}{n}; - fitCounter = fitCounter + 1; - else - otherpars(otherCounter) = problemDef.nba(n); - otherconstr(otherCounter,1) = limits.bulkIn(n,1); - otherconstr(otherCounter,2) = limits.bulkIn(n,2); - otherCounter = otherCounter + 1; - end -end - -%NBsubs -for n = 1:length(checks.fitBulkOut) - if checks.fitBulkOut(n) == 1 - fitpars(fitCounter) = problemDef.nbs(n); - fitconstr(fitCounter,1) = limits.bulkOut(n,1); - fitconstr(fitCounter,2) = limits.bulkOut(n,2); - fitNames{fitCounter} = problemDefCells{12}{n}; - fitCounter = fitCounter + 1; - else - otherpars(otherCounter) = problemDef.nbs(n); - otherconstr(otherCounter,1) = limits.bulkOut(n,1); - otherconstr(otherCounter,2) = limits.bulkOut(n,2); - otherCounter = otherCounter + 1; + + %..also for the scale factors + for n = 1:length(checks.fitScalefactor) + if checks.fitScalefactor(n) == 1 + fitpars(fitCounter) = problemDef.scalefactors(n); + fitconstr(fitCounter,1) = limits.scalefactor(n,1); + fitconstr(fitCounter,2) = limits.scalefactor(n,2); + fitNames{fitCounter} = problemDefCells{9}{n}; + fitCounter = fitCounter + 1; + else + otherpars(otherCounter) = problemDef.scalefactors(n); + otherconstr(otherCounter,1) = limits.scalefactor(n,1); + otherconstr(otherCounter,2) = limits.scalefactor(n,2); + otherCounter = otherCounter + 1; + end + end + + %Need qzshifts + for n = 1:length(checks.fitQzshift) + if checks.fitQzshift(n) == 1 + fitpars(fitCounter) = problemDef.qzshifts(n); + fitconstr(fitCounter,1) = limits.qzshift(n,1); + fitconstr(fitCounter,2) = limits.qzshift(n,2); + fitNames{fitCounter} = problemDefCells{10}{n}; + fitCounter = fitCounter + 1; + else + otherpars(otherCounter) = problemDef.qzshifts(n); + otherconstr(otherCounter,1) = limits.qzshift(n,1); + otherconstr(otherCounter,2) = limits.qzshift(n,2); + otherCounter = otherCounter + 1; + end + end + + %Bulk In + for n = 1:length(checks.fitBulkIn) + if checks.fitBulkIn(n) == 1 + fitpars(fitCounter) = problemDef.bulkIn(n); + fitconstr(fitCounter,1) = limits.bulkIn(n,1); + fitconstr(fitCounter,2) = limits.bulkIn(n,2); + fitNames{fitCounter} = problemDefCells{11}{n}; + fitCounter = fitCounter + 1; + else + otherpars(otherCounter) = problemDef.bulkIn(n); + otherconstr(otherCounter,1) = limits.bulkIn(n,1); + otherconstr(otherCounter,2) = limits.bulkIn(n,2); + otherCounter = otherCounter + 1; + end + end + + %Bulk Out + for n = 1:length(checks.fitBulkOut) + if checks.fitBulkOut(n) == 1 + fitpars(fitCounter) = problemDef.bulkOut(n); + fitconstr(fitCounter,1) = limits.bulkOut(n,1); + fitconstr(fitCounter,2) = limits.bulkOut(n,2); + fitNames{fitCounter} = problemDefCells{12}{n}; + fitCounter = fitCounter + 1; + else + otherpars(otherCounter) = problemDef.bulkOut(n); + otherconstr(otherCounter,1) = limits.bulkOut(n,1); + otherconstr(otherCounter,2) = limits.bulkOut(n,2); + otherCounter = otherCounter + 1; + end + end + + %Resolution..... + for n = 1:length(checks.fitResolutionParam) + if checks.fitResolutionParam(n) == 1 + fitpars(fitCounter) = problemDef.resolutionParams(n); + fitconstr(fitCounter,1) = limits.resolutionParam(n,1); + fitconstr(fitCounter,2) = limits.resolutionParam(n,2); + fitNames{fitCounter} = problemDefCells{13}{n}; + fitCounter = fitCounter + 1; + else + otherpars(otherCounter) = problemDef.resolutionParams(n); + otherconstr(otherCounter,1) = limits.resolutionParam(n,1); + otherconstr(otherCounter,2) = limits.resolutionParam(n,2); + otherCounter = otherCounter + 1; + end + end + + % Domain Ratio + for n = 1:length(checks.fitDomainRatio) + if checks.fitDomainRatio(n) == 1 + fitpars(fitCounter) = problemDef.domainRatio(n); + fitconstr(fitCounter,1) = limits.domainRatio(n,1); + fitconstr(fitCounter,2) = limits.domainRatio(n,2); + fitNames{fitCounter} = problemDefCells{20}{n}; + fitCounter = fitCounter + 1; + else + otherpars(otherCounter) = problemDef.domainRatio(n); + otherconstr(otherCounter,1) = limits.domainRatio(n,1); + otherconstr(otherCounter,2) = limits.domainRatio(n,2); + otherCounter = otherCounter + 1; + end end -end - -%Resolution..... -for n = 1:length(checks.fitResolutionParam) - if checks.fitResolutionParam(n) == 1 - fitpars(fitCounter) = problemDef.res(n); - fitconstr(fitCounter,1) = limits.resolutionParam(n,1); - fitconstr(fitCounter,2) = limits.resolutionParam(n,2); - fitNames{fitCounter} = problemDefCells{13}{n}; - fitCounter = fitCounter + 1; - else - otherpars(otherCounter) = problemDef.res(n); - otherconstr(otherCounter,1) = limits.resolutionParam(n,1); - otherconstr(otherCounter,2) = limits.resolutionParam(n,2); - otherCounter = otherCounter + 1; - end -end - -% Domain Ratio -for n = 1:length(checks.fitDomainRatio) - if checks.fitDomainRatio(n) == 1 - fitpars(fitCounter) = problemDef.domainRatio(n); - fitconstr(fitCounter,1) = limits.domainRatio(n,1); - fitconstr(fitCounter,2) = limits.domainRatio(n,2); - fitNames{fitCounter} = problemDefCells{20}{n}; - fitCounter = fitCounter + 1; - else - otherpars(otherCounter) = problemDef.domainRatio(n); - otherconstr(otherCounter,1) = limits.domainRatio(n,1); - otherconstr(otherCounter,2) = limits.domainRatio(n,2); - otherCounter = otherCounter + 1; - end -end - -problemDef.fitpars = fitpars; -problemDef.otherpars = otherpars; -problemDef.fitconstr = fitconstr; -problemDef.otherconstr = otherconstr; + + problemDef.fitpars = fitpars; + problemDef.otherpars = otherpars; + problemDef.fitconstr = fitconstr; + problemDef.otherconstr = otherconstr; end \ No newline at end of file diff --git a/minimisers/generalUtils/packParamsPriors.m b/minimisers/generalUtils/packParamsPriors.m index 818e22818..5227e220d 100644 --- a/minimisers/generalUtils/packParamsPriors.m +++ b/minimisers/generalUtils/packParamsPriors.m @@ -1,244 +1,221 @@ function [problemDef,fitNames,fitPriors] = packParamsPriors(problemDef,problemDefCells,limits,priors,checks) -%Separate out the params array into fitting -%and unfitting arrays. - - -%problem = getappdata(0,'problem'); - -% controls.checks.fitParam = ones(length(problem.params),1); -% controls.checks.fitBackgroundParam = ones(length(problem.backs),1); -% controls.checks.fitScalefactor = ones(length(problem.scalefac),1); -% controls.checks.fitBulkIn = ones(length(problem.nba),1); -% controls.checks.fitBulkOut = ones(length(problem.nbs),1); -% controls.checks.fitResolutionParam = ones(length(problem.resolution),1); - -% calculation.limits.param = problem.constr; -% calculation.limits.backgroundParam = problem.backs_constr; -% calculation.limits.scalefactor = problem.scale_constr; -% calculation.limits.qzshift = problem.shifts_constr; -% calculation.limits.bulkIn = problem.nbairs_constr; -% calculation.limits.bulkOut = problem.nbsubs_constr; -% calculation.limits.resolutionParam = problem.resolution_constr; - - - -%We need to pack the parameters into seperate vectors -%of those that are being fitted, and those that are -%held constant. -numberOfFitted = sum(checks.fitParam) + ... - sum(checks.fitBackgroundParam) + ... - sum(checks.fitScalefactor) + ... - sum(checks.fitQzshift) + ... - sum(checks.fitBulkIn) + ... - sum(checks.fitBulkOut) + ... - sum(checks.fitResolutionParam) + ... - sum(checks.fitDomainRatio); - -numberOfTotal = length(problemDef.params) + ... - length(problemDef.backs) + ... - length(problemDef.sf) + ... - length(problemDef.shifts) + ... - length(problemDef.nba) + ... - length(problemDef.nbs) + ... - length(problemDef.res) + ... - length(problemDef.domainRatio); - -fitpars = problemDef.fitpars;%zeros(numberOfFitted,1); -otherpars = zeros((numberOfTotal-numberOfFitted),1); -fitconstr = zeros(numberOfFitted,2); -otherconstr = zeros((numberOfTotal-numberOfFitted),2); -%limits = problemDef.limits; -fitNames = cell(numberOfFitted,1); -fitPriors = zeros(numberOfFitted,2); -fitCounter = 1; -otherCounter = 1; -for n = 1:length(checks.fitParam) - if checks.fitParam(n) == 1 - fitpars(fitCounter) = problemDef.params(n); - fitconstr(fitCounter,1) = limits.param(n,1); - fitconstr(fitCounter,2) = limits.param(n,2); - fitNames{fitCounter} = problemDefCells{7}{n}; - thisPrior = priors.param{n}; - if (strcmpi(thisPrior{2},'gaussian')) - thisGausPrior = [thisPrior{3} thisPrior{4}]; + %We need to pack the parameters into seperate vectors + %of those that are being fitted, and those that are + %held constant. + numberOfFitted = sum(checks.fitParam) + ... + sum(checks.fitBackgroundParam) + ... + sum(checks.fitScalefactor) + ... + sum(checks.fitQzshift) + ... + sum(checks.fitBulkIn) + ... + sum(checks.fitBulkOut) + ... + sum(checks.fitResolutionParam) + ... + sum(checks.fitDomainRatio); + + numberOfTotal = length(problemDef.params) + ... + length(problemDef.backgroundParams) + ... + length(problemDef.scalefactors) + ... + length(problemDef.qzshifts) + ... + length(problemDef.bulkIn) + ... + length(problemDef.bulkOut) + ... + length(problemDef.resolutionParams) + ... + length(problemDef.domainRatio); + + fitpars = problemDef.fitpars; + otherpars = zeros((numberOfTotal-numberOfFitted),1); + fitconstr = zeros(numberOfFitted,2); + otherconstr = zeros((numberOfTotal-numberOfFitted),2); + fitNames = cell(numberOfFitted,1); + fitPriors = zeros(numberOfFitted,2); + fitCounter = 1; + otherCounter = 1; + + for n = 1:length(checks.fitParam) + if checks.fitParam(n) == 1 + fitpars(fitCounter) = problemDef.params(n); + fitconstr(fitCounter,1) = limits.param(n,1); + fitconstr(fitCounter,2) = limits.param(n,2); + fitNames{fitCounter} = problemDefCells{7}{n}; + thisPrior = priors.param{n}; + if (strcmpi(thisPrior{2},'gaussian')) + thisGausPrior = [thisPrior{3} thisPrior{4}]; + else + thisGausPrior = [0 Inf]; + end + fitPriors(fitCounter,:) = thisGausPrior; + fitCounter = fitCounter + 1; else - thisGausPrior = [0 Inf]; + otherpars(otherCounter) = problemDef.params(n); + otherconstr(otherCounter,1) = limits.param(n,1); + otherconstr(otherCounter,2) = limits.param(n,2); + otherCounter = otherCounter + 1; end - fitPriors(fitCounter,:) = thisGausPrior; - fitCounter = fitCounter + 1; - else - otherpars(otherCounter) = problemDef.params(n); - otherconstr(otherCounter,1) = limits.param(n,1); - otherconstr(otherCounter,2) = limits.param(n,2); - otherCounter = otherCounter + 1; end -end - -%Also do the same for backgrounds... -for n = 1:length(checks.fitBackgroundParam) - if checks.fitBackgroundParam(n) == 1 - fitpars(fitCounter) = problemDef.backs(n); - fitconstr(fitCounter,1) = limits.backgroundParam(n,1); - fitconstr(fitCounter,2) = limits.backgroundParam(n,2); - fitNames{fitCounter} = problemDefCells{8}{n}; - thisPrior = priors.backgroundParam{n}; - if (strcmpi(thisPrior{2},'gaussian')) - thisGausPrior = [thisPrior{4} thisPrior{5}]; + + %Also do the same for backgrounds... + for n = 1:length(checks.fitBackgroundParam) + if checks.fitBackgroundParam(n) == 1 + fitpars(fitCounter) = problemDef.backgroundParams(n); + fitconstr(fitCounter,1) = limits.backgroundParam(n,1); + fitconstr(fitCounter,2) = limits.backgroundParam(n,2); + fitNames{fitCounter} = problemDefCells{8}{n}; + thisPrior = priors.backgroundParam{n}; + if (strcmpi(thisPrior{2},'gaussian')) + thisGausPrior = [thisPrior{4} thisPrior{5}]; + else + thisGausPrior = [0 Inf]; + end + fitPriors(fitCounter,:) = thisGausPrior; + fitCounter = fitCounter + 1; else - thisGausPrior = [0 Inf]; + otherpars(otherCounter) = problemDef.backgroundParams(n); + otherconstr(otherCounter,1) = limits.backgroundParam(n,1); + otherconstr(otherCounter,2) = limits.backgroundParam(n,2); + otherCounter = otherCounter + 1; end - fitPriors(fitCounter,:) = thisGausPrior; - fitCounter = fitCounter + 1; - else - otherpars(otherCounter) = problemDef.backs(n); - otherconstr(otherCounter,1) = limits.backgroundParam(n,1); - otherconstr(otherCounter,2) = limits.backgroundParam(n,2); - otherCounter = otherCounter + 1; end -end - -%..also for the scale factors -for n = 1:length(checks.fitScalefactor) - if checks.fitScalefactor(n) == 1 - fitpars(fitCounter) = problemDef.sf(n); - fitconstr(fitCounter,1) = limits.scalefactor(n,1); - fitconstr(fitCounter,2) = limits.scalefactor(n,2); - fitNames{fitCounter} = problemDefCells{9}{n}; - thisPrior = priors.scalefactor{n}; - if (strcmpi(thisPrior{2},'gaussian')) - thisGausPrior = [thisPrior{4} thisPrior{5}]; + + %..also for the scale factors + for n = 1:length(checks.fitScalefactor) + if checks.fitScalefactor(n) == 1 + fitpars(fitCounter) = problemDef.scalefactors(n); + fitconstr(fitCounter,1) = limits.scalefactor(n,1); + fitconstr(fitCounter,2) = limits.scalefactor(n,2); + fitNames{fitCounter} = problemDefCells{9}{n}; + thisPrior = priors.scalefactor{n}; + if (strcmpi(thisPrior{2},'gaussian')) + thisGausPrior = [thisPrior{4} thisPrior{5}]; + else + thisGausPrior = [0 Inf]; + end + fitPriors(fitCounter,:) = thisGausPrior; + fitCounter = fitCounter + 1; else - thisGausPrior = [0 Inf]; + otherpars(otherCounter) = problemDef.scalefactors(n); + otherconstr(otherCounter,1) = limits.scalefactor(n,1); + otherconstr(otherCounter,2) = limits.scalefactor(n,2); + otherCounter = otherCounter + 1; end - fitPriors(fitCounter,:) = thisGausPrior; - fitCounter = fitCounter + 1; - else - otherpars(otherCounter) = problemDef.sf(n); - otherconstr(otherCounter,1) = limits.scalefactor(n,1); - otherconstr(otherCounter,2) = limits.scalefactor(n,2); - otherCounter = otherCounter + 1; - end -end - -%Need qshifts -for n = 1:length(checks.fitQzshift) - if checks.fitQzshift(n) == 1 - fitpars(fitCounter) = problemDef.shifts(n); - fitconstr(fitCounter,1) = limits.qzshift(n,1); - fitconstr(fitCounter,2) = limits.qzshift(n,2); - fitNames{fitCounter} = problemDefCells{10}{n}; - thisPrior = priors.qzshift{n}; - if (strcmpi(thisPrior{2},'gaussian')) - thisGausPrior = [thisPrior{4} thisPrior{5}]; + end + + %Need qzshifts + for n = 1:length(checks.fitQzshift) + if checks.fitQzshift(n) == 1 + fitpars(fitCounter) = problemDef.qzshifts(n); + fitconstr(fitCounter,1) = limits.qzshift(n,1); + fitconstr(fitCounter,2) = limits.qzshift(n,2); + fitNames{fitCounter} = problemDefCells{10}{n}; + thisPrior = priors.qzshift{n}; + if (strcmpi(thisPrior{2},'gaussian')) + thisGausPrior = [thisPrior{4} thisPrior{5}]; + else + thisGausPrior = [0 Inf]; + end + fitPriors(fitCounter,:) = thisGausPrior; + fitCounter = fitCounter + 1; else - thisGausPrior = [0 Inf]; + otherpars(otherCounter) = problemDef.qzshifts(n); + otherconstr(otherCounter,1) = limits.qzshift(n,1); + otherconstr(otherCounter,2) = limits.qzshift(n,2); + otherCounter = otherCounter + 1; end - fitPriors(fitCounter,:) = thisGausPrior; - fitCounter = fitCounter + 1; - else - otherpars(otherCounter) = problemDef.shifts(n); - otherconstr(otherCounter,1) = limits.qzshift(n,1); - otherconstr(otherCounter,2) = limits.qzshift(n,2); - otherCounter = otherCounter + 1; - end -end - -%Nbairs -for n = 1:length(checks.fitBulkIn) - if checks.fitBulkIn(n) == 1 - fitpars(fitCounter) = problemDef.nba(n); - fitconstr(fitCounter,1) = limits.bulkIn(n,1); - fitconstr(fitCounter,2) = limits.bulkIn(n,2); - fitNames{fitCounter} = problemDefCells{11}{n}; - thisPrior = priors.bulkIn{n}; - if (strcmpi(thisPrior{2},'gaussian')) - thisGausPrior = [thisPrior{4} thisPrior{5}]; + end + + %Bulk In + for n = 1:length(checks.fitBulkIn) + if checks.fitBulkIn(n) == 1 + fitpars(fitCounter) = problemDef.bulkIn(n); + fitconstr(fitCounter,1) = limits.bulkIn(n,1); + fitconstr(fitCounter,2) = limits.bulkIn(n,2); + fitNames{fitCounter} = problemDefCells{11}{n}; + thisPrior = priors.bulkIn{n}; + if (strcmpi(thisPrior{2},'gaussian')) + thisGausPrior = [thisPrior{4} thisPrior{5}]; + else + thisGausPrior = [0 Inf]; + end + fitPriors(fitCounter,:) = thisGausPrior; + fitCounter = fitCounter + 1; else - thisGausPrior = [0 Inf]; + otherpars(otherCounter) = problemDef.bulkIn(n); + otherconstr(otherCounter,1) = limits.bulkIn(n,1); + otherconstr(otherCounter,2) = limits.bulkIn(n,2); + otherCounter = otherCounter + 1; end - fitPriors(fitCounter,:) = thisGausPrior; - fitCounter = fitCounter + 1; - else - otherpars(otherCounter) = problemDef.nba(n); - otherconstr(otherCounter,1) = limits.bulkIn(n,1); - otherconstr(otherCounter,2) = limits.bulkIn(n,2); - otherCounter = otherCounter + 1; - end -end - -%NBsubs -for n = 1:length(checks.fitBulkOut) - if checks.fitBulkOut(n) == 1 - fitpars(fitCounter) = problemDef.nbs(n); - fitconstr(fitCounter,1) = limits.bulkOut(n,1); - fitconstr(fitCounter,2) = limits.bulkOut(n,2); - fitNames{fitCounter} = problemDefCells{12}{n}; - thisPrior = priors.bulkOut{n}; - if (strcmpi(thisPrior{2},'gaussian')) - thisGausPrior = [thisPrior{3} thisPrior{4}]; + end + + %Bulk Out + for n = 1:length(checks.fitBulkOut) + if checks.fitBulkOut(n) == 1 + fitpars(fitCounter) = problemDef.bulkOut(n); + fitconstr(fitCounter,1) = limits.bulkOut(n,1); + fitconstr(fitCounter,2) = limits.bulkOut(n,2); + fitNames{fitCounter} = problemDefCells{12}{n}; + thisPrior = priors.bulkOut{n}; + if (strcmpi(thisPrior{2},'gaussian')) + thisGausPrior = [thisPrior{3} thisPrior{4}]; + else + thisGausPrior = [0 Inf]; + end + fitPriors(fitCounter,:) = thisGausPrior; + fitCounter = fitCounter + 1; else - thisGausPrior = [0 Inf]; + otherpars(otherCounter) = problemDef.bulkOut(n); + otherconstr(otherCounter,1) = limits.bulkOut(n,1); + otherconstr(otherCounter,2) = limits.bulkOut(n,2); + otherCounter = otherCounter + 1; end - fitPriors(fitCounter,:) = thisGausPrior; - fitCounter = fitCounter + 1; - else - otherpars(otherCounter) = problemDef.nbs(n); - otherconstr(otherCounter,1) = limits.bulkOut(n,1); - otherconstr(otherCounter,2) = limits.bulkOut(n,2); - otherCounter = otherCounter + 1; - end -end - -%Resolution..... -for n = 1:length(checks.fitResolutionParam) - if checks.fitResolutionParam(n) == 1 - fitpars(fitCounter) = problemDef.res(n); - fitconstr(fitCounter,1) = limits.resolutionParam(n,1); - fitconstr(fitCounter,2) = limits.resolutionParam(n,2); - fitNames{fitCounter} = problemDefCells{13}{n}; - thisPrior = priors.resolutionParam{n}; - if (strcmpi(thisPrior{2},'gaussian')) - thisGausPrior = [thisPrior{4} thisPrior{5}]; + end + + %Resolution..... + for n = 1:length(checks.fitResolutionParam) + if checks.fitResolutionParam(n) == 1 + fitpars(fitCounter) = problemDef.resolutionParams(n); + fitconstr(fitCounter,1) = limits.resolutionParam(n,1); + fitconstr(fitCounter,2) = limits.resolutionParam(n,2); + fitNames{fitCounter} = problemDefCells{13}{n}; + thisPrior = priors.resolutionParam{n}; + if (strcmpi(thisPrior{2},'gaussian')) + thisGausPrior = [thisPrior{4} thisPrior{5}]; + else + thisGausPrior = [0 Inf]; + end + fitPriors(fitCounter,:) = thisGausPrior; + fitCounter = fitCounter + 1; else - thisGausPrior = [0 Inf]; + otherpars(otherCounter) = problemDef.resolutionParams(n); + otherconstr(otherCounter,1) = limits.resolutionParam(n,1); + otherconstr(otherCounter,2) = limits.resolutionParam(n,2); + otherCounter = otherCounter + 1; end - fitPriors(fitCounter,:) = thisGausPrior; - fitCounter = fitCounter + 1; - else - otherpars(otherCounter) = problemDef.res(n); - otherconstr(otherCounter,1) = limits.resolutionParam(n,1); - otherconstr(otherCounter,2) = limits.resolutionParam(n,2); - otherCounter = otherCounter + 1; - end -end - -% Domain Ratio -for n = 1:length(checks.fitDomainRatio) - if checks.fitDomainRatio(n) == 1 - fitpars(fitCounter) = problemDef.domainRatio(n); - fitconstr(fitCounter,1) = limits.domainRatio(n,1); - fitconstr(fitCounter,2) = limits.domainRatio(n,2); - fitNames{fitCounter} = problemDefCells{20}{n}; - thisPrior = priors.domainRatio{n}; - if (strcmpi(thisPrior{2},'gaussian')) - thisGausPrior = [thisPrior{4} thisPrior{5}]; + end + + % Domain Ratio + for n = 1:length(checks.fitDomainRatio) + if checks.fitDomainRatio(n) == 1 + fitpars(fitCounter) = problemDef.domainRatio(n); + fitconstr(fitCounter,1) = limits.domainRatio(n,1); + fitconstr(fitCounter,2) = limits.domainRatio(n,2); + fitNames{fitCounter} = problemDefCells{20}{n}; + thisPrior = priors.domainRatio{n}; + if (strcmpi(thisPrior{2},'gaussian')) + thisGausPrior = [thisPrior{4} thisPrior{5}]; + else + thisGausPrior = [0 Inf]; + end + fitPriors(fitCounter,:) = thisGausPrior; + fitCounter = fitCounter + 1; else - thisGausPrior = [0 Inf]; + otherpars(otherCounter) = problemDef.domainRatio(n); + otherconstr(otherCounter,1) = limits.domainRatio(n,1); + otherconstr(otherCounter,2) = limits.domainRatio(n,2); + otherCounter = otherCounter + 1; end - fitPriors(fitCounter,:) = thisGausPrior; - fitCounter = fitCounter + 1; - else - otherpars(otherCounter) = problemDef.domainRatio(n); - otherconstr(otherCounter,1) = limits.domainRatio(n,1); - otherconstr(otherCounter,2) = limits.domainRatio(n,2); - otherCounter = otherCounter + 1; - end -end - -problemDef.fitpars = fitpars; -problemDef.otherpars = otherpars; -problemDef.fitconstr = fitconstr; -problemDef.otherconstr = otherconstr; + end + + problemDef.fitpars = fitpars; + problemDef.otherpars = otherpars; + problemDef.fitconstr = fitconstr; + problemDef.otherconstr = otherconstr; end \ No newline at end of file diff --git a/minimisers/generalUtils/unpackParams.m b/minimisers/generalUtils/unpackParams.m index e76e88b9d..70626a3ef 100644 --- a/minimisers/generalUtils/unpackParams.m +++ b/minimisers/generalUtils/unpackParams.m @@ -1,146 +1,146 @@ function problemDef = unpackParams(problemDef,controls) -%Unpack the params out of the fitparsma and otherparams arrays -%back into problem.params - -%problem = getappdata(0,'problem'); - - -unpacked_counter = 1; -packed_counter = 1; -uppars_counter = 1; - -uppars = zeros(1,length(problemDef.params)); -for i = 1:length(controls.checks.fitParam) - if controls.checks.fitParam(i) == 1 - uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); - unpacked_counter = unpacked_counter + 1; - uppars_counter = uppars_counter + 1; - else - uppars(uppars_counter) = problemDef.otherpars(packed_counter); - packed_counter = packed_counter + 1; - uppars_counter = uppars_counter + 1; + %Unpack the params out of the fitparsma and otherparams arrays + %back into problem.params + + %problem = getappdata(0,'problem'); + + + unpacked_counter = 1; + packed_counter = 1; + uppars_counter = 1; + + uppars = zeros(1,length(problemDef.params)); + for i = 1:length(controls.checks.fitParam) + if controls.checks.fitParam(i) == 1 + uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); + unpacked_counter = unpacked_counter + 1; + uppars_counter = uppars_counter + 1; + else + uppars(uppars_counter) = problemDef.otherpars(packed_counter); + packed_counter = packed_counter + 1; + uppars_counter = uppars_counter + 1; + end end -end -problemDef.params = uppars; - - -%Also the backgrounds -uppars = zeros(1,length(problemDef.backs)); -uppars_counter = 1; -for i = 1:length(controls.checks.fitBackgroundParam) - if controls.checks.fitBackgroundParam(i) == 1 - uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); - unpacked_counter = unpacked_counter + 1; - uppars_counter = uppars_counter + 1; - else - uppars(uppars_counter) = problemDef.otherpars(packed_counter); - packed_counter = packed_counter + 1; - uppars_counter = uppars_counter + 1; + problemDef.params = uppars; + + + %Also the backgrounds + uppars = zeros(1,length(problemDef.backgroundParams)); + uppars_counter = 1; + for i = 1:length(controls.checks.fitBackgroundParam) + if controls.checks.fitBackgroundParam(i) == 1 + uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); + unpacked_counter = unpacked_counter + 1; + uppars_counter = uppars_counter + 1; + else + uppars(uppars_counter) = problemDef.otherpars(packed_counter); + packed_counter = packed_counter + 1; + uppars_counter = uppars_counter + 1; + end end -end -problemDef.backs = uppars; - -%Scalefactors -uppars = zeros(1,length(problemDef.sf)); -uppars_counter = 1; -for i = 1:length(controls.checks.fitScalefactor) - if controls.checks.fitScalefactor(i) == 1 - uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); - unpacked_counter = unpacked_counter + 1; - uppars_counter = uppars_counter + 1; - else - uppars(uppars_counter) = problemDef.otherpars(packed_counter); - packed_counter = packed_counter + 1; - uppars_counter = uppars_counter + 1; + problemDef.backgroundParams = uppars; + + %Scalefactors + uppars = zeros(1,length(problemDef.scalefactors)); + uppars_counter = 1; + for i = 1:length(controls.checks.fitScalefactor) + if controls.checks.fitScalefactor(i) == 1 + uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); + unpacked_counter = unpacked_counter + 1; + uppars_counter = uppars_counter + 1; + else + uppars(uppars_counter) = problemDef.otherpars(packed_counter); + packed_counter = packed_counter + 1; + uppars_counter = uppars_counter + 1; + end end -end -problemDef.sf = uppars; - - -%qshifts -uppars = zeros(1,length(problemDef.shifts)); -uppars_counter = 1; -for i = 1:length(controls.checks.fitQzshift) - if controls.checks.fitQzshift(i) == 1 - uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); - unpacked_counter = unpacked_counter + 1; - uppars_counter = uppars_counter + 1; - else - uppars(uppars_counter) = problemDef.otherpars(packed_counter); - packed_counter = packed_counter + 1; - uppars_counter = uppars_counter + 1; + problemDef.scalefactors = uppars; + + + %qzshifts + uppars = zeros(1,length(problemDef.qzshifts)); + uppars_counter = 1; + for i = 1:length(controls.checks.fitQzshift) + if controls.checks.fitQzshift(i) == 1 + uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); + unpacked_counter = unpacked_counter + 1; + uppars_counter = uppars_counter + 1; + else + uppars(uppars_counter) = problemDef.otherpars(packed_counter); + packed_counter = packed_counter + 1; + uppars_counter = uppars_counter + 1; + end end -end -problemDef.shifts = uppars; - - - -%Nbairs -uppars = zeros(1,length(problemDef.nba)); -uppars_counter = 1; -for i = 1:length(controls.checks.fitBulkIn) - if controls.checks.fitBulkIn(i) == 1 - uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); - unpacked_counter = unpacked_counter + 1; - uppars_counter = uppars_counter + 1; - else - uppars(uppars_counter) = problemDef.otherpars(packed_counter); - packed_counter = packed_counter + 1; - uppars_counter = uppars_counter + 1; + problemDef.qzshifts = uppars; + + + + %Bulk In + uppars = zeros(1,length(problemDef.bulkIn)); + uppars_counter = 1; + for i = 1:length(controls.checks.fitBulkIn) + if controls.checks.fitBulkIn(i) == 1 + uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); + unpacked_counter = unpacked_counter + 1; + uppars_counter = uppars_counter + 1; + else + uppars(uppars_counter) = problemDef.otherpars(packed_counter); + packed_counter = packed_counter + 1; + uppars_counter = uppars_counter + 1; + end end -end -problemDef.nba = uppars; - - -%Nbsubs -uppars = zeros(1,length(problemDef.nbs)); -uppars_counter = 1; -for i = 1:length(controls.checks.fitBulkOut) - if controls.checks.fitBulkOut(i) == 1 - uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); - unpacked_counter = unpacked_counter + 1; - uppars_counter = uppars_counter + 1; - else - uppars(uppars_counter) = problemDef.otherpars(packed_counter); - packed_counter = packed_counter + 1; - uppars_counter = uppars_counter + 1; + problemDef.bulkIn = uppars; + + + %Bulk Out + uppars = zeros(1,length(problemDef.bulkOut)); + uppars_counter = 1; + for i = 1:length(controls.checks.fitBulkOut) + if controls.checks.fitBulkOut(i) == 1 + uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); + unpacked_counter = unpacked_counter + 1; + uppars_counter = uppars_counter + 1; + else + uppars(uppars_counter) = problemDef.otherpars(packed_counter); + packed_counter = packed_counter + 1; + uppars_counter = uppars_counter + 1; + end end -end -problemDef.nbs = uppars; - - -%Finally resolutions -uppars = zeros(1,length(problemDef.res)); -uppars_counter = 1; -for i = 1:length(controls.checks.fitResolutionParam) - if controls.checks.fitResolutionParam(i) == 1 - uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); - unpacked_counter = unpacked_counter + 1; - uppars_counter = uppars_counter + 1; - else - uppars(uppars_counter) = problemDef.otherpars(packed_counter); - packed_counter = packed_counter + 1; - uppars_counter = uppars_counter + 1; + problemDef.bulkOut = uppars; + + + %Resolutions + uppars = zeros(1,length(problemDef.resolutionParams)); + uppars_counter = 1; + for i = 1:length(controls.checks.fitResolutionParam) + if controls.checks.fitResolutionParam(i) == 1 + uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); + unpacked_counter = unpacked_counter + 1; + uppars_counter = uppars_counter + 1; + else + uppars(uppars_counter) = problemDef.otherpars(packed_counter); + packed_counter = packed_counter + 1; + uppars_counter = uppars_counter + 1; + end end -end -problemDef.res = uppars; - - -%Finally domainRatio -uppars = zeros(1,length(problemDef.domainRatio)); -uppars_counter = 1; -for i = 1:length(controls.checks.fitDomainRatio) - if controls.checks.fitDomainRatio(i) == 1 - uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); - unpacked_counter = unpacked_counter + 1; - uppars_counter = uppars_counter + 1; - else - uppars(uppars_counter) = problemDef.otherpars(packed_counter); - packed_counter = packed_counter + 1; - uppars_counter = uppars_counter + 1; + problemDef.resolutionParams = uppars; + + + %Domain Ratios + uppars = zeros(1,length(problemDef.domainRatio)); + uppars_counter = 1; + for i = 1:length(controls.checks.fitDomainRatio) + if controls.checks.fitDomainRatio(i) == 1 + uppars(uppars_counter) = problemDef.fitpars(unpacked_counter); + unpacked_counter = unpacked_counter + 1; + uppars_counter = uppars_counter + 1; + else + uppars(uppars_counter) = problemDef.otherpars(packed_counter); + packed_counter = packed_counter + 1; + uppars_counter = uppars_counter + 1; + end end -end -problemDef.domainRatio = uppars; + problemDef.domainRatio = uppars; -%setappdata(0,'problem',problem); \ No newline at end of file +end diff --git a/minimisers/simplex/runSimplex.m b/minimisers/simplex/runSimplex.m index f339187c9..66e960297 100644 --- a/minimisers/simplex/runSimplex.m +++ b/minimisers/simplex/runSimplex.m @@ -6,12 +6,12 @@ result = cell(6,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); diff --git a/targetFunctions/+domainsTF/+customLayers/calculate.m b/targetFunctions/+domainsTF/+customLayers/calculate.m index 19a16d637..871fdfefd 100644 --- a/targetFunctions/+domainsTF/+customLayers/calculate.m +++ b/targetFunctions/+domainsTF/+customLayers/calculate.m @@ -17,10 +17,10 @@ numberOfContrasts = problemDef.numberOfContrasts; outSsubs = zeros(numberOfContrasts,1); backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); chis = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); @@ -63,26 +63,26 @@ switch controls.parallel case 'single' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,domainSldProfiles,allLayers,... allRoughs] = domainsTF.customLayers.single(problemDef,problemDefCells,controls); case 'points' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,domainSldProfiles,allLayers,... allRoughs] = domainsTF.customLayers.parallelPoints(problemDef,problemDefCells,controls); case 'contrasts' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,domainSldProfiles,allLayers,... allRoughs] = domainsTF.customLayers.parallelContrasts(problemDef,problemDefCells,controls); end problem.ssubs = outSsubs; -problem.backgrounds = backgs; -problem.qshifts = qshifts; -problem.scalefactors = sfs; -problem.nbairs = nbas; -problem.nbsubs = nbss; -problem.resolutions = resols; +problem.backgroundParams = backgs; +problem.qzshifts = qzshifts; +problem.scalefactors = scalefactors; +problem.bulkIn = bulkIns; +problem.bulkOut = bulkOuts; +problem.resolutionParams = resols; problem.calculations.all_chis = chis; problem.calculations.sum_chi = sum(chis); problem.allSubRough = allRoughs; diff --git a/targetFunctions/+domainsTF/+customLayers/parallelContrasts.m b/targetFunctions/+domainsTF/+customLayers/parallelContrasts.m index b6a7d96a7..19bff9db3 100644 --- a/targetFunctions/+domainsTF/+customLayers/parallelContrasts.m +++ b/targetFunctions/+domainsTF/+customLayers/parallelContrasts.m @@ -1,4 +1,4 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,domainSldProfiles,allLayers,... allRoughs] = parallelContrasts(problemDef,problemDefCells,controls) % Single threaded version of the custom layers, domainsTF reflectivity @@ -16,8 +16,8 @@ ~,~,customFiles] = parseCells(problemDefCells); % Extract individual parameters from problemDef struct -[numberOfContrasts, geometry, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, geometry, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, resample, backsType, cCustFiles] = extractProblemParams(problemDef); calcSld = controls.calcSldDuringFit; @@ -30,10 +30,10 @@ % Pre-Allocation of output arrays... backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -83,8 +83,8 @@ resamPars = controls.resamPars; % Process the custom models.... -[calcAllLayers,allRoughs] = domainsTF.customLayers.processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs, ... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary); +[calcAllLayers,allRoughs] = domainsTF.customLayers.processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs, ... + shifts,scalefactor,bulkIn,bulkOut,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary); % Parallel over all contrasts @@ -102,7 +102,7 @@ % from the input arrays. % First need to decide which values of the backgrounds, scalefactors % data shifts and bulk contrasts are associated with this contrast - [thisBackground,thisQshift,thisSf,thisNba,thisNbs,thisResol] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [thisBackground,thisQzshift,thisScalefactor,thisBulkIn,thisBulkOut,thisResol] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Get the custom layers output for this contrast % We have two for each contrast - one for each domain @@ -130,7 +130,7 @@ [sldProfile1,reflect1,Simul1,shifted_dat,layerSld1,resamLayers1,~,thisSsubs] = ... nonPolarisedTF.coreLayersCalculation... (thisContrastLayers1, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); @@ -138,7 +138,7 @@ [sldProfile2,reflect2,Simul2,~,layerSld2,resamLayers2,~,~] = ... nonPolarisedTF.coreLayersCalculation... (thisContrastLayers2, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); @@ -164,10 +164,10 @@ chis(i) = thisChiSquared; backgs(i) = thisBackground; - qshifts(i) = thisQshift; - sfs(i) = thisSf; - nbas(i) = thisNba; - nbss(i) = thisNbs; + qzshifts(i) = thisQzshift; + scalefactors(i) = thisScalefactor; + bulkIns(i) = thisBulkIn; + bulkOuts(i) = thisBulkOut; resols(i) = thisResol; allRoughs(i) = thisRough; end diff --git a/targetFunctions/+domainsTF/+customLayers/parallelPoints.m b/targetFunctions/+domainsTF/+customLayers/parallelPoints.m index 8b75f9e8e..d3e67d229 100644 --- a/targetFunctions/+domainsTF/+customLayers/parallelPoints.m +++ b/targetFunctions/+domainsTF/+customLayers/parallelPoints.m @@ -1,4 +1,4 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,domainSldProfiles,allLayers,... allRoughs] = parallelPoints(problemDef,problemDefCells,controls) % Single threaded version of the custom layers, domainsTF reflectivity @@ -16,8 +16,8 @@ ~,~,customFiles] = parseCells(problemDefCells); % Extract individual parameters from problemDef struct -[numberOfContrasts, geometry, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, geometry, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, resample, backsType, cCustFiles] = extractProblemParams(problemDef); calcSld = controls.calcSldDuringFit; @@ -30,10 +30,10 @@ % Pre-Allocation of output arrays... backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -83,8 +83,8 @@ resamPars = controls.resamPars; % Process the custom models.... -[calcAllLayers,allRoughs] = domainsTF.customLayers.processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs, ... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary); +[calcAllLayers,allRoughs] = domainsTF.customLayers.processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs, ... + shifts,scalefactor,bulkIn,bulkOut,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary); % Parallel over all contrasts @@ -102,7 +102,7 @@ % from the input arrays. % First need to decide which values of the backgrounds, scalefactors % data shifts and bulk contrasts are associated with this contrast - [thisBackground,thisQshift,thisSf,thisNba,thisNbs,thisResol] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [thisBackground,thisQzshift,thisScalefactor,thisBulkIn,thisBulkOut,thisResol] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Get the custom layers output for this contrast % We have two for each contrast - one for each domain @@ -130,7 +130,7 @@ [sldProfile1,reflect1,Simul1,shifted_dat,layerSld1,resamLayers1,~,thisSsubs] = ... nonPolarisedTF.coreLayersCalculation... (thisContrastLayers1, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); @@ -138,7 +138,7 @@ [sldProfile2,reflect2,Simul2,~,layerSld2,resamLayers2,~,~] = ... nonPolarisedTF.coreLayersCalculation... (thisContrastLayers2, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); @@ -164,10 +164,10 @@ chis(i) = thisChiSquared; backgs(i) = thisBackground; - qshifts(i) = thisQshift; - sfs(i) = thisSf; - nbas(i) = thisNba; - nbss(i) = thisNbs; + qzshifts(i) = thisQzshift; + scalefactors(i) = thisScalefactor; + bulkIns(i) = thisBulkIn; + bulkOuts(i) = thisBulkOut; resols(i) = thisResol; allRoughs(i) = thisRough; end diff --git a/targetFunctions/+domainsTF/+customLayers/processCustomFunction.m b/targetFunctions/+domainsTF/+customLayers/processCustomFunction.m index 1b9337a45..cc2c9428b 100644 --- a/targetFunctions/+domainsTF/+customLayers/processCustomFunction.m +++ b/targetFunctions/+domainsTF/+customLayers/processCustomFunction.m @@ -1,5 +1,5 @@ -function [allLayers,allRoughs] = processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs, ... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary) +function [allLayers,allRoughs] = processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs, ... + shifts,scalefactor,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary) % Top-level function for processing custom layers for all the % contrasts. @@ -11,8 +11,8 @@ allRoughs = zeros(numberOfContrasts,1); for i = 1:numberOfContrasts - allLayers{i,1} = [1 , 1]; % Type def as double (size not important) - allLayers{i,2} = [1 , 1]; + allLayers{i,1} = [1, 1]; % Type def as double (size not important) + allLayers{i,2} = [1, 1]; tempAllLayers{i,1} = [0 0 0 0 0]; tempAllLayers{i,2} = [0 0 0 0 0]; end @@ -26,8 +26,8 @@ % Find values of 'bulkIn' and 'bulkOut' for this % contrast... - [~,~,~,bulkIn,bulkOut,~] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),... - cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [~,~,~,thisBulkIn,thisBulkOut,~] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),... + contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,nba,nbs,res); thisContrastLayers1 = [1 1 1]; % typeDef coder.varsize('thisContrastLayers1',[10000, 6],[1 1]); @@ -36,22 +36,22 @@ coder.varsize('thisContrastLayers2',[10000, 6],[1 1]); if isnan(str2double(functionHandle)) - [thisContrastLayers1, allRoughs(i)] = callMatlabFunction(params,i,functionHandle,bulkIn,bulkOut,numberOfContrasts,1); - [thisContrastLayers2, ~] = callMatlabFunction(params,i,functionHandle,bulkIn,bulkOut,numberOfContrasts,2); + [thisContrastLayers1, allRoughs(i)] = callMatlabFunction(params,i,functionHandle,thisBulkIn,thisBulkOut,numberOfContrasts,1); + [thisContrastLayers2, ~] = callMatlabFunction(params,i,functionHandle,thisBulkIn,thisBulkOut,numberOfContrasts,2); else - [thisContrastLayers1, allRoughs(i)] = callCppFunction(params, bulkIn, bulkOut, i, 0, functionHandle); - [thisContrastLayers2, ~] = callCppFunction(params, bulkIn, bulkOut, i, 1, functionHandle); + [thisContrastLayers1, allRoughs(i)] = callCppFunction(params,thisBulkIn,thisBulkOut,i,0,functionHandle); + [thisContrastLayers2, ~] = callCppFunction(params,thisBulkIn,thisBulkOut,i,1,functionHandle); end % If the output layers has 5 columns, then we need to do % the hydration correction (the user has not done it in the % custom function). Do that here.... if ~useImaginary - thisContrastLayers1 = applyHydrationReal(thisContrastLayers1,bulkIn,bulkOut); - thisContrastLayers2 = applyHydrationReal(thisContrastLayers2,bulkIn,bulkOut); + thisContrastLayers1 = applyHydrationReal(thisContrastLayers1,thisBulkIn,thisBulkOut); + thisContrastLayers2 = applyHydrationReal(thisContrastLayers2,thisBulkIn,thisBulkOut); else - thisContrastLayers1 = applyHydrationImag(thisContrastLayers1,bulkIn,bulkOut); - thisContrastLayers2 = applyHydrationImag(thisContrastLayers2,bulkIn,bulkOut); + thisContrastLayers1 = applyHydrationImag(thisContrastLayers1,thisBulkIn,thisBulkOut); + thisContrastLayers2 = applyHydrationImag(thisContrastLayers2,thisBulkIn,thisBulkOut); end tempAllLayers{i,1} = thisContrastLayers1; diff --git a/targetFunctions/+domainsTF/+customLayers/single.m b/targetFunctions/+domainsTF/+customLayers/single.m index 22e9cbaf3..674b213c7 100644 --- a/targetFunctions/+domainsTF/+customLayers/single.m +++ b/targetFunctions/+domainsTF/+customLayers/single.m @@ -1,4 +1,4 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,domainSldProfiles,allLayers,... allRoughs] = single(problemDef,problemDefCells,controls) % Single threaded version of the custom layers, domainsTF reflectivity @@ -16,8 +16,8 @@ ~,~,customFiles] = parseCells(problemDefCells); % Extract individual parameters from problemDef struct -[numberOfContrasts, geometry, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, geometry, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, resample, backsType, cCustFiles] = extractProblemParams(problemDef); calcSld = controls.calcSldDuringFit; @@ -29,10 +29,10 @@ % Pre-Allocation of output arrays... backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -82,8 +82,8 @@ resamPars = controls.resamPars; % Process the custom models.... -[calcAllLayers,allRoughs] = domainsTF.customLayers.processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs, ... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary); +[calcAllLayers,allRoughs] = domainsTF.customLayers.processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs, ... + shifts,scalefactor,bulkIn,bulkOut,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary); % Parallel over all contrasts %layersCounter = 1; @@ -100,7 +100,7 @@ % from the input arrays. % First need to decide which values of the backgrounds, scalefactors % data shifts and bulk contrasts are associated with this contrast - [thisBackground,thisQshift,thisSf,thisNba,thisNbs,thisResol] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [thisBackground,thisQzshift,thisScalefactor,thisBulkIn,thisBulkOut,thisResol] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Get the custom layers output for this contrast % We have two for each contrast - one for each domain @@ -128,7 +128,7 @@ [sldProfile1,reflect1,Simul1,shifted_dat,layerSld1,resamLayers1,~,thisSsubs] = ... nonPolarisedTF.coreLayersCalculation... (thisContrastLayers1, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); @@ -136,7 +136,7 @@ [sldProfile2,reflect2,Simul2,~,layerSld2,resamLayers2,~,~] = ... nonPolarisedTF.coreLayersCalculation... (thisContrastLayers2, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); @@ -160,10 +160,10 @@ chis(i) = thisChiSquared; backgs(i) = thisBackground; - qshifts(i) = thisQshift; - sfs(i) = thisSf; - nbas(i) = thisNba; - nbss(i) = thisNbs; + qzshifts(i) = thisQzshift; + scalefactors(i) = thisScalefactor; + bulkIns(i) = thisBulkIn; + bulkOuts(i) = thisBulkOut; resols(i) = thisResol; allRoughs(i) = thisRough; end diff --git a/targetFunctions/+domainsTF/+customXY/calculate.m b/targetFunctions/+domainsTF/+customXY/calculate.m index e832cf7c9..07348b1cd 100644 --- a/targetFunctions/+domainsTF/+customXY/calculate.m +++ b/targetFunctions/+domainsTF/+customXY/calculate.m @@ -17,10 +17,10 @@ numberOfContrasts = problemDef.numberOfContrasts; outSsubs = zeros(numberOfContrasts,1); backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); chis = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); @@ -63,26 +63,26 @@ switch controls.parallel case 'single' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,domainSldProfiles,allLayers,... allRoughs] = domainsTF.customXY.single(problemDef,problemDefCells,controls); case 'points' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,domainSldProfiles,allLayers,... allRoughs] = domainsTF.customXY.parallelPoints(problemDef,problemDefCells,controls); case 'contrasts' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,domainSldProfiles,allLayers,... allRoughs] = domainsTF.customXY.parallelContrasts(problemDef,problemDefCells,controls); end problem.ssubs = outSsubs; -problem.backgrounds = backgs; -problem.qshifts = qshifts; -problem.scalefactors = sfs; -problem.nbairs = nbas; -problem.nbsubs = nbss; -problem.resolutions = resols; +problem.backgroundParams = backgs; +problem.qzshifts = qzshifts; +problem.scalefactors = scalefactors; +problem.bulkIn = bulkIns; +problem.bulkOut = bulkOuts; +problem.resolutionParams = resols; problem.calculations.all_chis = chis; problem.calculations.sum_chi = sum(chis); problem.allSubRough = allRoughs; diff --git a/targetFunctions/+domainsTF/+customXY/parallelContrasts.m b/targetFunctions/+domainsTF/+customXY/parallelContrasts.m index 469a7058a..65be0e9b5 100644 --- a/targetFunctions/+domainsTF/+customXY/parallelContrasts.m +++ b/targetFunctions/+domainsTF/+customXY/parallelContrasts.m @@ -1,4 +1,4 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,domainSldProfiles,allLayers,... allRoughs] = parallelContrasts(problemDef,problemDefCells,controls) @@ -12,16 +12,16 @@ customFiles] = parseCells(problemDefCells); % Extract individual parameters from problemDef struct -[numberOfContrasts, ~, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, ~, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, ~, backsType, cCustFiles] = extractProblemParams(problemDef); %Pre-Allocation... backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -74,12 +74,12 @@ domainRatio = 1; % Default for compile. -[domainSldProfiles,allRoughs] = domainsTF.customXY.processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs, ... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params); +[domainSldProfiles,allRoughs] = domainsTF.customXY.processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs, ... + shifts,scalefactor,bulkIn,bulkOut,res,cCustFiles,numberOfContrasts,customFiles,params); for i = 1:numberOfContrasts outSsubs(i) = allRoughs(i); - [backgs(i),qshifts(i),sfs(i),nbas(i),nbss(i),resols(i)] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [backgs(i),qzshifts(i),scalefactors(i),bulkIns(i),bulkOuts(i),resols(i)] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Get the domain ratio for this contrast thisContrastDR = contrastDomainRatios(i); @@ -109,12 +109,12 @@ tempAllLayers{i} = {layerSld1, layerSld2}; tempSldProfiles{i} = {thisSld1, thisSld2}; - shifted_dat = shiftData(sfs(i),qshifts(i),dataPresent(i),allData{i},dataLimits{i},simLimits{i}); + shifted_dat = shiftData(scalefactors(i),qzshifts(i),dataPresent(i),allData{i},dataLimits{i},simLimits{i}); shifted_data{i} = shifted_dat; reflectivityType = 'standardAbeles'; - [reflect1,Simul1] = callReflectivity(nbas(i),nbss(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld1,allRoughs(i),resols(i),'single',reflectivityType,useImaginary); - [reflect2,Simul2] = callReflectivity(nbas(i),nbss(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld2,allRoughs(i),resols(i),'single',reflectivityType,useImaginary); + [reflect1,Simul1] = callReflectivity(bulkIns(i),bulkOuts(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld1,allRoughs(i),resols(i),'single',reflectivityType,useImaginary); + [reflect2,Simul2] = callReflectivity(bulkIns(i),bulkOuts(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld2,allRoughs(i),resols(i),'single',reflectivityType,useImaginary); [reflect1,Simul1,shifted_dat] = applyBackgroundCorrection(reflect1,Simul1,shifted_dat,backgs(i),backsType(i)); [reflect2,Simul2,shifted_dat] = applyBackgroundCorrection(reflect2,Simul2,shifted_dat,backgs(i),backsType(i)); diff --git a/targetFunctions/+domainsTF/+customXY/parallelPoints.m b/targetFunctions/+domainsTF/+customXY/parallelPoints.m index b6dcf473d..f18616c95 100644 --- a/targetFunctions/+domainsTF/+customXY/parallelPoints.m +++ b/targetFunctions/+domainsTF/+customXY/parallelPoints.m @@ -1,4 +1,4 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,domainSldProfiles,allLayers,... allRoughs] = parallelPoints(problemDef,problemDefCells,controls) @@ -12,16 +12,16 @@ customFiles] = parseCells(problemDefCells); % Extract individual parameters from problemDef struct -[numberOfContrasts, ~, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, ~, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, ~, backsType, cCustFiles] = extractProblemParams(problemDef); %Pre-Allocation... backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -74,12 +74,12 @@ domainRatio = 1; % Default for compile. -[domainSldProfiles,allRoughs] = domainsTF.customXY.processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs, ... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params); +[domainSldProfiles,allRoughs] = domainsTF.customXY.processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs, ... + shifts,scalefactor,bulkIn,bulkOut,res,cCustFiles,numberOfContrasts,customFiles,params); for i = 1:numberOfContrasts outSsubs(i) = allRoughs(i); - [backgs(i),qshifts(i),sfs(i),nbas(i),nbss(i),resols(i)] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [backgs(i),qzshifts(i),scalefactors(i),bulkIns(i),bulkOuts(i),resols(i)] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Get the domain ratio for this contrast thisContrastDR = contrastDomainRatios(i); @@ -109,12 +109,12 @@ tempAllLayers{i} = {layerSld1, layerSld2}; tempSldProfiles{i} = {thisSld1, thisSld2}; - shifted_dat = shiftData(sfs(i),qshifts(i),dataPresent(i),allData{i},dataLimits{i},simLimits{i}); + shifted_dat = shiftData(scalefactors(i),qzshifts(i),dataPresent(i),allData{i},dataLimits{i},simLimits{i}); shifted_data{i} = shifted_dat; reflectivityType = 'standardAbeles'; - [reflect1,Simul1] = callReflectivity(nbas(i),nbss(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld1,allRoughs(i),resols(i),'points',reflectivityType,useImaginary); - [reflect2,Simul2] = callReflectivity(nbas(i),nbss(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld2,allRoughs(i),resols(i),'points',reflectivityType,useImaginary); + [reflect1,Simul1] = callReflectivity(bulkIns(i),bulkOuts(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld1,allRoughs(i),resols(i),'points',reflectivityType,useImaginary); + [reflect2,Simul2] = callReflectivity(bulkIns(i),bulkOuts(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld2,allRoughs(i),resols(i),'points',reflectivityType,useImaginary); [reflect1,Simul1,shifted_dat] = applyBackgroundCorrection(reflect1,Simul1,shifted_dat,backgs(i),backsType(i)); [reflect2,Simul2,shifted_dat] = applyBackgroundCorrection(reflect2,Simul2,shifted_dat,backgs(i),backsType(i)); diff --git a/targetFunctions/+domainsTF/+customXY/processCustomFunction.m b/targetFunctions/+domainsTF/+customXY/processCustomFunction.m index c809a94ab..4f34ffcb2 100644 --- a/targetFunctions/+domainsTF/+customXY/processCustomFunction.m +++ b/targetFunctions/+domainsTF/+customXY/processCustomFunction.m @@ -1,5 +1,5 @@ -function [allSLDs,allRoughs] = processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs, ... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params) +function [allSLDs,allRoughs] = processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs, ... + shifts,scalefactor,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params) % Top-level function for processing custom XY profiles for all the % contrasts. @@ -23,14 +23,14 @@ functionHandle = customFiles{cCustFiles(i)}; % Find values of 'bulkIn' and 'bulkOut' for this contrast... - [~,~,~,bulkIn,bulkOut,~] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [~,~,~,thisBulkIn,thisBulkOut,~] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,nba,nbs,res); if isnan(str2double(functionHandle)) - [tempAllSLDs{i, 1}, allRoughs(i)] = callMatlabFunction(params,i,functionHandle,bulkIn,bulkOut,numberOfContrasts,1); - [tempAllSLDs{i, 2}, ~] = callMatlabFunction(params,i,functionHandle,bulkIn,bulkOut,numberOfContrasts,2); + [tempAllSLDs{i, 1}, allRoughs(i)] = callMatlabFunction(params,i,functionHandle,thisBulkIn,thisBulkOut,numberOfContrasts,1); + [tempAllSLDs{i, 2}, ~] = callMatlabFunction(params,i,functionHandle,thisBulkIn,thisBulkOut,numberOfContrasts,2); else - [tempAllSLDs{i, 1}, allRoughs(i)] = callCppFunction(params, bulkIn, bulkOut, i, 0, functionHandle); - [tempAllSLDs{i, 2}, ~] = callCppFunction(params, bulkIn, bulkOut, i, 1, functionHandle); + [tempAllSLDs{i, 1}, allRoughs(i)] = callCppFunction(params,thisBulkIn,thisBulkOut,i,0,functionHandle); + [tempAllSLDs{i, 2}, ~] = callCppFunction(params,thisBulkIn,thisBulkOut,i,1,functionHandle); end end diff --git a/targetFunctions/+domainsTF/+customXY/single.m b/targetFunctions/+domainsTF/+customXY/single.m index 4953f794f..a25b1a318 100644 --- a/targetFunctions/+domainsTF/+customXY/single.m +++ b/targetFunctions/+domainsTF/+customXY/single.m @@ -1,4 +1,4 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,domainSldProfiles,allLayers,... allRoughs] = single(problemDef,problemDefCells,controls) @@ -12,16 +12,16 @@ customFiles] = parseCells(problemDefCells); % Extract individual parameters from problemDef struct -[numberOfContrasts, ~, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, ~, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, ~, backsType, cCustFiles] = extractProblemParams(problemDef); %Pre-Allocation... backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -79,12 +79,12 @@ domainSldProfiles{i,1} = [1 1 ; 1 1]; domainSldProfiles{i,2} = [1 1 ; 1 1]; end -[domainSldProfiles,allRoughs] = domainsTF.customXY.processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs, ... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params); +[domainSldProfiles,allRoughs] = domainsTF.customXY.processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs, ... + shifts,scalefactor,bulkIn,bulkOut,res,cCustFiles,numberOfContrasts,customFiles,params); for i = 1:numberOfContrasts outSsubs(i) = allRoughs(i); - [backgs(i),qshifts(i),sfs(i),nbas(i),nbss(i),resols(i)] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [backgs(i),qzshifts(i),scalefactors(i),bulkIns(i),bulkOuts(i),resols(i)] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Get the domain ratio for this contrast thisContrastDR = contrastDomainRatios(i); @@ -114,12 +114,12 @@ tempAllLayers{i} = {layerSld1, layerSld2}; tempSldProfiles{i} = {thisSld1, thisSld2}; - shifted_dat = shiftData(sfs(i),qshifts(i),dataPresent(i),allData{i},dataLimits{i},simLimits{i}); + shifted_dat = shiftData(scalefactors(i),qzshifts(i),dataPresent(i),allData{i},dataLimits{i},simLimits{i}); shifted_data{i} = shifted_dat; reflectivityType = 'standardAbeles'; - [reflect1,Simul1] = callReflectivity(nbas(i),nbss(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld1,allRoughs(i),resols(i),'single',reflectivityType,useImaginary); - [reflect2,Simul2] = callReflectivity(nbas(i),nbss(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld2,allRoughs(i),resols(i),'single',reflectivityType,useImaginary); + [reflect1,Simul1] = callReflectivity(bulkIns(i),bulkOuts(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld1,allRoughs(i),resols(i),'single',reflectivityType,useImaginary); + [reflect2,Simul2] = callReflectivity(bulkIns(i),bulkOuts(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld2,allRoughs(i),resols(i),'single',reflectivityType,useImaginary); [reflect1,Simul1,shifted_dat] = applyBackgroundCorrection(reflect1,Simul1,shifted_dat,backgs(i),backsType(i)); [reflect2,Simul2,shifted_dat] = applyBackgroundCorrection(reflect2,Simul2,shifted_dat,backgs(i),backsType(i)); diff --git a/targetFunctions/+domainsTF/+standardLayers/calculate.m b/targetFunctions/+domainsTF/+standardLayers/calculate.m index d03207729..80e6732f6 100644 --- a/targetFunctions/+domainsTF/+standardLayers/calculate.m +++ b/targetFunctions/+domainsTF/+standardLayers/calculate.m @@ -17,10 +17,10 @@ numberOfContrasts = problemDef.numberOfContrasts; outSsubs = zeros(numberOfContrasts,1); backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); chis = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); @@ -59,27 +59,27 @@ switch controls.parallel case 'single' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = domainsTF.standardLayers.single(problemDef,problemDefCells,controls); case 'points' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = domainsTF.standardLayers.parallelPoints(problemDef,problemDefCells,controls); case 'contrasts' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = domainsTF.standardLayers.parallelContrasts(problemDef,problemDefCells,controls); end % Package everything into one array for tidy output problem.ssubs = outSsubs; -problem.backgrounds = backgs; -problem.qshifts = qshifts; -problem.scalefactors = sfs; -problem.nbairs = nbas; -problem.nbsubs = nbss; -problem.resolutions = resols; +problem.backgroundParams = backgs; +problem.qzshifts = qzshifts; +problem.scalefactors = scalefactors; +problem.bulkIn = bulkIns; +problem.bulkOut = bulkOuts; +problem.resolutionParams = resols; problem.calculations.all_chis = chis; problem.calculations.sum_chi = sum(chis); problem.allSubRough = allRoughs; diff --git a/targetFunctions/+domainsTF/+standardLayers/parallelContrasts.m b/targetFunctions/+domainsTF/+standardLayers/parallelContrasts.m index 7e7f707aa..9d383099d 100644 --- a/targetFunctions/+domainsTF/+standardLayers/parallelContrasts.m +++ b/targetFunctions/+domainsTF/+standardLayers/parallelContrasts.m @@ -1,4 +1,4 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,domainSldProfiles,allLayers,... allRoughs] = parallelContrasts(problemDef,problemDefCells,controls) % Single threaded version of the Standard Layers calculation @@ -20,8 +20,8 @@ domainContrastLayers = problemDefCells{19}; % Extract individual parameters from problemDef struct -[numberOfContrasts, geometry, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, geometry, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, resample, backsType, ~] = extractProblemParams(problemDef); calcSld = controls.calcSldDuringFit; @@ -33,10 +33,10 @@ % Allocate the memory for the output arrays before the main loop backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -105,7 +105,7 @@ % from the input arrays. % First need to decide which values of the backgrounds, scalefactors % data shifts and bulk contrasts are associated with this contrast - [thisBackground,thisQshift,thisSf,thisNba,thisNbs,thisResol] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [thisBackground,thisQzshift,thisScalefactor,thisBulkIn,thisBulkOut,thisResol] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Also need to determine which layers from the overall layers list % are required for this contrast, and put them in the correct order @@ -132,12 +132,12 @@ % Call the core layers calculation - need to do this once for each % domain [sldProfile1,reflect1,Simul1,shifted_dat,layerSld1,resamLayers1,~,thisSsubs]= nonPolarisedTF.coreLayersCalculation(thisContrastLayers1, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); [sldProfile2,reflect2,Simul2,~,layerSld2,resamLayers2,~,~] = nonPolarisedTF.coreLayersCalculation(thisContrastLayers2, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); @@ -161,10 +161,10 @@ chis(i) = thisChiSquared; backgs(i) = thisBackground; - qshifts(i) = thisQshift; - sfs(i) = thisSf; - nbas(i) = thisNba; - nbss(i) = thisNbs; + qzshifts(i) = thisQzshift; + scalefactors(i) = thisScalefactor; + bulkIns(i) = thisBulkIn; + bulkOuts(i) = thisBulkOut; resols(i) = thisResol; allRoughs(i) = thisRough; end diff --git a/targetFunctions/+domainsTF/+standardLayers/parallelPoints.m b/targetFunctions/+domainsTF/+standardLayers/parallelPoints.m index 94e210aa3..ff14c2dd3 100644 --- a/targetFunctions/+domainsTF/+standardLayers/parallelPoints.m +++ b/targetFunctions/+domainsTF/+standardLayers/parallelPoints.m @@ -1,5 +1,5 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,domainSldProfiles,allLayers,... allRoughs] = parallelPoints(problemDef,problemDefCells,controls) % Single threaded version of the Standard Layers calculation @@ -21,8 +21,8 @@ domainContrastLayers = problemDefCells{19}; % Extract individual parameters from problemDef struct -[numberOfContrasts, geometry, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, geometry, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, resample, backsType, ~] = extractProblemParams(problemDef); calcSld = controls.calcSldDuringFit; @@ -34,10 +34,10 @@ % Allocate the memory for the output arrays before the main loop backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -106,7 +106,7 @@ % from the input arrays. % First need to decide which values of the backgrounds, scalefactors % data shifts and bulk contrasts are associated with this contrast - [thisBackground,thisQshift,thisSf,thisNba,thisNbs,thisResol] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [thisBackground,thisQzshift,thisScalefactor,thisBulkIn,thisBulkOut,thisResol] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Also need to determine which layers from the overall layers list % are required for this contrast, and put them in the correct order @@ -133,12 +133,12 @@ % Call the core layers calculation - need to do this once for each % domain [sldProfile1,reflect1,Simul1,shifted_dat,layerSld1,resamLayers1,~,thisSsubs]= nonPolarisedTF.coreLayersCalculation(thisContrastLayers1, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); [sldProfile2,reflect2,Simul2,~,layerSld2,resamLayers2,~,~] = nonPolarisedTF.coreLayersCalculation(thisContrastLayers2, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); @@ -162,10 +162,10 @@ chis(i) = thisChiSquared; backgs(i) = thisBackground; - qshifts(i) = thisQshift; - sfs(i) = thisSf; - nbas(i) = thisNba; - nbss(i) = thisNbs; + qzshifts(i) = thisQzshift; + scalefactors(i) = thisScalefactor; + bulkIns(i) = thisBulkIn; + bulkOuts(i) = thisBulkOut; resols(i) = thisResol; allRoughs(i) = thisRough; end diff --git a/targetFunctions/+domainsTF/+standardLayers/single.m b/targetFunctions/+domainsTF/+standardLayers/single.m index 4e737e2dd..28b8e8575 100644 --- a/targetFunctions/+domainsTF/+standardLayers/single.m +++ b/targetFunctions/+domainsTF/+standardLayers/single.m @@ -1,5 +1,5 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,domainSldProfiles,allLayers,... allRoughs] = single(problemDef,problemDefCells,controls) % Single threaded version of the Standard Layers calculation @@ -21,8 +21,8 @@ domainContrastLayers = problemDefCells{19}; % Extract individual parameters from problemDef struct -[numberOfContrasts, geometry, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, geometry, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, resample, backsType, ~] = extractProblemParams(problemDef); calcSld = controls.calcSldDuringFit; @@ -34,10 +34,10 @@ % Allocate the memory for the output arrays before the main loop backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -106,7 +106,7 @@ % from the input arrays. % First need to decide which values of the backgrounds, scalefactors % data shifts and bulk contrasts are associated with this contrast - [thisBackground,thisQshift,thisSf,thisNba,thisNbs,thisResol] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [thisBackground,thisQzshift,thisScalefactor,thisBulkIn,thisBulkOut,thisResol] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Also need to determine which layers from the overall layers list % are required for this contrast, and put them in the correct order @@ -133,12 +133,12 @@ % Call the core layers calculation - need to do this once for each % domain [sldProfile1,reflect1,Simul1,shifted_dat,layerSld1,resamLayers1,~,thisSsubs]= nonPolarisedTF.coreLayersCalculation(thisContrastLayers1, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); [sldProfile2,reflect2,Simul2,~,layerSld2,resamLayers2,~,~] = nonPolarisedTF.coreLayersCalculation(thisContrastLayers2, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); @@ -162,10 +162,10 @@ chis(i) = thisChiSquared; backgs(i) = thisBackground; - qshifts(i) = thisQshift; - sfs(i) = thisSf; - nbas(i) = thisNba; - nbss(i) = thisNbs; + qzshifts(i) = thisQzshift; + scalefactors(i) = thisScalefactor; + bulkIns(i) = thisBulkIn; + bulkOuts(i) = thisBulkOut; resols(i) = thisResol; allRoughs(i) = thisRough; end diff --git a/targetFunctions/+domainsTF/reflectivityCalculation.m b/targetFunctions/+domainsTF/reflectivityCalculation.m index e6e58ed46..5078a488d 100644 --- a/targetFunctions/+domainsTF/reflectivityCalculation.m +++ b/targetFunctions/+domainsTF/reflectivityCalculation.m @@ -22,12 +22,12 @@ % some execution paths' error. 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'); diff --git a/targetFunctions/+nonPolarisedTF/+customLayers/calculate.m b/targetFunctions/+nonPolarisedTF/+customLayers/calculate.m index 805f36eea..988dd47ee 100644 --- a/targetFunctions/+nonPolarisedTF/+customLayers/calculate.m +++ b/targetFunctions/+nonPolarisedTF/+customLayers/calculate.m @@ -16,10 +16,10 @@ numberOfContrasts = problemDef.numberOfContrasts; outSsubs = zeros(numberOfContrasts,1); backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); chis = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); @@ -57,26 +57,26 @@ switch controls.parallel case 'single' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = nonPolarisedTF.customLayers.single(problemDef,problemDefCells,controls); case 'points' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = nonPolarisedTF.customLayers.parallelPoints(problemDef,problemDefCells,controls); case 'contrasts' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = nonPolarisedTF.customLayers.parallelContrasts(problemDef,problemDefCells,controls); end problem.ssubs = outSsubs; -problem.backgrounds = backgs; -problem.qshifts = qshifts; -problem.scalefactors = sfs; -problem.nbairs = nbas; -problem.nbsubs = nbss; -problem.resolutions = resols; +problem.backgroundParams = backgs; +problem.qzshifts = qzshifts; +problem.scalefactors = scalefactors; +problem.bulkIn = bulkIns; +problem.bulkOut = bulkOuts; +problem.resolutionParams = resols; problem.calculations.all_chis = chis; problem.calculations.sum_chi = sum(chis); problem.allSubRough = allRoughs; diff --git a/targetFunctions/+nonPolarisedTF/+customLayers/parallelContrasts.m b/targetFunctions/+nonPolarisedTF/+customLayers/parallelContrasts.m index 9c7174446..d6e355863 100644 --- a/targetFunctions/+nonPolarisedTF/+customLayers/parallelContrasts.m +++ b/targetFunctions/+nonPolarisedTF/+customLayers/parallelContrasts.m @@ -1,4 +1,4 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = parallelContrasts(problemDef,problemDefCells,controls) @@ -17,8 +17,8 @@ ~,~,customFiles] = parseCells(problemDefCells); % Extract individual parameters from problemDef struct -[numberOfContrasts, geometry, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, geometry, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, resample, backsType, cCustFiles] = extractProblemParams(problemDef); calcSld = controls.calcSldDuringFit; @@ -26,10 +26,10 @@ % Pre-Allocation of output arrays... backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -59,8 +59,8 @@ resamPars = controls.resamPars; % Process the custom models.... -[allLayers,allRoughs] = nonPolarisedTF.customLayers.processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs, ... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary); +[allLayers,allRoughs] = nonPolarisedTF.customLayers.processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs, ... + shifts,scalefactor,bulkIn,bulkOut,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary); % Multi cored over all contrasts parfor i = 1:numberOfContrasts @@ -69,7 +69,7 @@ % from the input arrays. % First need to decide which values of the backgrounds, scalefactors % data shifts and bulk contrasts are associated with this contrast - [thisBackground,thisQshift,thisSf,thisNba,thisNbs,thisResol] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [thisBackground,thisQzshift,thisScalefactor,thisBulkIn,thisBulkOut,thisResol] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Get the custom layers output for this contrast thisContrastLayers = allLayers{i}; @@ -94,7 +94,7 @@ [sldProfile,reflect,Simul,shifted_dat,layerSld,resamLayers,thisChiSquared,thisSsubs] = ... nonPolarisedTF.coreLayersCalculation... (thisContrastLayers, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); @@ -112,10 +112,10 @@ chis(i) = thisChiSquared; backgs(i) = thisBackground; - qshifts(i) = thisQshift; - sfs(i) = thisSf; - nbas(i) = thisNba; - nbss(i) = thisNbs; + qzshifts(i) = thisQzshift; + scalefactors(i) = thisScalefactor; + bulkIns(i) = thisBulkIn; + bulkOuts(i) = thisBulkOut; resols(i) = thisResol; allRoughs(i) = thisRough; diff --git a/targetFunctions/+nonPolarisedTF/+customLayers/parallelPoints.m b/targetFunctions/+nonPolarisedTF/+customLayers/parallelPoints.m index 962c70ad2..bc105912a 100644 --- a/targetFunctions/+nonPolarisedTF/+customLayers/parallelPoints.m +++ b/targetFunctions/+nonPolarisedTF/+customLayers/parallelPoints.m @@ -1,4 +1,4 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = parallelPoints(problemDef,problemDefCells,controls) % Multi threaded version of the custom layers over reflectivity poimnts @@ -16,8 +16,8 @@ ~,~,customFiles] = parseCells(problemDefCells); % Extract individual parameters from problemDef struct -[numberOfContrasts, geometry, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, geometry, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, resample, backsType, cCustFiles] = extractProblemParams(problemDef); calcSld = controls.calcSldDuringFit; @@ -25,10 +25,10 @@ % Pre-Allocation of output arrays... backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -58,8 +58,8 @@ resamPars = controls.resamPars; % Process the custom models.... -[allLayers,allRoughs] = nonPolarisedTF.customLayers.processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs, ... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary); +[allLayers,allRoughs] = nonPolarisedTF.customLayers.processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs, ... + shifts,scalefactor,bulkIn,bulkOut,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary); % Single cored over all contrasts for i = 1:numberOfContrasts @@ -68,7 +68,7 @@ % from the input arrays. % First need to decide which values of the backgrounds, scalefactors % data shifts and bulk contrasts are associated with this contrast - [thisBackground,thisQshift,thisSf,thisNba,thisNbs,thisResol] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [thisBackground,thisQzshift,thisScalefactor,thisBulkIn,thisBulkOut,thisResol] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Get the custom layers output for this contrast thisContrastLayers = allLayers{i}; @@ -93,7 +93,7 @@ [sldProfile,reflect,Simul,shifted_dat,layerSld,resamLayers,thisChiSquared,thisSsubs] = ... nonPolarisedTF.coreLayersCalculation... (thisContrastLayers, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); @@ -111,10 +111,10 @@ chis(i) = thisChiSquared; backgs(i) = thisBackground; - qshifts(i) = thisQshift; - sfs(i) = thisSf; - nbas(i) = thisNba; - nbss(i) = thisNbs; + qzshifts(i) = thisQzshift; + scalefactors(i) = thisScalefactor; + bulkIns(i) = thisBulkIn; + bulkOuts(i) = thisBulkOut; resols(i) = thisResol; allRoughs(i) = thisRough; diff --git a/targetFunctions/+nonPolarisedTF/+customLayers/processCustomFunction.m b/targetFunctions/+nonPolarisedTF/+customLayers/processCustomFunction.m index a5ef22eaf..8b9734962 100644 --- a/targetFunctions/+nonPolarisedTF/+customLayers/processCustomFunction.m +++ b/targetFunctions/+nonPolarisedTF/+customLayers/processCustomFunction.m @@ -1,5 +1,5 @@ -function [allLayers,allRoughs] = processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs,... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary) +function [allLayers,allRoughs] = processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs,... + shifts,scalefactor,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary) % Top-level function for processing custom layers for all the % contrasts. @@ -23,24 +23,24 @@ % Find values of 'bulkIn' and 'bulkOut' for this % contrast... - [~,~,~,bulkIn,bulkOut,~] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [~,~,~,thisBulkIn,thisBulkOut,~] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,nba,nbs,res); thisContrastLayers = [1 1 1]; % typeDef coder.varsize('thisContrastLayers',[10000, 6],[1 1]); if isnan(str2double(functionHandle)) - [thisContrastLayers,allRoughs(i)] = callMatlabFunction(params,i,functionHandle,bulkIn,bulkOut,numberOfContrasts,0); + [thisContrastLayers,allRoughs(i)] = callMatlabFunction(params,i,functionHandle,thisBulkIn,thisBulkOut,numberOfContrasts,0); else - [thisContrastLayers, allRoughs(i)] = callCppFunction(params, bulkIn, bulkOut, i, -1, functionHandle); + [thisContrastLayers, allRoughs(i)] = callCppFunction(params,thisBulkIn,thisBulkOut,i,-1,functionHandle); end % If the output layers has 5 columns, then we need to do % the hydration correction (the user has not done it in the % custom function). Do that here.... if ~useImaginary - thisContrastLayers = applyHydrationReal(thisContrastLayers,bulkIn,bulkOut); + thisContrastLayers = applyHydrationReal(thisContrastLayers,thisBulkIn,thisBulkOut); else - thisContrastLayers = applyHydrationImag(thisContrastLayers,bulkIn,bulkOut); + thisContrastLayers = applyHydrationImag(thisContrastLayers,thisBulkIn,thisBulkOut); end tempAllLayers{i} = thisContrastLayers; diff --git a/targetFunctions/+nonPolarisedTF/+customLayers/single.m b/targetFunctions/+nonPolarisedTF/+customLayers/single.m index 2267b3750..4bc8516aa 100644 --- a/targetFunctions/+nonPolarisedTF/+customLayers/single.m +++ b/targetFunctions/+nonPolarisedTF/+customLayers/single.m @@ -1,4 +1,4 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = single(problemDef,problemDefCells,controls) % Single threaded version of the custom layers, nonPolarisedTF reflectivity @@ -16,8 +16,8 @@ ~,~,customFiles] = parseCells(problemDefCells); % Extract individual parameters from problemDef struct -[numberOfContrasts, geometry, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, geometry, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, resample, backsType, cCustFiles] = extractProblemParams(problemDef); calcSld = controls.calcSldDuringFit; @@ -25,10 +25,10 @@ % Pre-Allocation of output arrays... backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -58,8 +58,8 @@ resamPars = controls.resamPars; % Process the custom models.... -[allLayers,allRoughs] = nonPolarisedTF.customLayers.processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs, ... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary); +[allLayers,allRoughs] = nonPolarisedTF.customLayers.processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs, ... + shifts,scalefactor,bulkIn,bulkOut,res,cCustFiles,numberOfContrasts,customFiles,params,useImaginary); % Single cored over all contrasts for i = 1:numberOfContrasts @@ -68,7 +68,7 @@ % from the input arrays. % First need to decide which values of the backgrounds, scalefactors % data shifts and bulk contrasts are associated with this contrast - [thisBackground,thisQshift,thisSf,thisNba,thisNbs,thisResol] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [thisBackground,thisQzshift,thisScalefactor,thisBulkIn,thisBulkOut,thisResol] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Get the custom layers output for this contrast thisContrastLayers = allLayers{i}; @@ -93,7 +93,7 @@ [sldProfile,reflect,Simul,shifted_dat,layerSld,resamLayers,thisChiSquared,thisSsubs] = ... nonPolarisedTF.coreLayersCalculation... (thisContrastLayers, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); @@ -111,10 +111,10 @@ chis(i) = thisChiSquared; backgs(i) = thisBackground; - qshifts(i) = thisQshift; - sfs(i) = thisSf; - nbas(i) = thisNba; - nbss(i) = thisNbs; + qzshifts(i) = thisQzshift; + scalefactors(i) = thisScalefactor; + bulkIns(i) = thisBulkIn; + bulkOuts(i) = thisBulkOut; resols(i) = thisResol; allRoughs(i) = thisRough; diff --git a/targetFunctions/+nonPolarisedTF/+customXY/calculate.m b/targetFunctions/+nonPolarisedTF/+customXY/calculate.m index 5d409723e..448860a62 100644 --- a/targetFunctions/+nonPolarisedTF/+customXY/calculate.m +++ b/targetFunctions/+nonPolarisedTF/+customXY/calculate.m @@ -18,10 +18,10 @@ numberOfContrasts = problemDef.numberOfContrasts; outSsubs = zeros(numberOfContrasts,1); backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); chis = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); @@ -58,26 +58,26 @@ switch controls.parallel case 'single' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = nonPolarisedTF.customXY.single(problemDef,problemDefCells,controls); case 'points' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = nonPolarisedTF.customXY.parallelPoints(problemDef,problemDefCells,controls); case 'contrasts' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = nonPolarisedTF.customXY.parallelContrasts(problemDef,problemDefCells,controls); end problem.ssubs = outSsubs; -problem.backgrounds = backgs; -problem.qshifts = qshifts; -problem.scalefactors = sfs; -problem.nbairs = nbas; -problem.nbsubs = nbss; -problem.resolutions = resols; +problem.backgroundParams = backgs; +problem.qzshifts = qzshifts; +problem.scalefactors = scalefactors; +problem.bulkIn = bulkIns; +problem.bulkOut = bulkOuts; +problem.resolutionParams = resols; problem.calculations.all_chis = chis; problem.calculations.sum_chi = sum(chis); problem.allSubRough = allRoughs; diff --git a/targetFunctions/+nonPolarisedTF/+customXY/parallelContrasts.m b/targetFunctions/+nonPolarisedTF/+customXY/parallelContrasts.m index 5c0c1b0e9..37f04f766 100644 --- a/targetFunctions/+nonPolarisedTF/+customXY/parallelContrasts.m +++ b/targetFunctions/+nonPolarisedTF/+customXY/parallelContrasts.m @@ -1,4 +1,4 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = parallelContrasts(problemDef,problemDefCells,controls) @@ -12,16 +12,16 @@ customFiles] = parseCells(problemDefCells); % Extract individual parameters from problemDef struct -[numberOfContrasts, ~, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, ~, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, ~, backsType, cCustFiles] = extractProblemParams(problemDef); %Pre-Allocation... backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -54,11 +54,11 @@ resamPars = controls.resamPars; useImaginary = problemDef.useImaginary; -[sldProfiles,allRoughs] = nonPolarisedTF.customXY.processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs, ... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params); +[sldProfiles,allRoughs] = nonPolarisedTF.customXY.processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs, ... + shifts,scalefactor,bulkIn,bulkOut,res,cCustFiles,numberOfContrasts,customFiles,params); parfor i = 1:numberOfContrasts - [backgs(i),qshifts(i),sfs(i),nbas(i),nbss(i),resols(i)] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [backgs(i),qzshifts(i),scalefactors(i),bulkIns(i),bulkOuts(i),resols(i)] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Resample the layers thisSld = sldProfiles{i}; @@ -73,11 +73,11 @@ layerSlds{i} = layerSld; allLayers{i} = layerSld; - shifted_dat = shiftData(sfs(i),qshifts(i),dataPresent(i),allData{i},dataLimits{i},simLimits{i}); + shifted_dat = shiftData(scalefactors(i),qzshifts(i),dataPresent(i),allData{i},dataLimits{i},simLimits{i}); shifted_data{i} = shifted_dat; reflectivityType = 'standardAbeles'; - [reflect,Simul] = callReflectivity(nbas(i),nbss(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld,outSsubs(i),resols(i),'single',reflectivityType,useImaginary); + [reflect,Simul] = callReflectivity(bulkIns(i),bulkOuts(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld,outSsubs(i),resols(i),'single',reflectivityType,useImaginary); [reflect,Simul,shifted_dat] = applyBackgroundCorrection(reflect,Simul,shifted_dat,backgs(i),backsType(i)); diff --git a/targetFunctions/+nonPolarisedTF/+customXY/parallelPoints.m b/targetFunctions/+nonPolarisedTF/+customXY/parallelPoints.m index 2127eed42..4605cba3b 100644 --- a/targetFunctions/+nonPolarisedTF/+customXY/parallelPoints.m +++ b/targetFunctions/+nonPolarisedTF/+customXY/parallelPoints.m @@ -1,4 +1,4 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = parallelPoints(problemDef,problemDefCells,controls) @@ -14,16 +14,16 @@ customFiles] = parseCells(problemDefCells); % Extract individual parameters from problemDef struct -[numberOfContrasts, ~, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, ~, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, ~, backsType, cCustFiles] = extractProblemParams(problemDef); %Pre-Allocation... backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -56,11 +56,11 @@ resamPars = controls.resamPars; useImaginary = problemDef.useImaginary; -[sldProfiles,allRoughs] = nonPolarisedTF.customXY.processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs, ... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params); +[sldProfiles,allRoughs] = nonPolarisedTF.customXY.processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs, ... + shifts,scalefactor,bulkIn,bulkOut,res,cCustFiles,numberOfContrasts,customFiles,params); for i = 1:numberOfContrasts - [backgs(i),qshifts(i),sfs(i),nbas(i),nbss(i),resols(i)] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [backgs(i),qzshifts(i),scalefactors(i),bulkIns(i),bulkOuts(i),resols(i)] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Resample the layers thisSld = sldProfiles{i}; @@ -75,11 +75,11 @@ layerSlds{i} = layerSld; allLayers{i} = layerSld; - shifted_dat = shiftData(sfs(i),qshifts(i),dataPresent(i),allData{i},dataLimits{i},simLimits{i}); + shifted_dat = shiftData(scalefactors(i),qzshifts(i),dataPresent(i),allData{i},dataLimits{i},simLimits{i}); shifted_data{i} = shifted_dat; reflectivityType = 'standardAbeles'; - [reflect,Simul] = callReflectivity(nbas(i),nbss(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld,outSsubs(i),resols(i),'points',reflectivityType,useImaginary); + [reflect,Simul] = callReflectivity(bulkIns(i),bulkOuts(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld,outSsubs(i),resols(i),'points',reflectivityType,useImaginary); [reflect,Simul,shifted_dat] = applyBackgroundCorrection(reflect,Simul,shifted_dat,backgs(i),backsType(i)); diff --git a/targetFunctions/+nonPolarisedTF/+customXY/processCustomFunction.m b/targetFunctions/+nonPolarisedTF/+customXY/processCustomFunction.m index 394b88943..5f0c67699 100644 --- a/targetFunctions/+nonPolarisedTF/+customXY/processCustomFunction.m +++ b/targetFunctions/+nonPolarisedTF/+customXY/processCustomFunction.m @@ -1,5 +1,5 @@ -function [allSLDs,allRoughs] = processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs,... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params) +function [allSLDs,allRoughs] = processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs,... + shifts,scalefactor,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params) % Top-level function for processing custom XY profiles for all the % contrasts. @@ -22,12 +22,12 @@ % Find values of 'bulkIn' and 'bulkOut' for this % contrast... - [~,~,~,bulkIn,bulkOut,~] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [~,~,~,thisBulkIn,thisBulkOut,~] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,nba,nbs,res); if isnan(str2double(functionHandle)) - [tempAllSLDs{i}, allRoughs(i)] = callMatlabFunction(params,i,functionHandle,bulkIn,bulkOut,numberOfContrasts,0); + [tempAllSLDs{i}, allRoughs(i)] = callMatlabFunction(params,i,functionHandle,thisBulkIn,thisBulkOut,numberOfContrasts,0); else - [tempAllSLDs{i}, allRoughs(i)] = callCppFunction(params, bulkIn, bulkOut, i, -1, functionHandle); + [tempAllSLDs{i}, allRoughs(i)] = callCppFunction(params,thisBulkIn,thisBulkOut,i,-1,functionHandle); end end diff --git a/targetFunctions/+nonPolarisedTF/+customXY/single.m b/targetFunctions/+nonPolarisedTF/+customXY/single.m index 0a936dfab..3197bc4c5 100644 --- a/targetFunctions/+nonPolarisedTF/+customXY/single.m +++ b/targetFunctions/+nonPolarisedTF/+customXY/single.m @@ -1,4 +1,4 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = single(problemDef,problemDefCells,controls) @@ -12,16 +12,16 @@ customFiles] = parseCells(problemDefCells); % Extract individual parameters from problemDef struct -[numberOfContrasts, ~, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, ~, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, ~, backsType, cCustFiles] = extractProblemParams(problemDef); %Pre-Allocation... backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -54,11 +54,11 @@ resamPars = controls.resamPars; useImaginary = problemDef.useImaginary; -[sldProfiles,allRoughs] = nonPolarisedTF.customXY.processCustomFunction(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs, ... - shifts,sf,nba,nbs,res,cCustFiles,numberOfContrasts,customFiles,params); +[sldProfiles,allRoughs] = nonPolarisedTF.customXY.processCustomFunction(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs, ... + shifts,scalefactor,bulkIn,bulkOut,res,cCustFiles,numberOfContrasts,customFiles,params); for i = 1:numberOfContrasts - [backgs(i),qshifts(i),sfs(i),nbas(i),nbss(i),resols(i)] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [backgs(i),qzshifts(i),scalefactors(i),bulkIns(i),bulkOuts(i),resols(i)] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Resample the layers thisSld = sldProfiles{i}; @@ -73,11 +73,11 @@ layerSlds{i} = layerSld; allLayers{i} = layerSld; - shifted_dat = shiftData(sfs(i),qshifts(i),dataPresent(i),allData{i},dataLimits{i},simLimits{i}); + shifted_dat = shiftData(scalefactors(i),qzshifts(i),dataPresent(i),allData{i},dataLimits{i},simLimits{i}); shifted_data{i} = shifted_dat; reflectivityType = 'standardAbeles'; - [reflect,Simul] = callReflectivity(nbas(i),nbss(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld,outSsubs(i),resols(i),'single',reflectivityType,useImaginary); + [reflect,Simul] = callReflectivity(bulkIns(i),bulkOuts(i),simLimits{i},repeatLayers{i},shifted_dat,layerSld,outSsubs(i),resols(i),'single',reflectivityType,useImaginary); [reflect,Simul,shifted_dat] = applyBackgroundCorrection(reflect,Simul,shifted_dat,backgs(i),backsType(i)); diff --git a/targetFunctions/+nonPolarisedTF/+standardLayers/calculate.m b/targetFunctions/+nonPolarisedTF/+standardLayers/calculate.m index b8e6194f5..cbfc6d4bb 100644 --- a/targetFunctions/+nonPolarisedTF/+standardLayers/calculate.m +++ b/targetFunctions/+nonPolarisedTF/+standardLayers/calculate.m @@ -17,10 +17,10 @@ numberOfContrasts = problemDef.numberOfContrasts; outSsubs = zeros(numberOfContrasts,1); backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); chis = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); @@ -59,27 +59,27 @@ switch controls.parallel case 'single' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = nonPolarisedTF.standardLayers.single(problemDef,problemDefCells,controls); case 'points' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = nonPolarisedTF.standardLayers.parallelPoints(problemDef,problemDefCells,controls); case 'contrasts' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = nonPolarisedTF.standardLayers.parallelContrasts(problemDef,problemDefCells,controls); end % Package everything into one array for tidy output problem.ssubs = outSsubs; -problem.backgrounds = backgs; -problem.qshifts = qshifts; -problem.scalefactors = sfs; -problem.nbairs = nbas; -problem.nbsubs = nbss; -problem.resolutions = resols; +problem.backgroundParams = backgs; +problem.qzshifts = qzshifts; +problem.scalefactors = scalefactors; +problem.bulkIn = bulkIns; +problem.bulkOut = bulkOuts; +problem.resolutionParams = resols; problem.calculations.all_chis = chis; problem.calculations.sum_chi = sum(chis); problem.allSubRough = allRoughs; diff --git a/targetFunctions/+nonPolarisedTF/+standardLayers/parallelContrasts.m b/targetFunctions/+nonPolarisedTF/+standardLayers/parallelContrasts.m index 5744d4472..17e53c650 100644 --- a/targetFunctions/+nonPolarisedTF/+standardLayers/parallelContrasts.m +++ b/targetFunctions/+nonPolarisedTF/+standardLayers/parallelContrasts.m @@ -1,5 +1,5 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = parallelContrasts(problemDef,problemDefCells,controls) % Standard Layers calculation paralelised over the outer loop @@ -18,8 +18,8 @@ layersDetails,~] = parseCells(problemDefCells); % Extract individual parameters from problemDef struct -[numberOfContrasts, geometry, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, geometry, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, resample, backsType, ~] = extractProblemParams(problemDef); calcSld = controls.calcSldDuringFit; @@ -27,10 +27,10 @@ % Allocate the memory for the output arrays before the main loop backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -71,7 +71,7 @@ % from the input arrays. % First need to decide which values of the backgrounds, scalefactors % data shifts and bulk contrasts are associated with this contrast - [thisBackground,thisQshift,thisSf,thisNba,thisNbs,thisResol] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [thisBackground,thisQzshift,thisScalefactor,thisBulkIn,thisBulkOut,thisResol] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Also need to determine which layers from the overall layers list % are required for this contrast, and put them in the correct order @@ -97,7 +97,7 @@ % Call the core layers calculation [sldProfile,reflect,Simul,shifted_dat,layerSld,resampledLayers,... thisChiSquared,thisSsubs] = nonPolarisedTF.coreLayersCalculation(thisContrastLayers, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); @@ -113,10 +113,10 @@ layerSlds{i} = layerSld; chis(i) = thisChiSquared; backgs(i) = thisBackground; - qshifts(i) = thisQshift; - sfs(i) = thisSf; - nbas(i) = thisNba; - nbss(i) = thisNbs; + qzshifts(i) = thisQzshift; + scalefactors(i) = thisScalefactor; + bulkIns(i) = thisBulkIn; + bulkOuts(i) = thisBulkOut; resols(i) = thisResol; allRoughs(i) = thisRough; allLayers{i} = resampledLayers; diff --git a/targetFunctions/+nonPolarisedTF/+standardLayers/parallelPoints.m b/targetFunctions/+nonPolarisedTF/+standardLayers/parallelPoints.m index 3df8cd4e2..74449119b 100644 --- a/targetFunctions/+nonPolarisedTF/+standardLayers/parallelPoints.m +++ b/targetFunctions/+nonPolarisedTF/+standardLayers/parallelPoints.m @@ -1,5 +1,5 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = parallelPoints(problemDef,problemDefCells,controls) % Standard Layers calculation paralelised over the inner loop @@ -19,8 +19,8 @@ layersDetails,~] = parseCells(problemDefCells); % Extract individual parameters from problemDef struct -[numberOfContrasts, geometry, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, geometry, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, resample, backsType, ~] = extractProblemParams(problemDef); calcSld = controls.calcSldDuringFit; @@ -28,10 +28,10 @@ % Allocate the memory for the output arrays before the main loop backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -72,7 +72,7 @@ % from the input arrays. % First need to decide which values of the backgrounds, scalefactors % data shifts and bulk contrasts are associated with this contrast - [thisBackground,thisQshift,thisSf,thisNba,thisNbs,thisResol] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [thisBackground,thisQzshift,thisScalefactor,thisBulkIn,thisBulkOut,thisResol] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Also need to determine which layers from the overall layers list % are required for this contrast, and put them in the correct order @@ -98,7 +98,7 @@ % Call the core layers calculation [sldProfile,reflect,Simul,shifted_dat,layerSld,resampledLayers,... thisChiSquared,thisSsubs] = nonPolarisedTF.coreLayersCalculation(thisContrastLayers, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); @@ -114,10 +114,10 @@ layerSlds{i} = layerSld; chis(i) = thisChiSquared; backgs(i) = thisBackground; - qshifts(i) = thisQshift; - sfs(i) = thisSf; - nbas(i) = thisNba; - nbss(i) = thisNbs; + qzshifts(i) = thisQzshift; + scalefactors(i) = thisScalefactor; + bulkIns(i) = thisBulkIn; + bulkOuts(i) = thisBulkOut; resols(i) = thisResol; allRoughs(i) = thisRough; allLayers{i} = resampledLayers; diff --git a/targetFunctions/+nonPolarisedTF/+standardLayers/single.m b/targetFunctions/+nonPolarisedTF/+standardLayers/single.m index c16880b1a..4bdec5985 100644 --- a/targetFunctions/+nonPolarisedTF/+standardLayers/single.m +++ b/targetFunctions/+nonPolarisedTF/+standardLayers/single.m @@ -1,5 +1,5 @@ -function [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... +function [outSsubs,backgs,qzshifts,scalefactors,bulkIns,bulkOuts,resols,chis,reflectivity,... Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = single(problemDef,problemDefCells,controls) % Single threaded version of the Standard Layers calculation @@ -19,8 +19,8 @@ layersDetails,~] = parseCells(problemDefCells); % Extract individual parameters from problemDef struct -[numberOfContrasts, geometry, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... +[numberOfContrasts, geometry, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... ~, resample, backsType, ~] = extractProblemParams(problemDef); calcSld = controls.calcSldDuringFit; @@ -28,10 +28,10 @@ % Allocate the memory for the output arrays before the main loop backgs = zeros(numberOfContrasts,1); -qshifts = zeros(numberOfContrasts,1); -sfs = zeros(numberOfContrasts,1); -nbas = zeros(numberOfContrasts,1); -nbss = zeros(numberOfContrasts,1); +qzshifts = zeros(numberOfContrasts,1); +scalefactors = zeros(numberOfContrasts,1); +bulkIns = zeros(numberOfContrasts,1); +bulkOuts = zeros(numberOfContrasts,1); resols = zeros(numberOfContrasts,1); allRoughs = zeros(numberOfContrasts,1); outSsubs = zeros(numberOfContrasts,1); @@ -72,7 +72,7 @@ % from the input arrays. % First need to decide which values of the backgrounds, scalefactors % data shifts and bulk contrasts are associated with this contrast - [thisBackground,thisQshift,thisSf,thisNba,thisNbs,thisResol] = backSort(cBacks(i),cShifts(i),cScales(i),cNbas(i),cNbss(i),cRes(i),backs,shifts,sf,nba,nbs,res); + [thisBackground,thisQzshift,thisScalefactor,thisBulkIn,thisBulkOut,thisResol] = backSort(contrastBackgrounds(i),contrastQzshifts(i),contrastScalefactors(i),contrastBulkIns(i),contrastBulkOuts(i),contrastResolutions(i),backs,shifts,scalefactor,bulkIn,bulkOut,res); % Also need to determine which layers from the overall layers list % are required for this contrast, and put them in the correct order @@ -98,7 +98,7 @@ % Call the core layers calculation [sldProfile,reflect,Simul,shifted_dat,layerSld,resampledLayers,... thisChiSquared,thisSsubs] = nonPolarisedTF.coreLayersCalculation(thisContrastLayers, thisRough, ... - geometry, thisNba, thisNbs, thisResample, calcSld, thisSf, thisQshift,... + geometry, thisBulkIn, thisBulkOut, thisResample, calcSld, thisScalefactor, thisQzshift,... thisDataPresent, thisData, thisDataLimits, thisSimLimits, thisRepeatLayers,... thisBackground,thisResol,thisBacksType,nParams,parallelPoints,resamPars,useImaginary); @@ -114,10 +114,10 @@ layerSlds{i} = layerSld; chis(i) = thisChiSquared; backgs(i) = thisBackground; - qshifts(i) = thisQshift; - sfs(i) = thisSf; - nbas(i) = thisNba; - nbss(i) = thisNbs; + qzshifts(i) = thisQzshift; + scalefactors(i) = thisScalefactor; + bulkIns(i) = thisBulkIn; + bulkOuts(i) = thisBulkOut; resols(i) = thisResol; allRoughs(i) = thisRough; allLayers{i} = resampledLayers; diff --git a/targetFunctions/+nonPolarisedTF/coreLayersCalculation.m b/targetFunctions/+nonPolarisedTF/coreLayersCalculation.m index 4802a5f96..7c78253a0 100644 --- a/targetFunctions/+nonPolarisedTF/coreLayersCalculation.m +++ b/targetFunctions/+nonPolarisedTF/coreLayersCalculation.m @@ -1,6 +1,6 @@ function [sldProfile,reflect,Simul,shifted_dat,theseLayers,resamLayers,chiSq,ssubs] = ... coreLayersCalculation(contrastLayers, rough, ... - geometry, nba, nbs, resample, calcSld, sf, qshift,... + geometry, bulkIn, bulkOut, resample, calcSld, scalefactor, qzshift,... dataPresent, data, dataLimits, simLimits, repeatLayers,... background,resol,backsType,params,parallelPoints,resamPars,useImaginary) @@ -25,12 +25,12 @@ % contrastLayers : % rough : % geometry : -% nba : -% nbs : +% bulkIn : +% bulkOut : % resample : % calcSld : -% sf : -% qshift : +% scalefactor : +% qzshift : % dataPresent : % data : % dataLimits : @@ -64,9 +64,9 @@ % Bulid up the layers matrix for this contrast if ~useImaginary - [theseLayers, ssubs] = groupLayersMod(contrastLayers,rough,geometry,nba,nbs); + [theseLayers, ssubs] = groupLayersMod(contrastLayers,rough,geometry,bulkIn,bulkOut); else - [theseLayers, ssubs] = groupLayersModImaginary(contrastLayers,rough,geometry,nba,nbs); + [theseLayers, ssubs] = groupLayersModImaginary(contrastLayers,rough,geometry,bulkIn,bulkOut); end % Make the SLD profiles. @@ -88,12 +88,12 @@ thisSldLays = theseLayers; end - sldProfile = makeSLDProfiles(nba,nbs,thisSldLays,ssubs,repeatLayers); + sldProfile = makeSLDProfiles(bulkIn,bulkOut,thisSldLays,ssubs,repeatLayers); % If we have imaginary, we are also % going to need an SLD profile for the imaginary part if useImaginary - % Note nba and nbs = 0 since there is never any imaginary part for + % Note bulkIn and bulkOut = 0 since there is never any imaginary part for % the bulk phases.. sldProfileIm = makeSLDProfiles(0,0,thisSldLaysIm,ssubs,repeatLayers); end @@ -116,11 +116,11 @@ end % Apply scale factors and q shifts to the data -shifted_dat = shiftData(sf,qshift,dataPresent,data,dataLimits,simLimits); +shifted_dat = shiftData(scalefactor,qzshift,dataPresent,data,dataLimits,simLimits); % Calculate the reflectivity reflectivityType = 'standardAbeles'; -[reflect,Simul] = callReflectivity(nba,nbs,simLimits,repeatLayers,shifted_dat,layerSld,ssubs,resol,parallelPoints,reflectivityType,useImaginary); +[reflect,Simul] = callReflectivity(bulkIn,bulkOut,simLimits,repeatLayers,shifted_dat,layerSld,ssubs,resol,parallelPoints,reflectivityType,useImaginary); % Apply background correction, either to the simulation or the data [reflect,Simul,shifted_dat] = applyBackgroundCorrection(reflect,Simul,shifted_dat,background,backsType); diff --git a/targetFunctions/+nonPolarisedTF/reflectivityCalculation.m b/targetFunctions/+nonPolarisedTF/reflectivityCalculation.m index 566af021e..98b79b8f4 100644 --- a/targetFunctions/+nonPolarisedTF/reflectivityCalculation.m +++ b/targetFunctions/+nonPolarisedTF/reflectivityCalculation.m @@ -22,12 +22,12 @@ % some execution paths' error. 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'); diff --git a/targetFunctions/common/backSort.m b/targetFunctions/common/backSort.m index 3f0022f59..3ee55dd2c 100644 --- a/targetFunctions/common/backSort.m +++ b/targetFunctions/common/backSort.m @@ -1,63 +1,56 @@ -function [backg,qshift,sf,nba,nbs,resol] = backSort(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs,shifts,sf,nba,nbs,res) +function [outBackground,outQzshift,outScalefactor,outBulkIn,outBulkOut,outResolution] = backSort(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs,qzshifts,scalefactor,bulkIn,bulkOut,res) % Distributes the background and shift values among the different contrasts % % USAGE:: % -% [backg,qshift,sf,nba,nbs,resol] = backsort(cBacks,cShifts,cScales,cNbas,cNbss,cRes,backs,shifts,sf,nba,nbs,res) +% [backg,qzshift,scalefactor,bulkIn,bulkOut,resol] = backsort(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs,shifts,scalefactor,bulkIn,bulkOut,res) % % INPUTS: -% * cBacks : Which backround value is associated with each contrast -% * cShifts : Which qz_shift value is associated with each contrast -% * cScales : Which scalefactor value is associated with each contrast -% * cNbas : Which NBa value is associated with each contrast -% * cNbss : Which Nbs value is associated with each contrast -% * cRes : Which resolution value is associated with each contrast -% * backs : List of all background values. -% * shifts : List of all qz-shift values -% * sf : List of all scalefactor values -% * nba : List of all nba values -% * nbs : List of all nbs values -% * res : List of all resolution values +% * contrastBackgrounds : Which backround value is associated with each contrast +% * contrastQzshifts : Which qz_shift value is associated with each contrast +% * contrastScalefactors : Which scalefactor value is associated with each contrast +% * contrastBulkIns : Which BulkIn value is associated with each contrast +% * contrastBulkOuts : Which BulkOut value is associated with each contrast +% * contrastResolutions : Which resolution value is associated with each contrast +% * backs : List of all background values. +% * shifts : List of all qzshift values +% * scalefactor : List of all scalefactor values +% * bulkIn : List of all bulkIn values +% * bulkOut : List of all bulkOut values +% * res : List of all resolution values % % OUTPUTS: % * backgs : list of actual background values for each contrast -% * qshifts : list of actual shift values for each contrast -% * sfs : list of actual shift values for each contrast -% * nbas : list of actual shift values for each contrast -% * nbss : list of actual shift values for each contrast -% * nbss : list of actual shift values for each contrast +% * qzshifts : list of actual shift values for each contrast +% * scalefactors : list of actual shift values for each contrast +% * bulkIns : list of actual shift values for each contrast +% * bulkOuts : list of actual shift values for each contrast +% * bulkOuts : list of actual shift values for each contrast % % - - - - + %for i = 1:nc + %thisBack = contrastBackgrounds(i); + outBackground = backs(contrastBackgrounds); + + %thisShift = contrastQzshifts(i); + outQzshift = qzshifts(contrastQzshifts); + + %thisScale = contrastScalefactors(i); + outScalefactor = scalefactor(contrastScalefactors); + + %thisBulkIn = contrastBulkIns(i); + outBulkIn = bulkIn(contrastBulkIns); + %thisBulkOut = contrastBulkOuts(i); + outBulkOut = bulkOut(contrastBulkOuts); - %for i = 1:nc - %thisBack = cBacks(i); - backg = backs(cBacks); - - %thisShift = cShifts(i); - qshift = shifts(cShifts); - - %thisScale = cScales(i); - sf = sf(cScales); - - %thisNbair = cNbas(i); - nba = nba(cNbas); - - %thisNbsub = cNbss(i); - nbs = nbs(cNbss); - - %thisResol = cRes(i); - if cRes ~= -1 - resol = res(cRes); - else - resol = -1; % Negative value means we have a data resolution.. - end - %end - - - end \ No newline at end of file + %thisResol = contrastResolutions(i); + if contrastResolutions ~= -1 + outResolution = res(contrastResolutions); + else + outResolution = -1; % Negative value means we have a data resolution.. + end + %end + +end diff --git a/targetFunctions/common/callReflectivity/callReflectivity.m b/targetFunctions/common/callReflectivity/callReflectivity.m index 1ea6e2b1b..233a4ff85 100644 --- a/targetFunctions/common/callReflectivity/callReflectivity.m +++ b/targetFunctions/common/callReflectivity/callReflectivity.m @@ -1,4 +1,4 @@ -function [reflectivity, Simulation] = callReflectivity(nbairs,nbsubs,simLimits,repeatLayers,this_data,layers,ssubs,res,parallel,refType,useImaginary) +function [reflectivity, Simulation] = callReflectivity(bulkIns,bulkOuts,simLimits,repeatLayers,this_data,layers,ssubs,res,parallel,refType,useImaginary) xdata = this_data(:,1); @@ -15,7 +15,7 @@ if isempty(layers) % No layers defined. Make a zeros dummy zero layer - layers = [0 nbairs 0]; + layers = [0 bulkIns 0]; end nLayers = size(layers,1); @@ -53,8 +53,8 @@ end % Add the air and substrate parameters -slds(1) = nbairs; -slds(end) = nbsubs; +slds(1) = bulkIns; +slds(end) = bulkOuts; roughs(end) = ssubs; simXLo = simLimits(1); diff --git a/targetFunctions/common/customModelFunctions/callCppFunction.m b/targetFunctions/common/customModelFunctions/callCppFunction.m index 4f7cc0422..ad6d4627d 100644 --- a/targetFunctions/common/customModelFunctions/callCppFunction.m +++ b/targetFunctions/common/customModelFunctions/callCppFunction.m @@ -1,4 +1,4 @@ -function [output,subRough] = callCppFunction(params, nba, nbs, contrast, domain, pointer) +function [output,subRough] = callCppFunction(params, bulkIn, bulkOut, contrast, domain, pointer) coder.cinclude(''); coder.cinclude('classHandle.hpp') @@ -15,11 +15,11 @@ % domain should either before 0 or 1. A value less than zero indicates no domains if (domain < 0) coder.ceval('std::mem_fn(&CallbackInterface::invoke)', ... - callback, coder.ref(params), coder.ref(nba), coder.ref(nbs), contrast, coder.wref(tempOutput), ... + callback, coder.ref(params), coder.ref(bulkIn), coder.ref(bulkOut), contrast, coder.wref(tempOutput), ... coder.wref(outputSize), coder.wref(subRough)); else coder.ceval('std::mem_fn(&CallbackInterface::invoke)', ... - callback, coder.ref(params), coder.ref(nba), coder.ref(nbs), contrast, domain, coder.wref(tempOutput), ... + callback, coder.ref(params), coder.ref(bulkIn), coder.ref(bulkOut), contrast, domain, coder.wref(tempOutput), ... coder.wref(outputSize), coder.wref(subRough)); end diff --git a/targetFunctions/common/extractProblemParams.m b/targetFunctions/common/extractProblemParams.m index 504917e07..801a064c7 100644 --- a/targetFunctions/common/extractProblemParams.m +++ b/targetFunctions/common/extractProblemParams.m @@ -1,30 +1,30 @@ -function [numberOfContrasts, geometry, cBacks, cShifts, cScales, cNbas, cNbss,... -cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... -numberOfLayers, resample, backsType, cFiles] = extractProblemParams(problemDef) +function [numberOfContrasts, geometry, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... +contrastResolutions, backs, shifts, scalefactor, bulkIn, bulkOut, res, dataPresent, nParams, params,... +numberOfLayers, resample, backsType, contrastCustomFiles] = extractProblemParams(problemDef) %Extract individual parameters from problemDef numberOfContrasts = problemDef.numberOfContrasts; geometry = problemDef.geometry; -cBacks = problemDef.contrastBackgrounds; -cShifts = problemDef.contrastQzshifts; -cScales = problemDef.contrastScalefactors; -cNbas = problemDef.contrastBulkIns; -cNbss = problemDef.contrastBulkOuts; -cRes = problemDef.contrastResolutions; -backs = problemDef.backs; -shifts = problemDef.shifts; -sf = problemDef.sf; -nba = problemDef.nba; -nbs = problemDef.nbs; -res = problemDef.res; +contrastBackgrounds = problemDef.contrastBackgrounds; +contrastQzshifts = problemDef.contrastQzshifts; +contrastScalefactors = problemDef.contrastScalefactors; +contrastBulkIns = problemDef.contrastBulkIns; +contrastBulkOuts = problemDef.contrastBulkOuts; +contrastResolutions = problemDef.contrastResolutions; +backs = problemDef.backgroundParams; +shifts = problemDef.qzshifts; +scalefactor = problemDef.scalefactors; +bulkIn = problemDef.bulkIn; +bulkOut = problemDef.bulkOut; +res = problemDef.resolutionParams; dataPresent = problemDef.dataPresent; nParams = length(problemDef.params); params = problemDef.params; numberOfLayers = problemDef.numberOfLayers; resample = problemDef.resample; backsType = problemDef.contrastBackgroundsType; -cFiles = problemDef.contrastCustomFiles; +contrastCustomFiles = problemDef.contrastCustomFiles; end diff --git a/targetFunctions/common/groupLayers/groupLayersMod.m b/targetFunctions/common/groupLayers/groupLayersMod.m index e1b356350..d32c3b6f2 100644 --- a/targetFunctions/common/groupLayers/groupLayersMod.m +++ b/targetFunctions/common/groupLayers/groupLayersMod.m @@ -1,9 +1,9 @@ -function [outLayers, outSsubs] = groupLayersMod(allLayers,allRoughs,geometry,nbair,nbsubs) +function [outLayers, outSsubs] = groupLayersMod(allLayers,allRoughs,geometry,bulkIn,bulkOuts) %Arrange layers according to geometry and apply any coverage correction. % % USAGE:: % -% [outLayers, outSsubs] = groupLayersMod(allLayers,allRoughs,numberOfContrasts,geometry,nbairs,nbsubs) +% [outLayers, outSsubs] = groupLayersMod(allLayers,allRoughs,numberOfContrasts,geometry,bulkIns,bulkOuts) % % INPUTS: % @@ -11,8 +11,8 @@ % * allRoughs = Double of substrate roughness for each contrast. % * numberOfContrasts = double. % * geometry = 'Air / Liquid (or solid)' or 'Solid / Liquid' -% * nbairs = vector of nbair values. -% * nbsubs = vector of nbsub values. +% * bulkIns = vector of bulkIn values. +% * bulkOuts = vector of bulkOut values. % % The paratt calculation procedds through the % z,rho,rough stack, and the parameter 'ssub' in @@ -71,9 +71,9 @@ for j = 1:l this_pcw = output(j,4); if output(j,5) == 1 - pc_add = nbair; + pc_add = bulkIn; else - pc_add = nbsubs; + pc_add = bulkOuts; end if ~isnan(this_pcw) layers(j,2) = pc_add*(this_pcw/100) + (1-(this_pcw/100))*layers(j,2); diff --git a/targetFunctions/common/groupLayers/groupLayersModImaginary.m b/targetFunctions/common/groupLayers/groupLayersModImaginary.m index 355ed36c5..78703399b 100644 --- a/targetFunctions/common/groupLayers/groupLayersModImaginary.m +++ b/targetFunctions/common/groupLayers/groupLayersModImaginary.m @@ -1,9 +1,9 @@ -function [outLayers, outSsubs] = groupLayersModImaginary(allLayers,allRoughs,geometry,nbair,nbsubs) +function [outLayers, outSsubs] = groupLayersModImaginary(allLayers,allRoughs,geometry,bulkIn,bulkOuts) %Arrange layers according to geometry and apply any coverage correction. % % USAGE:: % -% [outLayers, outSsubs] = groupLayersMod(allLayers,allRoughs,numberOfContrasts,geometry,nbairs,nbsubs) +% [outLayers, outSsubs] = groupLayersMod(allLayers,allRoughs,numberOfContrasts,geometry,bulkIns,bulkOuts) % % INPUTS: % @@ -11,8 +11,8 @@ % * allRoughs = Double of substrate roughness for each contrast. % * numberOfContrasts = double. % * geometry = 'Air / Liquid (or solid)' or 'Solid / Liquid' -% * nbairs = vector of nbair values. -% * nbsubs = vector of nbsub values. +% * bulkIns = vector of bulkIn values. +% * bulkOuts = vector of bulkOut values. % % The paratt calculation procedds through the % z,rho,rough stack, and the parameter 'ssub' in @@ -71,9 +71,9 @@ for j = 1:l this_pcw = output(j,5); if output(j,5) == 1 - pc_add = nbair; + pc_add = bulkIn; else - pc_add = nbsubs; + pc_add = bulkOuts; end if ~isnan(this_pcw) layers(j,2) = pc_add*(this_pcw/100) + (1-(this_pcw/100))*layers(j,2); diff --git a/targetFunctions/common/makeSLDProfiles/makeSLDProfileXY.m b/targetFunctions/common/makeSLDProfiles/makeSLDProfileXY.m index 256b3d90d..7480a712b 100644 --- a/targetFunctions/common/makeSLDProfiles/makeSLDProfileXY.m +++ b/targetFunctions/common/makeSLDProfiles/makeSLDProfileXY.m @@ -1,4 +1,4 @@ -function out = makeSLDProfileXY(nbair,nbsub,ssub,layers,numberOfLayers,nrepeats) +function out = makeSLDProfileXY(bulkIn,bulkOut,ssub,layers,numberOfLayers,nrepeats) if numberOfLayers>0 layerThicks = sum(layers(:,1)); @@ -8,7 +8,7 @@ boxCen = 0; boxWidth = 100; nextLayRough = layers(1,3); - airBox = asymconvstep(x,boxWidth,boxCen,nextLayRough,nextLayRough,nbair); + airBox = asymconvstep(x,boxWidth,boxCen,nextLayRough,nextLayRough,bulkIn); lastBoxEdge = boxCen + (boxWidth/2); for n = 1:nrepeats for i = 1:numberOfLayers @@ -31,7 +31,7 @@ end thisLayRough = nextLayRough;%layers(end,3); thisLayThick = (x(end)-lastBoxEdge)*2; - thisLaySLD = nbsub; + thisLaySLD = bulkOut; nextLayRough = ssub; thisBoxCentre = x(end); Lays(:,(numberOfLayers*nrepeats)+1) = asymconvstep(x,thisLayThick,thisBoxCentre,thisLayRough,nextLayRough,thisLaySLD); @@ -45,8 +45,8 @@ subsBoxCen = max(x); airBoxCen = 0; widths = max(x); - airBox = asymconvstep(x,widths,airBoxCen,ssub,ssub,nbair); - subBox = asymconvstep(x,widths,subsBoxCen,ssub,ssub,nbsub); + airBox = asymconvstep(x,widths,airBoxCen,ssub,ssub,bulkIn); + subBox = asymconvstep(x,widths,subsBoxCen,ssub,ssub,bulkOut); SLD = airBox + subBox; end diff --git a/targetFunctions/common/makeSLDProfiles/makeSLDProfiles.m b/targetFunctions/common/makeSLDProfiles/makeSLDProfiles.m index 36689d815..97334b948 100644 --- a/targetFunctions/common/makeSLDProfiles/makeSLDProfiles.m +++ b/targetFunctions/common/makeSLDProfiles/makeSLDProfiles.m @@ -1,4 +1,4 @@ -function sldProfile= makeSLDProfiles(nbair,nbsub,sld,ssub,repeats) +function sldProfile= makeSLDProfiles(bulkIn,bulkOut,sld,ssub,repeats) lays = size(sld,1); @@ -9,6 +9,6 @@ end -sldProfile = makeSLDProfileXY(nbair,nbsub,ssub,sld,lays,reps); +sldProfile = makeSLDProfileXY(bulkIn,bulkOut,ssub,sld,lays,reps); end \ No newline at end of file diff --git a/targetFunctions/common/shiftData.m b/targetFunctions/common/shiftData.m index c5f9ca99a..7ad454d30 100644 --- a/targetFunctions/common/shiftData.m +++ b/targetFunctions/common/shiftData.m @@ -1,25 +1,25 @@ -function shifted_data = shiftData(scalefac,horshift,dataPresent,data,dataLimits,simLimits) +function shiftedData = shiftData(scalefactor,qzshift,dataPresent,data,dataLimits,simLimits) % Shifts the data according to scale factor. If there is no data, makes % x-data over the simulation range. % % INPUTS: % -% * scalefac = problem.scalefactors; -% * horshift = problem.qshifts; -% * numberOfContrasts = problem.numberOfContrasts; +% * scalefactor = problem.scalefactors; +% * horshift = problem.qzshifts; % * dataPresent = problem.dataPresent; % * allData = problem.data; % * dataLimits = problem.dataLimits; - switch dataPresent + case 1 - if scalefac == 0 - scalefac = 1e-30; + + if scalefactor == 0 + scalefactor = 1e-30; end - data(:,1) = data(:,1) + horshift; - data(:,2) = data(:,2) ./ scalefac; - data(:,3) = data(:,3) ./ scalefac; + data(:,1) = data(:,1) + qzshift; + data(:,2) = data(:,2) ./ scalefactor; + data(:,3) = data(:,3) ./ scalefactor; lowLimit = dataLimits(1); hiLimit = dataLimits(2); @@ -38,22 +38,16 @@ hiIndex = length(data(:,1)); end - shifted_data = data(lowIndex:hiIndex,:); + shiftedData = data(lowIndex:hiIndex,:); + otherwise + simPoints = 500; simLo = simLimits(1); simHi = simLimits(2); simXData = linspace(simLo,simHi,simPoints); simYData = zeros(length(simXData),1); - shifted_data = [simXData(:) simYData(:) simYData(:)]; -end - + shiftedData = [simXData(:) simYData(:) simYData(:)]; - - - - - - - - \ No newline at end of file +end + \ No newline at end of file diff --git a/targetFunctions/reflectivityCalculation.m b/targetFunctions/reflectivityCalculation.m index 4c7380930..5056a8ee2 100644 --- a/targetFunctions/reflectivityCalculation.m +++ b/targetFunctions/reflectivityCalculation.m @@ -21,12 +21,12 @@ % for compilation, we have to preallocate memory for the output arrays % Setting these parameters in the struct defines them as doubles problem.ssubs = 0; -problem.backgrounds = 0; -problem.qshifts = 0; +problem.backgroundParams = 0; +problem.qzshifts = 0; problem.scalefactors = 0; -problem.nbairs = 0; -problem.nbsubs = 0; -problem.resolutions = 0; +problem.bulkIn = 0; +problem.bulkOut = 0; +problem.resolutionParams = 0; problem.calculations.all_chis = 0; problem.calculations.sum_chi = 0; problem.allSubRough = 0; @@ -186,12 +186,12 @@ % Pre-processor directives for Matlab Coder % to define the size of the output array 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]); diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomLayersInputs.mat b/tests/domainsTFReflectivityCalculation/domainsCustomLayersInputs.mat index c756c47ed..156433b39 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomLayersInputs.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomLayersInputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomLayersOutputs.mat b/tests/domainsTFReflectivityCalculation/domainsCustomLayersOutputs.mat index 77693c8e5..d064d5985 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomLayersOutputs.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomLayersOutputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomLayersTFParams.mat b/tests/domainsTFReflectivityCalculation/domainsCustomLayersTFParams.mat index ea96f08a3..d69ba3f7d 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomLayersTFParams.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomLayersTFParams.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomXYInputs.mat b/tests/domainsTFReflectivityCalculation/domainsCustomXYInputs.mat index 3052f7c0e..cc27f1f14 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomXYInputs.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomXYInputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomXYOutputs.mat b/tests/domainsTFReflectivityCalculation/domainsCustomXYOutputs.mat index a24eb9549..a7a173caa 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomXYOutputs.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomXYOutputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomXYTFParams.mat b/tests/domainsTFReflectivityCalculation/domainsCustomXYTFParams.mat index 5599870f5..e4b330382 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomXYTFParams.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomXYTFParams.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsStandardLayersInputs.mat b/tests/domainsTFReflectivityCalculation/domainsStandardLayersInputs.mat index e746408ae..6326929ef 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsStandardLayersInputs.mat and b/tests/domainsTFReflectivityCalculation/domainsStandardLayersInputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsStandardLayersOutputs.mat b/tests/domainsTFReflectivityCalculation/domainsStandardLayersOutputs.mat index 4366b8f06..acf3be0ad 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsStandardLayersOutputs.mat and b/tests/domainsTFReflectivityCalculation/domainsStandardLayersOutputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsStandardLayersTFParams.mat b/tests/domainsTFReflectivityCalculation/domainsStandardLayersTFParams.mat index 8766c33e2..99653b82f 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsStandardLayersTFParams.mat and b/tests/domainsTFReflectivityCalculation/domainsStandardLayersTFParams.mat differ diff --git a/tests/domainsTFReflectivityCalculation/makeDomainsInputsAndOutputs.m b/tests/domainsTFReflectivityCalculation/makeDomainsInputsAndOutputs.m index 3a0b9c322..e6beb9f51 100644 --- a/tests/domainsTFReflectivityCalculation/makeDomainsInputsAndOutputs.m +++ b/tests/domainsTFReflectivityCalculation/makeDomainsInputsAndOutputs.m @@ -56,17 +56,17 @@ TFParams.sldProfiles = sldProfiles; TFParams.allLayers = allLayers; -[outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... - Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... +[outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,... + resolutionParams,chis,reflectivity,simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = domainsTF.standardLayers.single(problemDef,problemDefCells,controls); TFParams.outSsubs = outSsubs; -TFParams.backgs = backgs; -TFParams.qshifts = qshifts; -TFParams.sfs = sfs; -TFParams.nbas = nbas; -TFParams.nbss = nbss; -TFParams.resols = resols; +TFParams.backgroundParams = backgroundParams; +TFParams.qzshifts = qzshifts; +TFParams.scalefactors = scalefactors; +TFParams.bulkIn = bulkIn; +TFParams.bulkOut = bulkOut; +TFParams.resolutionParams = resolutionParams; TFParams.chis = chis; TFParams.allRoughs = allRoughs; @@ -125,17 +125,17 @@ TFParams.sldProfiles = sldProfiles; TFParams.allLayers = allLayers; -[outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... - Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... +[outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,... + resolutionParams,chis,reflectivity,simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = domainsTF.customXY.single(problemDef,problemDefCells,controls); TFParams.outSsubs = outSsubs; -TFParams.backgs = backgs; -TFParams.qshifts = qshifts; -TFParams.sfs = sfs; -TFParams.nbas = nbas; -TFParams.nbss = nbss; -TFParams.resols = resols; +TFParams.backgroundParams = backgroundParams; +TFParams.qzshifts = qzshifts; +TFParams.scalefactors = scalefactors; +TFParams.bulkIn = bulkIn; +TFParams.bulkOut = bulkOut; +TFParams.resolutionParams = resolutionParams; TFParams.chis = chis; TFParams.allRoughs = allRoughs; @@ -194,17 +194,17 @@ TFParams.sldProfiles = sldProfiles; TFParams.allLayers = allLayers; -[outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... - Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... +[outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,... + resolutionParams,chis,reflectivity,simulation,shifted_data,layerSlds,sldProfiles,allLayers,... allRoughs] = domainsTF.customLayers.single(problemDef,problemDefCells,controls); TFParams.outSsubs = outSsubs; -TFParams.backgs = backgs; -TFParams.qshifts = qshifts; -TFParams.sfs = sfs; -TFParams.nbas = nbas; -TFParams.nbss = nbss; -TFParams.resols = resols; +TFParams.backgrounds = backgroundParams; +TFParams.qzshifts = qzshifts; +TFParams.scalefactors = scalefactors; +TFParams.bulkIn = bulkIn; +TFParams.bulkOut = bulkOut; +TFParams.resolutionParams = resolutionParams; TFParams.chis = chis; TFParams.allRoughs = allRoughs; diff --git a/tests/domainsTFReflectivityCalculation/testDomainsReflectivityCalculations.m b/tests/domainsTFReflectivityCalculation/testDomainsReflectivityCalculations.m index a10c24056..fde3dadf7 100644 --- a/tests/domainsTFReflectivityCalculation/testDomainsReflectivityCalculations.m +++ b/tests/domainsTFReflectivityCalculation/testDomainsReflectivityCalculations.m @@ -3,20 +3,6 @@ % testReflectivityCalculations Class based unit tests for RAT API, the % reflectivity calculation and pre- and post-processing routines. % -% In this class, we test: -% RAT, RATMain, reflectivityCalculation, reflectivityCalculation, -% domainsTFReflectivityCalculation, -% domainsTF.standardLayersReflectivityCalculation, -% domainsTF.customLayersReflectivityCalculation, -% domainsTF.customXYReflectivityCalculation, -% domainsTF.standardLayersSingle, domainsTF.customLayersSingle, -% domainsTF.customXYSingle, domainsTF.standardLayersParallelContrasts, -% domainsTF.customLayersParallelContrasts, domainsTF.customXYParallelContrasts, -% domainsTF.standardLayersParallelPoints, domainsTF.customLayersParallelPoints, -% domainsTF.customXYParallelPoints, -% RatParseClasstoStructs_new, parseCells, extractProblemParams -% parseResultToStruct, RATParseOutToProjectClass -% % We are using the test cases for a domains reflectivity calculation % to test the routines. We consider standard layers, custom layers and % custom XY examples. For the reflectivity calculation itself, we consider @@ -62,12 +48,12 @@ TFSLDProfiles TFAllLayers TFOutSsubs - TFBackgs - TFQshifts - TFSfs - TFNbas - TFNbss - TFResols + TFBackgroundParams + TFQzshifts + TFScalefactors + TFBulkIn + TFBulkOut + TFResolutionParams TFChis TFAllRoughs tolerance = 1.0e-12 % Relative tolerance for equality of floats @@ -113,12 +99,12 @@ function loadTFParams(testCase, TFFile) testCase.TFAllLayers = testCase.TFParams.TFParams.allLayers; testCase.TFOutSsubs = testCase.TFParams.TFParams.outSsubs; - testCase.TFBackgs = testCase.TFParams.TFParams.backgs; - testCase.TFQshifts = testCase.TFParams.TFParams.qshifts; - testCase.TFSfs = testCase.TFParams.TFParams.sfs; - testCase.TFNbas = testCase.TFParams.TFParams.nbas; - testCase.TFNbss = testCase.TFParams.TFParams.nbss; - testCase.TFResols = testCase.TFParams.TFParams.resols; + testCase.TFBackgroundParams = testCase.TFParams.TFParams.backgroundParams; + testCase.TFQzshifts = testCase.TFParams.TFParams.qzshifts; + testCase.TFScalefactors = testCase.TFParams.TFParams.scalefactors; + testCase.TFBulkIn = testCase.TFParams.TFParams.bulkIn; + testCase.TFBulkOut = testCase.TFParams.TFParams.bulkOut; + testCase.TFResolutionParams = testCase.TFParams.TFParams.resolutionParams; testCase.TFChis = testCase.TFParams.TFParams.chis; testCase.TFAllRoughs = testCase.TFParams.TFParams.allRoughs; end @@ -208,29 +194,29 @@ function testDomainsTFLayersSerialReflectivityCalculation(testCase, TFFile) % Choose the appropriate routine for each test case switch TFFile case 'domainsStandardLayersTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = domainsTF.standardLayers.single(testCase.problemDef,testCase.problemDefCells,... testCase.controls); case 'domainsCustomLayersTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = domainsTF.customLayers.single(testCase.problemDef,testCase.problemDefCells,... testCase.controls); case 'domainsCustomXYTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = domainsTF.customXY.single(testCase.problemDef,testCase.problemDefCells,... testCase.controls); end testCase.verifyEqual(outSsubs, testCase.TFOutSsubs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(backgs, testCase.TFBackgs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(qshifts, testCase.TFQshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(sfs, testCase.TFSfs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nbas, testCase.TFNbas, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nbss, testCase.TFNbss, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(resols, testCase.TFResols, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(backgroundParams, testCase.TFBackgroundParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(qzshifts, testCase.TFQzshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(scalefactors, testCase.TFScalefactors, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkIn, testCase.TFBulkIn, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkOut, testCase.TFBulkOut, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(resolutionParams, testCase.TFResolutionParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(chis, testCase.TFChis, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(reflectivity, testCase.TFReflectivity, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(simulation, testCase.TFSimulation, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); @@ -245,29 +231,29 @@ function testDomainsTFLayersParallelContrastsReflectivityCalculation(testCase, T % Choose the appropriate routine for each test case switch TFFile case 'domainsStandardLayersTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = domainsTF.standardLayers.parallelContrasts(testCase.problemDef,testCase.problemDefCells,... testCase.controls); case 'domainsCustomLayersTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = domainsTF.customLayers.parallelContrasts(testCase.problemDef,testCase.problemDefCells,... testCase.controls); case 'domainsCustomXYTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = domainsTF.customXY.parallelContrasts(testCase.problemDef,testCase.problemDefCells,... testCase.controls); end testCase.verifyEqual(outSsubs, testCase.TFOutSsubs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(backgs, testCase.TFBackgs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(qshifts, testCase.TFQshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(sfs, testCase.TFSfs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nbas, testCase.TFNbas, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nbss, testCase.TFNbss, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(resols, testCase.TFResols, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(backgroundParams, testCase.TFBackgroundParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(qzshifts, testCase.TFQzshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(scalefactors, testCase.TFScalefactors, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkIn, testCase.TFBulkIn, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkOut, testCase.TFBulkOut, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(resolutionParams, testCase.TFResolutionParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(chis, testCase.TFChis, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(reflectivity, testCase.TFReflectivity, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(simulation, testCase.TFSimulation, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); @@ -282,29 +268,29 @@ function testDomainsTFLayersParallelPointsReflectivityCalculation(testCase, TFFi % Choose the appropriate routine for each test case switch TFFile case 'domainsStandardLayersTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = domainsTF.standardLayers.parallelPoints(testCase.problemDef,testCase.problemDefCells,... testCase.controls); case 'domainsCustomLayersTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = domainsTF.customLayers.parallelPoints(testCase.problemDef,testCase.problemDefCells,... testCase.controls); case 'domainsCustomXYTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = domainsTF.customXY.parallelPoints(testCase.problemDef,testCase.problemDefCells,... testCase.controls); end testCase.verifyEqual(outSsubs, testCase.TFOutSsubs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(backgs, testCase.TFBackgs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(qshifts, testCase.TFQshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(sfs, testCase.TFSfs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nbas, testCase.TFNbas, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nbss, testCase.TFNbss, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(resols, testCase.TFResols, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(backgroundParams, testCase.TFBackgroundParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(qzshifts, testCase.TFQzshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(scalefactors, testCase.TFScalefactors, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkIn, testCase.TFBulkIn, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkOut, testCase.TFBulkOut, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(resolutionParams, testCase.TFResolutionParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(chis, testCase.TFChis, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(reflectivity, testCase.TFReflectivity, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(simulation, testCase.TFSimulation, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); @@ -340,31 +326,31 @@ function testRATParseCells(testCase) end function testExtractProblemParams(testCase) - [numberOfContrasts, geometry, cBacks, cShifts, cScales, cNbas, cNbss,... - cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... - numberOfLayers, resample, backsType, cFiles] = extractProblemParams(testCase.problemDef); + [numberOfContrasts, geometry, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... + contrastResolutions, backgroundParams, qzshifts, scalefactors, bulkIn, bulkOut, resolutionParams, dataPresent, nParams, params,... + numberOfLayers, resample, backgroundParamsType, contrastCustomFiles] = extractProblemParams(testCase.problemDef); testCase.verifyEqual(numberOfContrasts, testCase.problemDef.numberOfContrasts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(geometry, testCase.problemDef.geometry, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(cBacks, testCase.problemDef.contrastBackgrounds, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(cShifts, testCase.problemDef.contrastQzshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(cScales, testCase.problemDef.contrastScalefactors, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(cNbas, testCase.problemDef.contrastBulkIns, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(cNbss, testCase.problemDef.contrastBulkOuts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(cRes, testCase.problemDef.contrastResolutions, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(backs, testCase.problemDef.backs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(shifts, testCase.problemDef.shifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(sf, testCase.problemDef.sf, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nba, testCase.problemDef.nba, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nbs, testCase.problemDef.nbs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(res, testCase.problemDef.res, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(contrastBackgrounds, testCase.problemDef.contrastBackgrounds, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(contrastQzshifts, testCase.problemDef.contrastQzshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(contrastScalefactors, testCase.problemDef.contrastScalefactors, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(contrastBulkIns, testCase.problemDef.contrastBulkIns, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(contrastBulkOuts, testCase.problemDef.contrastBulkOuts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(contrastResolutions, testCase.problemDef.contrastResolutions, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(backgroundParams, testCase.problemDef.backgroundParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(qzshifts, testCase.problemDef.qzshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(scalefactors, testCase.problemDef.scalefactors, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkIn, testCase.problemDef.bulkIn, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkOut, testCase.problemDef.bulkOut, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(resolutionParams, testCase.problemDef.resolutionParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(dataPresent, testCase.problemDef.dataPresent, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(nParams, length(testCase.problemDef.params), 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(params, testCase.problemDef.params, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(numberOfLayers, testCase.problemDef.numberOfLayers, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(resample, testCase.problemDef.resample, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(backsType, testCase.problemDef.contrastBackgroundsType, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(cFiles, testCase.problemDef.contrastCustomFiles, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(backgroundParamsType, testCase.problemDef.contrastBackgroundsType, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(contrastCustomFiles, testCase.problemDef.contrastCustomFiles, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); end function testParseResultToStruct(testCase) diff --git a/tests/nonPolarisedTFReflectivityCalculation/customLayersInputs.mat b/tests/nonPolarisedTFReflectivityCalculation/customLayersInputs.mat index 7b761d3ce..64d2baecb 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customLayersInputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/customLayersInputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customLayersOutputs.mat b/tests/nonPolarisedTFReflectivityCalculation/customLayersOutputs.mat index 4f196b65c..31eca09c0 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customLayersOutputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/customLayersOutputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customLayersTFParams.mat b/tests/nonPolarisedTFReflectivityCalculation/customLayersTFParams.mat index 9f7391d94..8f3e227b4 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customLayersTFParams.mat and b/tests/nonPolarisedTFReflectivityCalculation/customLayersTFParams.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customXYInputs.mat b/tests/nonPolarisedTFReflectivityCalculation/customXYInputs.mat index 135b4b37c..973b6348b 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customXYInputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/customXYInputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customXYOutputs.mat b/tests/nonPolarisedTFReflectivityCalculation/customXYOutputs.mat index 10b67a592..13ca0d46e 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customXYOutputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/customXYOutputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customXYTFParams.mat b/tests/nonPolarisedTFReflectivityCalculation/customXYTFParams.mat index 748bdfc93..88c4b6f96 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customXYTFParams.mat and b/tests/nonPolarisedTFReflectivityCalculation/customXYTFParams.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/makeInputsAndOutputs.m b/tests/nonPolarisedTFReflectivityCalculation/makeInputsAndOutputs.m index 1e1fa4cf6..88aad766e 100644 --- a/tests/nonPolarisedTFReflectivityCalculation/makeInputsAndOutputs.m +++ b/tests/nonPolarisedTFReflectivityCalculation/makeInputsAndOutputs.m @@ -46,27 +46,27 @@ save(['tests' filesep 'nonPolarisedTFReflectivityCalculation' filesep 'customLayersOutputs'],'outputs'); % (c) TF Parameters -[problem,reflectivity,simulation,shifted_data,layerSlds,sldProfiles,allLayers] = nonPolarisedTF.reflectivityCalculation(problemDef,problemDefCells,controls); +[problem,reflectivity,simulation,shiftedData,layerSlds,sldProfiles,allLayers] = nonPolarisedTF.reflectivityCalculation(problemDef,problemDefCells,controls); TFParams.problem = problem; TFParams.reflectivity = reflectivity; TFParams.simulation = simulation; -TFParams.shiftedData = shifted_data; +TFParams.shiftedData = shiftedData; TFParams.layerSlds = layerSlds; TFParams.sldProfiles = sldProfiles; TFParams.allLayers = allLayers; -[outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... - Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... +[outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... + simulation,shiftedData,layerSlds,sldProfiles,allLayers,... allRoughs] = nonPolarisedTF.customLayers.single(problemDef,problemDefCells,controls); TFParams.outSsubs = outSsubs; -TFParams.backgs = backgs; -TFParams.qshifts = qshifts; -TFParams.sfs = sfs; -TFParams.nbas = nbas; -TFParams.nbss = nbss; -TFParams.resols = resols; +TFParams.backgroundParams = backgroundParams; +TFParams.qzshifts = qzshifts; +TFParams.scalefactors = scalefactors; +TFParams.bulkIn = bulkIn; +TFParams.bulkOut = bulkOut; +TFParams.resolutionParams = resolutionParams; TFParams.chis = chis; TFParams.allRoughs = allRoughs; @@ -115,27 +115,27 @@ save(['tests' filesep 'nonPolarisedTFReflectivityCalculation' filesep 'customXYOutputs'],'outputs'); % (c) TF Parameters -[problem,reflectivity,simulation,shifted_data,layerSlds,sldProfiles,allLayers] = nonPolarisedTF.reflectivityCalculation(problemDef,problemDefCells,controls); +[problem,reflectivity,simulation,shiftedData,layerSlds,sldProfiles,allLayers] = nonPolarisedTF.reflectivityCalculation(problemDef,problemDefCells,controls); TFParams.problem = problem; TFParams.reflectivity = reflectivity; TFParams.simulation = simulation; -TFParams.shiftedData = shifted_data; +TFParams.shiftedData = shiftedData; TFParams.layerSlds = layerSlds; TFParams.sldProfiles = sldProfiles; TFParams.allLayers = allLayers; -[outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... - Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... +[outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,... + resolutionParams,chis,reflectivity,simulation,shiftedData,layerSlds,sldProfiles,allLayers,... allRoughs] = nonPolarisedTF.customXY.single(problemDef,problemDefCells,controls); TFParams.outSsubs = outSsubs; -TFParams.backgs = backgs; -TFParams.qshifts = qshifts; -TFParams.sfs = sfs; -TFParams.nbas = nbas; -TFParams.nbss = nbss; -TFParams.resols = resols; +TFParams.backgroundParams = backgroundParams; +TFParams.qzshifts = qzshifts; +TFParams.scalefactors = scalefactors; +TFParams.bulkIn = bulkIn; +TFParams.bulkOut = bulkOut; +TFParams.resolutionParams = resolutionParams; TFParams.chis = chis; TFParams.allRoughs = allRoughs; @@ -184,27 +184,27 @@ save(['tests' filesep 'nonPolarisedTFReflectivityCalculation' filesep 'standardLayersOutputs'],'outputs'); % (c) TF Parameters -[problem,reflectivity,simulation,shifted_data,layerSlds,sldProfiles,allLayers] = nonPolarisedTF.reflectivityCalculation(problemDef,problemDefCells,controls); +[problem,reflectivity,simulation,shiftedData,layerSlds,sldProfiles,allLayers] = nonPolarisedTF.reflectivityCalculation(problemDef,problemDefCells,controls); TFParams.problem = problem; TFParams.reflectivity = reflectivity; TFParams.simulation = simulation; -TFParams.shiftedData = shifted_data; +TFParams.shiftedData = shiftedData; TFParams.layerSlds = layerSlds; TFParams.sldProfiles = sldProfiles; TFParams.allLayers = allLayers; -[outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... - Simulation,shifted_data,layerSlds,sldProfiles,allLayers,... +[outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,... + resolutionParams,chis,reflectivity,simulation,shiftedData,layerSlds,sldProfiles,allLayers,... allRoughs] = nonPolarisedTF.standardLayers.single(problemDef,problemDefCells,controls); TFParams.outSsubs = outSsubs; -TFParams.backgs = backgs; -TFParams.qshifts = qshifts; -TFParams.sfs = sfs; -TFParams.nbas = nbas; -TFParams.nbss = nbss; -TFParams.resols = resols; +TFParams.backgroundParams = backgroundParams; +TFParams.qzshifts = qzshifts; +TFParams.scalefactors = scalefactors; +TFParams.bulkIn = bulkIn; +TFParams.bulkOut = bulkOut; +TFParams.resolutionParams = resolutionParams; TFParams.chis = chis; TFParams.allRoughs = allRoughs; diff --git a/tests/nonPolarisedTFReflectivityCalculation/standardLayersInputs.mat b/tests/nonPolarisedTFReflectivityCalculation/standardLayersInputs.mat index 11c8a4d84..ae56eee94 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/standardLayersInputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/standardLayersInputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/standardLayersOutputs.mat b/tests/nonPolarisedTFReflectivityCalculation/standardLayersOutputs.mat index 37e3f8fdc..35df49e41 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/standardLayersOutputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/standardLayersOutputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/standardLayersTFParams.mat b/tests/nonPolarisedTFReflectivityCalculation/standardLayersTFParams.mat index b84271a00..e0b6a03de 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/standardLayersTFParams.mat and b/tests/nonPolarisedTFReflectivityCalculation/standardLayersTFParams.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/testReflectivityCalculations.m b/tests/nonPolarisedTFReflectivityCalculation/testReflectivityCalculations.m index 9b67e7a7f..b981c46ed 100644 --- a/tests/nonPolarisedTFReflectivityCalculation/testReflectivityCalculations.m +++ b/tests/nonPolarisedTFReflectivityCalculation/testReflectivityCalculations.m @@ -47,12 +47,12 @@ TFSLDProfiles TFAllLayers TFOutSsubs - TFBackgs - TFQshifts - TFSfs - TFNbas - TFNbss - TFResols + TFBackgroundParams + TFQzshifts + TFScalefactors + TFBulkIn + TFBulkOut + TFResolutionParams TFChis TFAllRoughs tolerance = 1.0e-12 % Relative tolerance for equality of floats @@ -98,12 +98,12 @@ function loadTFParams(testCase, TFFile) testCase.TFAllLayers = testCase.TFParams.TFParams.allLayers; testCase.TFOutSsubs = testCase.TFParams.TFParams.outSsubs; - testCase.TFBackgs = testCase.TFParams.TFParams.backgs; - testCase.TFQshifts = testCase.TFParams.TFParams.qshifts; - testCase.TFSfs = testCase.TFParams.TFParams.sfs; - testCase.TFNbas = testCase.TFParams.TFParams.nbas; - testCase.TFNbss = testCase.TFParams.TFParams.nbss; - testCase.TFResols = testCase.TFParams.TFParams.resols; + testCase.TFBackgroundParams = testCase.TFParams.TFParams.backgroundParams; + testCase.TFQzshifts = testCase.TFParams.TFParams.qzshifts; + testCase.TFScalefactors = testCase.TFParams.TFParams.scalefactors; + testCase.TFBulkIn = testCase.TFParams.TFParams.bulkIn; + testCase.TFBulkOut = testCase.TFParams.TFParams.bulkOut; + testCase.TFResolutionParams = testCase.TFParams.TFParams.resolutionParams; testCase.TFChis = testCase.TFParams.TFParams.chis; testCase.TFAllRoughs = testCase.TFParams.TFParams.allRoughs; end @@ -193,29 +193,29 @@ function testNonPolarisedTFLayersSerialReflectivityCalc(testCase, TFFile) % Choose the appropriate routine for each test case switch TFFile case 'standardLayersTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = nonPolarisedTF.standardLayers.single(testCase.problemDef,testCase.problemDefCells,... testCase.controls); case 'customLayersTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = nonPolarisedTF.customLayers.single(testCase.problemDef,testCase.problemDefCells,... testCase.controls); case 'customXYTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = nonPolarisedTF.customXY.single(testCase.problemDef,testCase.problemDefCells,... testCase.controls); end testCase.verifyEqual(outSsubs, testCase.TFOutSsubs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(backgs, testCase.TFBackgs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(qshifts, testCase.TFQshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(sfs, testCase.TFSfs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nbas, testCase.TFNbas, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nbss, testCase.TFNbss, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(resols, testCase.TFResols, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(backgroundParams, testCase.TFBackgroundParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(qzshifts, testCase.TFQzshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(scalefactors, testCase.TFScalefactors, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkIn, testCase.TFBulkIn, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkOut, testCase.TFBulkOut, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(resolutionParams, testCase.TFResolutionParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(chis, testCase.TFChis, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(reflectivity, testCase.TFReflectivity, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(simulation, testCase.TFSimulation, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); @@ -230,29 +230,29 @@ function testNonPolarisedTFLayersParallelContrastsReflectivityCalc(testCase, TFF % Choose the appropriate routine for each test case switch TFFile case 'standardLayersTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = nonPolarisedTF.standardLayers.parallelContrasts(testCase.problemDef,testCase.problemDefCells,... testCase.controls); case 'customLayersTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = nonPolarisedTF.customLayers.parallelContrasts(testCase.problemDef,testCase.problemDefCells,... testCase.controls); case 'customXYTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = nonPolarisedTF.customXY.parallelContrasts(testCase.problemDef,testCase.problemDefCells,... testCase.controls); end testCase.verifyEqual(outSsubs, testCase.TFOutSsubs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(backgs, testCase.TFBackgs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(qshifts, testCase.TFQshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(sfs, testCase.TFSfs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nbas, testCase.TFNbas, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nbss, testCase.TFNbss, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(resols, testCase.TFResols, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(backgroundParams, testCase.TFBackgroundParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(qzshifts, testCase.TFQzshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(scalefactors, testCase.TFScalefactors, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkIn, testCase.TFBulkIn, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkOut, testCase.TFBulkOut, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(resolutionParams, testCase.TFResolutionParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(chis, testCase.TFChis, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(reflectivity, testCase.TFReflectivity, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(simulation, testCase.TFSimulation, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); @@ -267,29 +267,29 @@ function testNonPolarisedTFLayersParallelPointsReflectivityCalc(testCase, TFFile % Choose the appropriate routine for each test case switch TFFile case 'standardLayersTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = nonPolarisedTF.standardLayers.parallelPoints(testCase.problemDef,testCase.problemDefCells,... testCase.controls); case 'customLayersTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = nonPolarisedTF.customLayers.parallelPoints(testCase.problemDef,testCase.problemDefCells,... testCase.controls); case 'customXYTFParams.mat' - [outSsubs,backgs,qshifts,sfs,nbas,nbss,resols,chis,reflectivity,... + [outSsubs,backgroundParams,qzshifts,scalefactors,bulkIn,bulkOut,resolutionParams,chis,reflectivity,... simulation,shiftedData,layerSLDs,SLDProfiles,allLayers,... allRoughs] = nonPolarisedTF.customXY.parallelPoints(testCase.problemDef,testCase.problemDefCells,... testCase.controls); end testCase.verifyEqual(outSsubs, testCase.TFOutSsubs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(backgs, testCase.TFBackgs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(qshifts, testCase.TFQshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(sfs, testCase.TFSfs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nbas, testCase.TFNbas, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nbss, testCase.TFNbss, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(resols, testCase.TFResols, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(backgroundParams, testCase.TFBackgroundParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(qzshifts, testCase.TFQzshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(scalefactors, testCase.TFScalefactors, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkIn, testCase.TFBulkIn, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkOut, testCase.TFBulkOut, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(resolutionParams, testCase.TFResolutionParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(chis, testCase.TFChis, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(reflectivity, testCase.TFReflectivity, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(simulation, testCase.TFSimulation, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); @@ -325,31 +325,31 @@ function testRATParseCells(testCase) end function testExtractProblemParams(testCase) - [numberOfContrasts, geometry, cBacks, cShifts, cScales, cNbas, cNbss,... - cRes, backs, shifts, sf, nba, nbs, res, dataPresent, nParams, params,... - numberOfLayers, resample, backsType, cFiles] = extractProblemParams(testCase.problemDef); + [numberOfContrasts, geometry, contrastBackgrounds, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts,... + contrastResolutions, backgroundParams, qzshifts, scalefactors, bulkIn, bulkOut, resolutionParams, dataPresent, nParams, params,... + numberOfLayers, resample, backgroundParamsType, contrastCustomFiles] = extractProblemParams(testCase.problemDef); testCase.verifyEqual(numberOfContrasts, testCase.problemDef.numberOfContrasts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(geometry, testCase.problemDef.geometry, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(cBacks, testCase.problemDef.contrastBackgrounds, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(cShifts, testCase.problemDef.contrastQzshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(cScales, testCase.problemDef.contrastScalefactors, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(cNbas, testCase.problemDef.contrastBulkIns, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(cNbss, testCase.problemDef.contrastBulkOuts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(cRes, testCase.problemDef.contrastResolutions, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(backs, testCase.problemDef.backs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(shifts, testCase.problemDef.shifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(sf, testCase.problemDef.sf, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nba, testCase.problemDef.nba, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(nbs, testCase.problemDef.nbs, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(res, testCase.problemDef.res, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(contrastBackgrounds, testCase.problemDef.contrastBackgrounds, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(contrastQzshifts, testCase.problemDef.contrastQzshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(contrastScalefactors, testCase.problemDef.contrastScalefactors, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(contrastBulkIns, testCase.problemDef.contrastBulkIns, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(contrastBulkOuts, testCase.problemDef.contrastBulkOuts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(contrastResolutions, testCase.problemDef.contrastResolutions, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(backgroundParams, testCase.problemDef.backgroundParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(qzshifts, testCase.problemDef.qzshifts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(scalefactors, testCase.problemDef.scalefactors, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkIn, testCase.problemDef.bulkIn, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(bulkOut, testCase.problemDef.bulkOut, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(resolutionParams, testCase.problemDef.resolutionParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(dataPresent, testCase.problemDef.dataPresent, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(nParams, length(testCase.problemDef.params), 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(params, testCase.problemDef.params, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(numberOfLayers, testCase.problemDef.numberOfLayers, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); testCase.verifyEqual(resample, testCase.problemDef.resample, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(backsType, testCase.problemDef.contrastBackgroundsType, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); - testCase.verifyEqual(cFiles, testCase.problemDef.contrastCustomFiles, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(backgroundParamsType, testCase.problemDef.contrastBackgroundsType, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); + testCase.verifyEqual(contrastCustomFiles, testCase.problemDef.contrastCustomFiles, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance); end function testParseResultToStruct(testCase) diff --git a/tests/testProjectClass.m b/tests/testProjectClass.m index aa8d401fd..753dcdcd3 100644 --- a/tests/testProjectClass.m +++ b/tests/testProjectClass.m @@ -392,20 +392,20 @@ function testScaleFactor(testCase) end function testQzShift(testCase) - % Checks the default Qz shift + % Checks the default qzshift testCase.verifySize(testCase.project.qzshifts.varTable, [1, 8], 'qzshifts has wrong dimension'); testCase.verifyEqual(string(testCase.project.qzshifts.varTable{1, :}),... string({'Qz shift 1', -1e-4, 0, 1e-4, false, priorTypes.Uniform.value, 0, Inf}), 'qzshifts default'); - % Checks that Qz shift can be added + % Checks that qzshift can be added testCase.project.addQzshift('Qz shift 2', -2e-4, 0, 2e-4, false); testCase.verifySize(testCase.project.qzshifts.varTable, [2, 8], 'qzshifts has wrong dimension'); testCase.verifyEqual(testCase.project.qzshifts.varTable{end, 1}, "Qz shift 2", 'addQzshift method not working'); - % Checks that Qz shift can be removed + % Checks that qzshift can be removed testCase.project.removeQzshift(2); testCase.verifySize(testCase.project.qzshifts.varTable, [1, 8], 'qzshifts has wrong dimension'); testCase.verifyEqual(testCase.project.qzshifts.varTable{:, 1}, "Qz shift 1", 'removeQzshift method not working'); - % Checks that Qzshift can be modified + % Checks that qzshift can be modified testCase.project.setQzshift(1, 'name','Qz shift 1','min',-1e-5,'value',0.001,'max',1e-5,'fit',true); testCase.verifyEqual(string(testCase.project.qzshifts.varTable{1, :}),... string({'Qz shift 1', -1e-5, 0.001, 1e-5, true, priorTypes.Uniform.value, 0, Inf}), 'setQzshift method not working'); diff --git a/tests/testProjectConversion/DSPCBilayerProjectClass.mat b/tests/testProjectConversion/DSPCBilayerProjectClass.mat index 52ce9c978..8ec1f959f 100644 Binary files a/tests/testProjectConversion/DSPCBilayerProjectClass.mat and b/tests/testProjectConversion/DSPCBilayerProjectClass.mat differ diff --git a/tests/testProjectConversion/monolayerVolumeModelProjectClass.mat b/tests/testProjectConversion/monolayerVolumeModelProjectClass.mat index e47004f61..39ddbfa4c 100644 Binary files a/tests/testProjectConversion/monolayerVolumeModelProjectClass.mat and b/tests/testProjectConversion/monolayerVolumeModelProjectClass.mat differ diff --git a/utilities/misc/projectClassToR1.m b/utilities/misc/projectClassToR1.m index 74ac5a322..5409bcbe2 100644 --- a/utilities/misc/projectClassToR1.m +++ b/utilities/misc/projectClassToR1.m @@ -134,7 +134,7 @@ numberOfContrasts = r2Problem.contrasts.numberOfContrasts; r1Problem.numberOfContrasts = numberOfContrasts; -[contrastBacks, contrastScales, contrastResolutions, contrastNbas, contrastNbss, contrastsNumberOfLayers, forceReload, fitlowrange, fithirange] = deal(zeros(numberOfContrasts, 1)); +[contrastBacks, contrastScales, contrastResolutions, contrastBulkIns, contrastBulkOuts, contrastsNumberOfLayers, forceReload, fitlowrange, fithirange] = deal(zeros(numberOfContrasts, 1)); contrastShifts = ones(numberOfContrasts, 1); [contrastLayers, simLimits, dataLimits, data, contrastNames, contrastFiles] = deal(cell(numberOfContrasts, 1)); @@ -146,11 +146,11 @@ % Bulk In bulkInLoc = strfind(r2BulkInStruct.names, thisContrast.bulkIn); - contrastNbas(i) = find(not(cellfun('isempty', bulkInLoc))); + contrastBulkIns(i) = find(not(cellfun('isempty', bulkInLoc))); % Bulk Out bulkOutLoc = strfind(r2BulkOutStruct.names, thisContrast.bulkOut); - contrastNbss(i) = find(not(cellfun('isempty', bulkOutLoc))); + contrastBulkOuts(i) = find(not(cellfun('isempty', bulkOutLoc))); % scalefactors scaleLoc = strfind(r1Problem.scalesNames, thisContrast.scalefactor); @@ -226,8 +226,8 @@ % Put everything into the R1 problem r1Problem.contrastTypes = dataTypes; r1Problem.contrastNames = contrastNames; -r1Problem.contrastNbas = contrastNbas; -r1Problem.contrastNbss = contrastNbss; +r1Problem.contrastNbas = contrastBulkIns; +r1Problem.contrastNbss = contrastBulkOuts; r1Problem.contrastScales = contrastScales; r1Problem.contrastShifts = contrastShifts; r1Problem.contrastResolutions = contrastResolutions; diff --git a/utilities/plotting/plotRefSLDHelper.m b/utilities/plotting/plotRefSLDHelper.m index 441a19c2f..be1ae306a 100644 --- a/utilities/plotting/plotRefSLDHelper.m +++ b/utilities/plotting/plotRefSLDHelper.m @@ -55,14 +55,14 @@ function plotRefSLDHelper(data, noDelay) if (data.resample(i) == 1) || (strcmpi(modelType, 'custom xy')) ssub = data.ssubs(i); layers = allLayers{i, 1}; - nbair = layers(1, 2); - nbsub = layers(end, 2); + bulkIn = layers(1, 2); + bulkOut = layers(end, 2); for j=1:size(allLayers, 2) layer = allLayers{i, j}; numberOfLayers = size(layer, 1); nrepeats = 1; - newProf = makeSLDProfileXY(nbair,nbsub,ssub,layer,numberOfLayers,nrepeats); + newProf = makeSLDProfileXY(bulkIn,bulkOut,ssub,layer,numberOfLayers,nrepeats); plot(newProf(:,1)-49,newProf(:,2)); end end