\(\renewcommand\AA{\unicode{x212B}}\)

FindCenterOfMassPosition v2

Summary

Finds the beam center in a 2D SANS data set.

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

Mandatory

Output

Input

string

TableWorkspace will contain the center of mass position. When empty, a CenterOfMass output parameter with two elements (x,y) is created.

CenterX

Input

number

0

Initial estimate for the beam center in X in meters

CenterY

Input

number

0

Initial estimate for the beam center in Y in meters

Tolerance

Input

number

0.00125

Tolerance on the center of mass position between each iteration in meters. Suggested value is the size of a quarter of a pixel.

DirectBeam

Input

boolean

True

When true, the calculation will include the pixels within BeamRadius from the beam center. Since the process is iterative, the pixels masked by DirectBeam=False will move.

BeamRadius

Input

number

0.0155

Radius of the direct beam area, in meters, used the exclude the beam when calculating the center of mass of the scattering pattern. This is ignored when DirectBeam=True

IntegrationRadius

Input

number

Optional

Integration radius, in meters, used to include when calculating the center of mass of the scattering pattern.

Description

Finds the beam center using the direct beam method. This algorithm is used by the EQSANS and HFIR SANS reduction.

The position of the beam center \(\vec{p}\) is given by

\[\vec{p}=\frac{\sum_iI_i\vec{d}_i}{\sum_iI_i}\]

where \(i\) runs over all pixels within the largest square detector area centered on the initial guess for the beam center position. The initial guess is (CenterX, CenterY) which defaults to the center of the detector. \(I_i\) is the detector count for pixel \(i\), and \(\vec{d}_i\) is x-y projection of the pixel position. The range of pixels considered is limited to be those symmetric (in x and y separately) around the previous step’s found beam center. The calculation above is repeated iteratively by replacing the initial guess with the position found with the previous iteration. The process stops when the difference between the positions found with two consecutive iterations is smaller than Tolerance in meters.

The integration range within the symmetric area of the detector can be controlled using BeamRadius (when DirectBeam=False) and IntegrationRadius. When both are in effect the pixels integrated are those that meet the equation

\[BeamRadius < |\vec{d}_i - \vec{p}| < IntegrationRadius\]

where \(\vec{p}\) is the beam center from the previous iteration. Again, when DirectBeam=True is specified, the lower bound is ignored. When IntegrationRadius is not specified, the upper bound is ignored. Not specifying any of these three parameters uses all data within the symmetric x/y region.

If the Output property is set, the beam centre will be placed in a table workspace. Otherwise, the result is placed in an ArrayProperty named CenterOfMass.

Usage

Note

To run these usage examples please first download the usage data, and add these to your path. In Mantid this is done using Manage User Directories.

Example - Find the beam center for a BioSANS data file:

# Load your data file
LoadSpice2D('BioSANS_empty_cell.xml', OutputWorkspace='empty_cell')

# Compute the center position, which will be put in a table workspace
center = FindCenterOfMassPosition('empty_cell', Output='center')
x, y = center.column(1)
print(f"(x, y) = ({x:.4f}, {y:.4f})")

Output:

(x, y) = (-0.0066, 0.0091)

Categories: AlgorithmIndex | SANS

Source

C++ header: FindCenterOfMassPosition2.h

C++ source: FindCenterOfMassPosition2.cpp