Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions targetFunctions/+domainsTF/domainsReflectivity.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,28 @@
% Extract parameters from problemStruct
[numberOfContrasts, geometry, contrastBackgroundIndices,...
contrastResolutionIndices, backgroundParamValues, resolutionParamValues,...
qzshifts, scalefactors, bulkIns, bulkOuts, domainRatios, dataPresent,...
nParams, paramValues, resample, contrastBackgroundTypes, contrastBackgroundActions,...
contrastResolutionTypes, contrastCustomFiles, useImaginary, repeatLayers,...
data, dataLimits, simulationLimits, inputContrastLayers, customFiles,...
domainContrastLayers] = extractProblemParams(problemStruct);
dataPresent, paramValues, resample, contrastBackgroundTypes,...
contrastBackgroundActions, contrastResolutionTypes, contrastCustomFiles,...
useImaginary, repeatLayers, data, dataLimits, simulationLimits,...
inputContrastLayers, layersDetails, customFiles, domainContrastLayers...
] = extractProblemParams(problemStruct);

nParams = length(problemStruct.params);
calcSld = controls.calcSldDuringFit;
parallel = controls.parallel;
numSimulationPoints = controls.numSimulationPoints;
resampleMinAngle = controls.resampleMinAngle;
resampleNPoints = controls.resampleNPoints;

% Find the actual values from the indices given in each contrast
scalefactors = problemStruct.scalefactors(problemStruct.contrastScalefactors)';
bulkIns = problemStruct.bulkIns(problemStruct.contrastBulkIns)';
bulkOuts = problemStruct.bulkOuts(problemStruct.contrastBulkOuts)';
domainRatios = problemStruct.domainRatios(problemStruct.contrastDomainRatios)';

% qzshifts are not included as a parameter in RAT,
% so we set up dummy values for the reflectivity calculation
qzshifts = zeros(problemStruct.numberOfContrasts,1);

% Allocate the memory for the output arrays before the main loop
subRoughs = zeros(numberOfContrasts,1);
Expand Down Expand Up @@ -77,7 +88,7 @@
% parameters to all the layers in the layers list. This only
% needs to be done once, and so is done outside the contrasts
% loop
layerValues = allocateParamsToLayers(paramValues, problemStruct.layersDetails);
layerValues = allocateParamsToLayers(paramValues, layersDetails);

for i = 1:numberOfContrasts

Expand Down
22 changes: 16 additions & 6 deletions targetFunctions/+normalTF/normalReflectivity.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,27 @@
% Extract parameters from problemStruct
[numberOfContrasts, geometry, contrastBackgroundIndices,...
contrastResolutionIndices, backgroundParamValues, resolutionParamValues,...
qzshifts, scalefactors, bulkIns, bulkOuts, ~, dataPresent, nParams,...
paramValues, resample, contrastBackgroundTypes, contrastBackgroundActions,...
contrastResolutionTypes, contrastCustomFiles, useImaginary, repeatLayers,...
data, dataLimits, simulationLimits, contrastLayersIndices, customFiles,...
~] = extractProblemParams(problemStruct);
dataPresent, paramValues, resample, contrastBackgroundTypes,...
contrastBackgroundActions, contrastResolutionTypes, contrastCustomFiles,...
useImaginary, repeatLayers, data, dataLimits, simulationLimits,...
contrastLayersIndices, layersDetails, customFiles, ~...
] = extractProblemParams(problemStruct);

nParams = length(problemStruct.params);
calcSld = controls.calcSldDuringFit;
parallel = controls.parallel;
numSimulationPoints = controls.numSimulationPoints;
resampleMinAngle = controls.resampleMinAngle;
resampleNPoints = controls.resampleNPoints;

% Find the actual values from the indices given in each contrast
scalefactors = problemStruct.scalefactors(problemStruct.contrastScalefactors)';
bulkIns = problemStruct.bulkIns(problemStruct.contrastBulkIns)';
bulkOuts = problemStruct.bulkOuts(problemStruct.contrastBulkOuts)';

% qzshifts are not included as a parameter in RAT,
% so we set up dummy values for the reflectivity calculation
qzshifts = zeros(problemStruct.numberOfContrasts,1);

% Allocate the memory for the output arrays before the main loop
subRoughs = zeros(numberOfContrasts,1);
Expand Down Expand Up @@ -57,7 +67,7 @@
% parameters to all the layers in the layers list. This only
% needs to be done once, and so is done outside the contrasts
% loop
layerValues = allocateParamsToLayers(paramValues, problemStruct.layersDetails);
layerValues = allocateParamsToLayers(paramValues, layersDetails);

