diff --git a/targetFunctions/+domainsTF/domainsReflectivity.m b/targetFunctions/+domainsTF/domainsReflectivity.m index 82ff486ad..85f92416e 100644 --- a/targetFunctions/+domainsTF/domainsReflectivity.m +++ b/targetFunctions/+domainsTF/domainsReflectivity.m @@ -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); @@ -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 diff --git a/targetFunctions/+normalTF/normalReflectivity.m b/targetFunctions/+normalTF/normalReflectivity.m index 1b5856c65..1fb96b724 100644 --- a/targetFunctions/+normalTF/normalReflectivity.m +++ b/targetFunctions/+normalTF/normalReflectivity.m @@ -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); @@ -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 diff --git a/targetFunctions/common/extractProblemParams.m b/targetFunctions/common/extractProblemParams.m index 509bf9bf7..5bb5ab296 100644 --- a/targetFunctions/common/extractProblemParams.m +++ b/targetFunctions/common/extractProblemParams.m @@ -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; @@ -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 diff --git a/tests/domainsTFReflectivityCalculation/testDomainsReflectivityCalculations.m b/tests/domainsTFReflectivityCalculation/testDomainsReflectivityCalculations.m index 5b256b51a..6924b7520 100644 --- a/tests/domainsTFReflectivityCalculation/testDomainsReflectivityCalculations.m +++ b/tests/domainsTFReflectivityCalculation/testDomainsReflectivityCalculations.m @@ -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); @@ -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); diff --git a/tests/normalTFReflectivityCalculation/testReflectivityCalculations.m b/tests/normalTFReflectivityCalculation/testReflectivityCalculations.m index becced31b..d0eada9ee 100644 --- a/tests/normalTFReflectivityCalculation/testReflectivityCalculations.m +++ b/tests/normalTFReflectivityCalculation/testReflectivityCalculations.m @@ -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); @@ -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 diff --git a/tests/testCommonFunctions/shiftDataInputs.mat b/tests/testCommonFunctions/shiftDataInputs.mat index 599d9352f..269cd686c 100644 Binary files a/tests/testCommonFunctions/shiftDataInputs.mat and b/tests/testCommonFunctions/shiftDataInputs.mat differ