Backgrounds Class

This class makes the backgrounds in RAT. Backgrounds are defined in a two stage process. Firstly we define the actual fitted parameters. These are held in a ‘ParametersClass’ table. Then, we group these into the backgrounds themselves using a multiTypeTable(table). So, we can then use the background parameters to either define background as constant, data or a function.

The methods on the left call the methods on the right in the table.

Method in Project Class

Method in backgroundsClass

projectClass.addBackgroundParam()

backgroundsClass.backgroundParams.addParameter()

projectClass.removeBackgroundParam()

backgroundsClass.backgroundParams.removeParameter()

projectClass.setBackgroundParamValue()

backgroundsClass.backgroundParams.setValue()

projectClass.addBackground()

backgroundsClass.addBackground()

projectClass.removeBackground()

backgroundsClass.removeBackground()

Note

  1. For constant, only one parameter is supplied to multi type table.

  2. For data, only the data itself is supplied as a cell.

  3. For function, the function name is supplied, along with up to three parameters (from the parameters table) which are then supplied to the function to calculate the background.

In each case, the background can either be added to the simulation or subtracted from the data.

Example showing how backgroundsClass methods are called.
    % Change the name of the existing parameters to refer to D2O
    problem.setBacksPar(1,'name','Backs par D2O','fit',true,'min',1e-8,'max',1e-5);

    % Add a new constant background
    problem.addBackground('Background SMW','constant','Backs par SMW');

Reference

class API.projectClass.backgroundsClass(parameters, startBackground)

Backgrounds are defined in a two stage process. Firstly we define the actual fitted parameters. These are held in a ‘ParametersClass’ table. Then, we group these into the backgrounds themselves using a multiTypeTable. So, we can then use the background parameters to either define background as constant, data or a function.

For constant only one parameter is supplied to multi type table.

For data only the itself is supplied as a cell.

For function, the function name is supplied, along with up to three parameters (from the parameters table) which are then supplied to the function to calculate the background.

In each case, the background can either be added to the simulation or subtracted from the data.

addBackground(varargin)

Adds a new entry to the background table.

background.addBackground(‘New Row’); background.addBackground(‘New Row’, ‘constant’, ‘param_name’); background.addBackground(‘New Row’, ‘function’, ‘function_name’, ‘param_name’); background.addBackground(‘New Row’, ‘data’);

backgroundsClass(parameters, startBackground)

Creates a background object. The arguments should be an instance of the parameter class with the background parameters and a cell array of backgrounds

params = parametersClass({‘Background Param 1’, 1e-7, 1e-6, 1e-5, false, ‘uniform’, 0, Inf}); % background = backgroundClass(params, {‘Background 1’, ‘constant’, ‘Background Param 1’});

displayBackgroundsObject()

Displays the background parameters and background table.

getNames()

Returns a N x 1 cell array of names of the backgrounds in the object.

names = background.getNames();

removeBackground(row)

Removes a background entry from the table. Expects the index or array of indices of background(s) to remove.

background.removeBackground(2); background.removeBackground([1, 3]);

setBackground(row, varargin)

Changes the value of a given background in the table. Expects the index or name of background and keyword/value pairs to set.

background.setBackground(1, ‘name’, ‘back 1’, ‘type’, ‘constant’, ‘value1’, ‘param_name’);

setBackgroundName(row, name)

Sets the name of a given background in the table. Expects an index and the new name.

background.setBackgroundName(1, ‘new_name’);

toStruct()

Converts the class parameters into a structure array