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

CalculateDIFC v1

Summary

Calculate the DIFC for every pixel

See Also

ConvertDiffCal

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

Mandatory

Name of the workspace to have DIFC calculated from

OutputWorkspace

Output

MatrixWorkspace

Mandatory

Workspace containing DIFC for each pixel

CalibrationWorkspace

Input

TableWorkspace

Optional: A TableWorkspace containing the DIFC values, which will be copied. This property cannot be set in conjunction with property OffsetsWorkspace.

OffsetMode

Input

string

Relative

Optional: Whether to calculate a relative, absolute, or signed offset. Default relative. Allowed values: [‘Relative’, ‘Absolute’, ‘Signed’]

BinWidth

Input

number

Optional

Optional: The bin width of the X axis. If using ‘Signed’ OffsetMode, this value is mandatory

OffsetsWorkspace

Input

OffsetsWorkspace

Optional: A OffsetsWorkspace containing the calibration offsets. This property cannot be set in conjunction with property CalibrationWorkspace.

Description

CalculateDIFC calculates the value of \(DIFC\) for every pixel in an instrument.

\[DIFC = \frac{m_n}{h} \frac{(L_1 + L_2) 2 \sin(\theta)}{1 + {offset}}\]

Or if OffsetMode is Signed \(DIFC\) will be calculated with the following equation for logarithmically binned data:

\[DIFC = \frac{m_n}{h} \cdot (L1 + L2) 2 \sin(\theta) \cdot (1+|BinWidth|)^{-offset}\]

DIFC is used in the equation

\[TOF = DIFC \times d\]

This algorithm uses the same underlying calculation as ConvertUnits v1 and AlignDetectors v1.

When specifying the CalibrationWorkspace, this algorithm copies the values in the detid and difc columns of the calibration workspace. It ignores any other calibration constants, such as difa and tzero (for more information, see the Diffraction Calibration Workspace concept page).

Assumptions: There are no assumptions and this algorithm works on the results of LoadEmptyInstrument v1.

Usage

Example - CalculateDIFC

ws = LoadEmptyInstrument(Filename="NOMAD_Definition.xml", OutputWorkspace="ws")
ws = CalculateDIFC(ws, OutputWorkspace="ws")

# Print the result
print("The output workspace has {} spectra".format(ws.getNumberHistograms()))
print("DIFC of pixel {} is {:.0f}".format(100, ws.readY(100)[0]))

Output:

The output workspace has 101376 spectra
DIFC of pixel 100 is 1274

Determining traditional offsets

ws = LoadEmptyInstrument(Filename="NOMAD_Definition.xml", OutputWorkspace="ws")
LoadDiffCal(InputWorkspace=ws, Filename='NOM_cal.h5', WorkspaceName='NOM')
uncalibrated = CalculateDIFC(ws, OutputWorkspace="uncalibrated")
calibrated = CalculateDIFC(ws, CalibrationWorkspace="NOM_cal", OutputWorkspace="calibrated")

offsets = calibrated/uncalibrated - 1.

Categories: AlgorithmIndex | Diffraction\Utility

Source

C++ header: CalculateDIFC.h

C++ source: CalculateDIFC.cpp