for i = 1:numberOfContrasts

Expand Down
35 changes: 6 additions & 29 deletions targetFunctions/common/extractProblemParams.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function [numberOfContrasts, geometry, contrastBackgroundParams,...
contrastResolutionParams, backgroundParams, resolutionParams, qzshifts,...
scalefactors, bulkIns, bulkOuts, domainRatios, dataPresent, nParams, params,...
resample, contrastBackgroundTypes, contrastBackgroundActions, contrastResolutionTypes,...
contrastCustomFiles, useImaginary, repeatLayers, data, dataLimits, simulationLimits,...
contrastLayers, customFiles, domainContrastLayers] = extractProblemParams(problemStruct)
contrastResolutionParams, backgroundParams, resolutionParams, dataPresent,...
params, resample, contrastBackgroundTypes, contrastBackgroundActions,...
contrastResolutionTypes, contrastCustomFiles, useImaginary, repeatLayers,...
data, dataLimits, simulationLimits, contrastLayers, layersDetails, customFiles,...
domainContrastLayers] = extractProblemParams(problemStruct)

resample = problemStruct.resample;
data = problemStruct.data;
Expand All @@ -21,34 +21,11 @@
contrastResolutionTypes = problemStruct.contrastResolutionTypes;
backgroundParams = problemStruct.backgroundParams;
resolutionParams = problemStruct.resolutionParams;
nParams = length(problemStruct.params);
params = problemStruct.params;
contrastLayers = problemStruct.contrastLayers;
layersDetails = problemStruct.layersDetails;
customFiles = problemStruct.customFiles;
contrastCustomFiles = problemStruct.contrastCustomFiles;
domainContrastLayers = problemStruct.domainContrastLayers;


% qzshifts are not included as a parameter in RAT, so we set up dummy
% values for the reflectivity calculation
contrastQzshifts = ones(1,problemStruct.numberOfContrasts);
qzshiftValues = 0.0;

contrastScalefactors = problemStruct.contrastScalefactors;
contrastBulkIns = problemStruct.contrastBulkIns;
contrastBulkOuts = problemStruct.contrastBulkOuts;
contrastDomainRatios = problemStruct.contrastDomainRatios;

scalefactorValues = problemStruct.scalefactors;
bulkInValues = problemStruct.bulkIns;
bulkOutValues = problemStruct.bulkOuts;
domainRatioValues = problemStruct.domainRatios;

% Find the actual values from the indices given in each contrast
qzshifts = qzshiftValues(contrastQzshifts)';
scalefactors = scalefactorValues(contrastScalefactors)';
bulkIns = bulkInValues(contrastBulkIns)';
bulkOuts = bulkOutValues(contrastBulkOuts)';
domainRatios = domainRatioValues(contrastDomainRatios)';

end
Original file line number Diff line number Diff line change
Expand Up @@ -254,28 +254,20 @@ function testCheckIndices(testCase)
end

