Table of Contents
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’] |
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 (, meV) are calculated as
where is the sample-detector distance, is the neutron mass, is the time-of-flight corresponding to the elastic peak, is the time-of-flight corresponding to the bin boundaries of the X data in the input workspace. Coefficient is related to the unit conversion and calculated as
where is the coefficient to convert energy from eV to Joule, is the coefficient to convert eV to meV and is the coefficient to convert to .
In contrast to the ConvertUnits v1, this algorithm calculates the new Y values as
where is the time-of-flight corresponding to the bin centre in the X data in the input workspace, is the time channel width, and are the Y data in the given input workspace.
This algorithm offers three options for calculation of the elastic peak position :
- Geometry: position of the elastic peak will be taken from the EPP sample log.
- FitVanadium: position of the elastic peak will be determined from the Gaussian fit of the given Vanadium workspace.
- 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 for a particular detector, this detector will be masked in the output workspace and warning will be produced.
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:
- valid Vanadium workspace must be provided
- sample logs channel_width, chopper_ratio, chopper_speed, Ei, wavelength, EPP must match for both, Vanadium and input workspaces.
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
Python: TOFTOFConvertTofToDeltaE.py