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

ConvertSpectrumAxis v1

../_images/ConvertSpectrumAxis-v1_dlg.png

ConvertSpectrumAxis dialog.

Summary

Converts the axis of a Workspace2D which normally holds spectrum numbers to some other unit, which will normally be some physical value about the instrument such as Q, Q^2 or theta. ‘Note’: After running this algorithm, some features will be unavailable on the workspace as it will have lost all connection to the instrument. This includes things like the 3D Instrument Display.

Properties

Name Direction Type Default Description
InputWorkspace Input MatrixWorkspace Mandatory The name of the input workspace.
OutputWorkspace Output MatrixWorkspace Mandatory The name to use for the output workspace.
Target Input string Mandatory The unit to which the spectrum axis should be converted. This can be either “theta” (for <math>theta</math> degrees), or any of the IDs known to the [[Unit Factory]]. Allowed values: [‘AtomicDistance’, ‘Degrees’, ‘DeltaE’, ‘DeltaE_inFrequency’, ‘DeltaE_inWavenumber’, ‘dSpacing’, ‘dSpacingPerpendicular’, ‘Empty’, ‘Energy’, ‘Energy_inWavenumber’, ‘Label’, ‘Momentum’, ‘MomentumTransfer’, ‘Phi’, ‘QSquared’, ‘SpinEchoLength’, ‘SpinEchoTime’, ‘Temperature’, ‘Time’, ‘TOF’, ‘Wavelength’, ‘theta’, ‘signed_theta’]
EMode Input string Direct Some unit conversions require this value to be set (“Direct” or “Indirect”). Allowed values: [‘Direct’, ‘Indirect’]
EFixed Input number Optional Value of fixed energy in meV : EI (EMode=Direct) or EF (EMode=Indirect))

Description

Converts the representation of the vertical axis of a MatrixWorkspace from its default of holding the spectrum number to the target unit given.

The spectra will be reordered in increasing order by the new unit and duplicates will not be aggregated. Any spectrum for which a detector is not found (i.e. if the instrument definition is incomplete) will not appear in the output workspace.

For units other than \(\theta\), the value placed in the axis is generated by using the ConvertUnits v1 methods to translate the values of the first and last bin for the current X-data unit into the target unit, then taking the mid-point of these.

Usage

Example: Convert Vertical Axis to Theta

# Creates a workspace with some detectors attached
dataws = CreateSampleWorkspace(NumBanks=1,BankPixelWidth=2) # 2x2 detector

theta = ConvertSpectrumAxis(dataws, Target="theta", Version=1)

vertical_axis = theta.getAxis(1)
print("There are {} axis values".format(vertical_axis.length()))
print("Final theta value: {:.6f} (degrees)".format(vertical_axis.getValue(vertical_axis.length() - 1)))
There are 4 axis values
Final theta value: 0.129645 (degrees)

Categories: AlgorithmIndex | Transforms\Units | Transforms\Axes