function testExtractProblemParams(testCase)
[numberOfContrasts, geometry, contrastBackgroundParams, contrastResolutionParams, backgroundParams, resolutionParams,...
~, scalefactors, bulkIns, bulkOuts, domainRatios, dataPresent, nParams, params, resample, backgroundTypes, backgroundActions, resolutionTypes,...
contrastCustomFiles, useImaginary, repeatLayers, data, dataLimits, simulationLimits, contrastLayers, customFiles, domainContrastLayers...
[numberOfContrasts, geometry, contrastBackgroundParams, contrastResolutionParams,...
backgroundParams, resolutionParams, dataPresent, params, resample,...
backgroundTypes, backgroundActions, resolutionTypes, contrastCustomFiles,...
useImaginary, repeatLayers, data, dataLimits, simulationLimits, contrastLayers,...
layersDetails, customFiles, domainContrastLayers...
] = extractProblemParams(testCase.problemStruct);

testScalefactors = testCase.problemStruct.scalefactors(testCase.problemStruct.contrastScalefactors)';
testBulkIns = testCase.problemStruct.bulkIns(testCase.problemStruct.contrastBulkIns)';
testBulkOuts = testCase.problemStruct.bulkOuts(testCase.problemStruct.contrastBulkOuts)';
testDomainRatios = testCase.problemStruct.domainRatios(testCase.problemStruct.contrastDomainRatios)';

testCase.verifyEqual(numberOfContrasts, testCase.problemStruct.numberOfContrasts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(geometry, testCase.problemStruct.geometry, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(contrastBackgroundParams, testCase.problemStruct.contrastBackgroundParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(contrastResolutionParams, testCase.problemStruct.contrastResolutionParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(backgroundParams, testCase.problemStruct.backgroundParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(resolutionParams, testCase.problemStruct.resolutionParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(scalefactors, testScalefactors, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(bulkIns, testBulkIns, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(bulkOuts, testBulkOuts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(domainRatios, testDomainRatios, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(dataPresent, testCase.problemStruct.dataPresent, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(nParams, length(testCase.problemStruct.params), 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(params, testCase.problemStruct.params, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(resample, testCase.problemStruct.resample, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(backgroundTypes, testCase.problemStruct.contrastBackgroundTypes, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
Expand All @@ -288,6 +280,7 @@ function testExtractProblemParams(testCase)
testCase.verifyEqual(dataLimits, testCase.problemStruct.dataLimits, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(simulationLimits, testCase.problemStruct.simulationLimits, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(contrastLayers, testCase.problemStruct.contrastLayers, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(layersDetails, testCase.problemStruct.layersDetails, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(customFiles, testCase.problemStruct.customFiles, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(domainContrastLayers, testCase.problemStruct.domainContrastLayers, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,28 +268,20 @@ function testCheckIndices(testCase)
end

function testExtractProblemParams(testCase)
[numberOfContrasts, geometry, contrastBackgroundParams, contrastResolutionParams, backgroundParams, resolutionParams,...
~, scalefactors, bulkIns, bulkOuts, domainRatios, dataPresent, nParams, params, resample, backgroundTypes, backgroundActions, resolutionTypes,...
contrastCustomFiles, useImaginary, repeatLayers, data, dataLimits, simulationLimits, contrastLayers, customFiles, domainContrastLayers...
[numberOfContrasts, geometry, contrastBackgroundParams, contrastResolutionParams,...
backgroundParams, resolutionParams, dataPresent, params, resample,...
backgroundTypes, backgroundActions, resolutionTypes, contrastCustomFiles,...
useImaginary, repeatLayers, data, dataLimits, simulationLimits, contrastLayers,...
layersDetails, customFiles, domainContrastLayers...
] = extractProblemParams(testCase.problemStruct);

testScalefactors = testCase.problemStruct.scalefactors(testCase.problemStruct.contrastScalefactors)';
testBulkIns = testCase.problemStruct.bulkIns(testCase.problemStruct.contrastBulkIns)';
testBulkOuts = testCase.problemStruct.bulkOuts(testCase.problemStruct.contrastBulkOuts)';
testDomainRatios = testCase.problemStruct.domainRatios(testCase.problemStruct.contrastDomainRatios)';

testCase.verifyEqual(numberOfContrasts, testCase.problemStruct.numberOfContrasts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(geometry, testCase.problemStruct.geometry, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(contrastBackgroundParams, testCase.problemStruct.contrastBackgroundParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(contrastResolutionParams, testCase.problemStruct.contrastResolutionParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(backgroundParams, testCase.problemStruct.backgroundParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(resolutionParams, testCase.problemStruct.resolutionParams, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(scalefactors, testScalefactors, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(bulkIns, testBulkIns, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(bulkOuts, testBulkOuts, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(domainRatios, testDomainRatios, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(dataPresent, testCase.problemStruct.dataPresent, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(nParams, length(testCase.problemStruct.params), 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(params, testCase.problemStruct.params, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(resample, testCase.problemStruct.resample, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(backgroundTypes, testCase.problemStruct.contrastBackgroundTypes, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
Expand All @@ -302,6 +294,7 @@ function testExtractProblemParams(testCase)
testCase.verifyEqual(dataLimits, testCase.problemStruct.dataLimits, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(simulationLimits, testCase.problemStruct.simulationLimits, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(contrastLayers, testCase.problemStruct.contrastLayers, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(layersDetails, testCase.problemStruct.layersDetails, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(customFiles, testCase.problemStruct.customFiles, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
testCase.verifyEqual(domainContrastLayers, testCase.problemStruct.domainContrastLayers, 'RelTol', testCase.tolerance, 'AbsTol', testCase.absTolerance);
end
Expand Down
Binary file modified tests/testCommonFunctions/shiftDataInputs.mat
Binary file not shown.