TOFTOFConvertTofToDeltaE v1

../_images/TOFTOFConvertTofToDeltaE-v1_dlg.png

TOFTOFConvertTofToDeltaE dialog.

Summary

Converts X-axis units from TOF to energy transfer dE.

Properties

Name Direction Type Default Description
InputWorkspace Input MatrixWorkspace Mandatory Input Sample workspace
VanadiumWorkspace Input MatrixWorkspace   Input Vanadium workspace (optional)
OutputWorkspace Output Workspace Mandatory Name the workspace that will contain the result
ChoiceElasticTof Input string Geometry Allowed values: [‘Geometry’, ‘FitVanadium’, ‘FitSample’]

Description

Converts X-axis units of the given workspace or group of workspaces from time-of-flight to energy transfer. Conversion is performed in a following way. The new X-axis data (\Delta E, meV) are calculated as

\Delta E = \frac{1}{2} C m_n L^2\cdot\left(\frac{1}{t_{el}^2} - \frac{1}{t^2}\right)

where L is the sample-detector distance, m_n is the neutron mass, t_{el} is the time-of-flight corresponding to the elastic peak, t is the time-of-flight corresponding to the bin boundaries of the X data in the input workspace. Coefficient C is related to the unit conversion and calculated as

C = \frac{10^{12}\cdot 10^3}{1.6\cdot 10^{-19}}

where 1.6\cdot 10^{-19} is the coefficient to convert energy from eV to Joule, 10^3 is the coefficient to convert eV to meV and 10^{12} is the coefficient to convert \mu\mathrm{sec}^2 to \mathrm{seconds}^2.

In contrast to the ConvertUnits v1, this algorithm calculates the new Y values I_E(\Delta E) as

I_E (\Delta E) = \frac{t_c^3}{C\cdot m_n\cdot L^2\cdot\Delta t}\cdot I(t)

where t_c is the time-of-flight corresponding to the bin centre in the X data in the input workspace, \Delta t is the time channel width, and I(t) are the Y data in the given input workspace.

This algorithm offers three options for calculation of the elastic peak position t_{el}:

  1. Geometry: position of the elastic peak will be taken from the EPP sample log.
  2. FitVanadium: position of the elastic peak will be determined from the Gaussian fit of the given Vanadium workspace.
  3. FitSample: position of the elastic peak will be determined from the Gaussian fit of the given input workspace.

If position of the elastic peak cannot be determined or t_{el} = 0 for a particular detector, this detector will be masked in the output workspace and warning will be produced.

Restrictions on the input workspaces

  • The unit of the X-axis must be Time-of-flight.

  • Workspace must contain following sample logs: channel_width, chopper_ratio, chopper_speed, Ei, wavelength, EPP.

  • Workpace must have an instrument set.

  • If option ChoiceElasticTof is set to FitVanaduim:

    1. valid Vanadium workspace must be provided
    2. sample logs channel_width, chopper_ratio, chopper_speed, Ei, wavelength, EPP must match for both, Vanadium and input workspaces.

Usage

Example 1: Convert using the default option.

import numpy

# create workspace with appropriate sample logs
ws_tof = CreateSampleWorkspace(Function="User Defined", UserDefinedFunction="name=LinearBackground, \
            A0=0.3;name=Gaussian, PeakCentre=6000, Height=5, Sigma=75", NumBanks=2, BankPixelWidth=1,
            XMin=4005.75, XMax=7995.75, BinWidth=10.5, BankDistanceFromSample=4.0)

lognames="channel_width,chopper_ratio,chopper_speed,Ei,wavelength,EPP"
logvalues="10.5,5,14000,2.27,6,190.0"
AddSampleLogMultiple(ws_tof, lognames, logvalues)

ws_dE=TOFTOFConvertTofToDeltaE(ws_tof)

print "Unit of X-axis before conversion: ", ws_tof.getAxis(0).getUnit().unitID()
print "Unit of X-axis after conversion: ",  ws_dE.getAxis(0).getUnit().unitID()
print "First 5 X values before conversion: ", ws_tof.readX(0)[:5]
print "First 5 X values after conversion: ", numpy.round(ws_dE.readX(0)[:5], 2)

Output:

Unit of X-axis before conversion:  TOF
Unit of X-axis after conversion:  DeltaE
First 5 X values before conversion:  [ 4005.75  4016.25  4026.75  4037.25  4047.75]
First 5 X values after conversion:  [-2.89 -2.86 -2.84 -2.81 -2.78]

Example 2: Convert using the FitSample option.

import numpy

# create workspace with appropriate sample logs
ws_tof = CreateSampleWorkspace(Function="User Defined", UserDefinedFunction="name=LinearBackground, \
            A0=0.3;name=Gaussian, PeakCentre=6000, Height=5, Sigma=75", NumBanks=2, BankPixelWidth=1,
            XMin=4005.75, XMax=7995.75, BinWidth=10.5, BankDistanceFromSample=4.0)

lognames="channel_width,chopper_ratio,chopper_speed,Ei,wavelength,EPP"
logvalues="10.5,5,14000,2.27,6,190.0"
AddSampleLogMultiple(ws_tof, lognames, logvalues)

ws_dE=TOFTOFConvertTofToDeltaE(ws_tof, ChoiceElasticTof='FitSample')

print "Unit of X-axis before conversion: ", ws_tof.getAxis(0).getUnit().unitID()
print "Unit of X-axis after conversion: ",  ws_dE.getAxis(0).getUnit().unitID()
print "First 5 X values before conversion: ", ws_tof.readX(0)[:5]
print "First 5 X values after conversion: ", numpy.round(ws_dE.readX(0)[:5], 2)

Output:

Unit of X-axis before conversion:  TOF
Unit of X-axis after conversion:  DeltaE
First 5 X values before conversion:  [ 4005.75  4016.25  4026.75  4037.25  4047.75]
First 5 X values after conversion:  [-2.89 -2.87 -2.84 -2.81 -2.79]

Categories: Algorithms | PythonAlgorithms\MLZ\TOFTOF | Transforms\Units | CorrectionFunctions