CreateUserDefinedBackground v1

../_images/CreateUserDefinedBackground-v1_dlg.png

CreateUserDefinedBackground dialog.

Summary

Creates a workspace of background data from a user-supplied set of points. This workspace can then be subtracted from the original data.

Properties

Name Direction Type Default Description
InputWorkspace Input MatrixWorkspace Mandatory Input workspace containing data and background
BackgroundPoints Input TableWorkspace Mandatory Table containing user-defined background points
OutputBackgroundWorkspace Output MatrixWorkspace Mandatory Workspace containing background to be subtracted

Description

Given an input workspace containing data with a background and a table of user-selected points defining the background, creates a new workspace containing background data that can be subtracted from the original data.

The background is constructed using linear interpolation at the same X values as the input workspace.

Typical use case

  1. Spectrum has several peaks on top of a large, irregularly shaped background.
  2. Plot spectrum and use Data > Draw Data Points in MantidPlot to define the background. Clicking anywhere outside of the graph will show a table with the points defined by clicking.
  3. Convert table to a TableWorkspace (Table > Convert to TableWorkspace)
  4. Run this algorithm, giving it the original data and the background table. It will return a workspace filled with background data.
  5. Use Minus v1 to subtract the returned workspace from the original data workspace.

Usage

Example - CreateUserDefinedBackground

# Create data: background + peak
dataX = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
background = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45]
peak = [0, 1, 4, 1, 0, 0, 0, 0, 0, 0]
dataY = [a + b for a, b in zip(background, peak)]
dataWS = CreateWorkspace(dataX, dataY)

# Create table of user-supplied background points
# In real use this would be done via the GUI
background_points = CreateEmptyTableWorkspace()
background_points.addColumn("double", "X", 1)
background_points.addColumn("double", "Y", 2)
for i in range(10):
   background_points.addRow([dataX[i], background[i]])

# Create background workspace and subtract it from data
backgroundWS = CreateUserDefinedBackground(InputWorkspace=dataWS, BackgroundPoints=background_points)
peakWS = Minus(dataWS, backgroundWS)


# Check that workspace matches expected peak
expected = CreateWorkspace(dataX, peak)
result, messages = CompareWorkspaces(peakWS, expected)
print "Workspaces match:", result

Output:

Workspaces match: True

Categories: Algorithms | CorrectionFunctions\BackgroundCorrections