Target Functions (Low Level API)#
- targetFunctions.reflectivityCalculation(problemStruct, controls)#
Main entry point into the reflectivity calculation for the toolbox. This is the main function that is called by any of the minimisers or analysis tools from the rest of the toolbox.
The main job of this function is to decide which type of calculation (i.e. ‘Target function’) is required, and call the relevant routines. Different model types are specified in sub functions. The types of available target functions are:
normal - The main basic target function type, for non polarised neutrons (or x-rays) with non-absorbing samples.
oil water - Target function for oil-water samples
domains - Target function for samples consisting of domains which are larger than the beam lateral coherence length.
magnetic - Target function for cases for polarised neutrons with polarisation analysis.
Common Functions#
- targetFunctions.common.backSort(contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts, qzshifts, scalefactors, bulkIn, bulkOut)#
Distributes the background and shift values among the different contrasts
- INPUTS:
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
qzshifts: List of all qzshift values
scalefactors: List of all scalefactor values
bulkIn: List of all bulkIn values
bulkOut: List of all bulkOut values
- OUTPUTS:
outQzshift: list of actual qzshift values for each contrast
outScalefactor: list of actual scalefactor values for each contrast
outBulkIn: list of actual bulkIn values for each contrast
outBulkOut: list of actual bulkOut values for each contrast
- targetFunctions.common.constructBackground(backgroundType, backgroundParamIndices, shiftedData, customFiles, backgroundParamArray, simulationXData, dataIndices)#
Apply background parameters to the background.
For function backgrounds, this means running the function using the defined parameters. For data and constant backgrounds, this means taking any predefined background data and adding any supplied parameters.
- targetFunctions.common.constructResolution(resolutionType, resolutionParamIndex, shiftedData, customFiles, resolutionParamArray, simulationXData, dataIndices)#
Apply resolution parameters to the resolution.
For data and constant resolutions, this means taking any predefined resolution data and adding any supplied parameters.
- targetFunctions.common.getFitNames(problemStruct)#
Note that this order of parameters fields is hard-coded by this routine, packParams, and packParamsPriors
- targetFunctions.common.makeSimulationRange(data, simulationLimits)#
Construct the x data for the simulation. This consists of the x data from the supplied data, plus additional points above and below the data range as necessary.
- targetFunctions.common.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:
scalefactor: problemStruct.scalefactors
qzshift: problemStruct.qzhifts
dataPresent: problemStruct.dataPresent
data: problemStruct.data
dataLimits: problemStruct.dataLimits
simLimits: problemStruct.simLimits
- OUTPUTS:
shiftedData: Data shifted using given scale factor
- targetFunctions.common.costFunctions.chiSquared(thisData, thisFit, P)#
Chi-squared function is used to evaluate the goodness of fit. It is a measure of the difference between the observed and expected.
- targetFunctions.common.groupLayers.allocateLayersForContrast(contrastLayers, outParameterisedLayers, useImaginary)#
Decide which layers are needed for a particular contrast. This function takes the master array of all layers and extracts which parameters are required for a particular contrast.
- INPUTS:
outParameterisedLayers - List of all the available layers thisContrastLayers - Array detailing which layers are required for this contrast
- targetFunctions.common.groupLayers.allocateParamsToLayers(params, layersDetails)#
Allocates parameters from the parameter array to the correct layers
This function takes the list of all layers in ‘layersDetails’, then loops over all the layers, putting in the correct parameter value from the parameters array into each layer in the ‘outLayers’ cell array
- targetFunctions.common.groupLayers.groupLayersMod(resampledLayers, subRoughs, geometry, bulkIns, bulkOuts)#
Arrange layers according to geometry and apply any coverage correction. The paratt calculation proceeds through the z,rho,rough stack, and the parameter ‘ssub’ is the final roughness encountered.
For air liquid ‘ssub’ is therefore the substrate roughness.
For solid liquid, the substrate roughness is the first roughness encountered, and ‘ssub’ is then the roughness of the outermost layer
USAGE:
[outLayers, ssubs] = groupLayersMod(resampledLayers,subRoughs,geometry,bulkIns,bulkOuts)
- INPUTS:
resampledLayers: cell array, one for each contrast. Each cell is the list of layer values for each contrast.
subRoughs: Double of substrate roughness for each contrast.
geometry: ‘Air / Liquid (or solid)’ or ‘Solid / Liquid’
bulkIns: vector of bulkIn values.
bulkOuts: vector of bulkOut values.
- Outputs:
outLayers: cell array of layers param values for each contrast.
ssubs: vector of ssub values.
- targetFunctions.common.groupLayers.groupLayersModImaginary(resampledLayers, subRoughs, geometry, bulkIns, bulkOuts)#
Arrange layers according to geometry and apply any coverage correction. The paratt calculation proceeds through the z,rho,rough stack, and the parameter ‘ssub’ is the final roughness encountered.
For air liquid ‘ssub’ is therefore the substrate roughness.
For solid liquid, the substrate roughness is the first roughness encountered, and ‘ssub’ is then the roughness of the outermost layer
USAGE:
[outLayers, ssubs] = groupLayersModImaginary(resampledLayers,subRoughs,geometry,bulkIns,bulkOuts)
- INPUTS:
resampledLayers: cell array, one for each contrast. Each cell is the list of layer values for each contrast.
subRoughs: Double of substrate roughness for each contrast.
geometry: ‘Air / Liquid (or solid)’ or ‘Solid / Liquid’
bulkIns: vector of bulkIn values.
bulkOuts: vector of bulkOut values.
- Outputs:
outLayers: cell array of layers param values for each contrast.
ssubs: vector of ssub values.
Normal Target Functions (normalTF)
- targetFunctions.normalTF.customLayers.processCustomFunction(contrastBulkIns, contrastBulkOuts, bulkInArray, bulkOutArray, cCustFiles, numberOfContrasts, customFiles, params, useImaginary)#
Top-level function for processing custom layers for all the contrasts.
- targetFunctions.normalTF.customXY.processCustomFunction(contrastBulkIns, contrastBulkOuts, bulkInArray, bulkOutArray, cCustFiles, numberOfContrasts, customFiles, params)#
Top-level function for processing custom XY profiles for all the contrasts.
Domains Target Functions (domainsTF)#
- targetFunctions.domainsTF.customLayers.processCustomFunction(contrastBulkIns, contrastBulkOuts, bulkInArray, bulkOutArray, cCustFiles, numberOfContrasts, customFiles, params, useImaginary)#
Top-level function for processing custom layers for all the contrasts.
- targetFunctions.domainsTF.customXY.processCustomFunction(contrastBulkIns, contrastBulkOuts, bulkInArray, bulkOutArray, cCustFiles, numberOfContrasts, customFiles, params)#
Top-level function for processing custom XY profiles for all the contrasts.