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

ConvertSpectrumAxis v2

Summary

Converts the axis of a Workspace2D which normally holds spectrum numbers to one of 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.

See Also

ConvertAxesToRealSpace, ConvertUnits

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 spectrum axis is converted to - “theta” (for the angle in degrees), Q or Q^2, where elastic Q is evaluated at EFixed. InPlaneTwoTheta and SignedInPlaneTwoTheta are the angle when each point is projected on the horizontal plane.Note that ‘theta’ and ‘signed_theta’ are there for compatibility purposes; they are the same as ‘Theta’ and ‘SignedTheta’ respectively. Allowed values: [‘Theta’, ‘SignedTheta’, ‘InPlaneTwoTheta’, ‘SignedInPlaneTwoTheta’, ‘ElasticQ’, ‘ElasticQSquared’, ‘theta’, ‘signed_theta’, ‘ElasticDSpacing’]

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))

OrderAxis

Input

boolean

True

Whether or not to sort the resulting spectrum axis.

Description

Converts the representation of the vertical axis of a MatrixWorkspace from its default of holding the spectrum number to the target unit given - theta, elastic Q, elastic Q^2 or elastic d-spacing.

The spectra will be reordered in increasing order by default, however this can be disabled by OrderAxis=False. In the case of the latter, spectra will preserve correspondence to the original workspace. 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.

InPlane2Theta and SignedInPlane2Theta return the 2theta value of the projection of the pixel on the horizontal scattering plane.

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")

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)

Example: Convert vertical axis to elastic Q for direct geometry

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

qws = ConvertSpectrumAxis(dataws, Target="ElasticQ", EFixed=15., EMode="Direct")

vertical_axis = qws.getAxis(1)
print("There are {} axis values".format(vertical_axis.length()))
print("Final Q value: {:.6f} (A^-1)".format(vertical_axis.getValue(vertical_axis.length() - 1)))
There are 4 axis values
Final Q value: 0.006088 (A^-1)

Categories: AlgorithmIndex | Transforms\Units | Transforms\Axes

Source

C++ header: ConvertSpectrumAxis2.h

C++ source: ConvertSpectrumAxis2.cpp