Skip to content
Snippets Groups Projects
ConvertSpectrumAxis-v1.rst 1.36 KiB
Newer Older
.. relatedalgorithms::

.. properties::

Description
-----------

Converts the representation of the vertical axis (the one up the side of
a matrix in MantidPlot) of a Workspace2D 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 :math:`\theta`, the value placed in the axis is
generated by using the :ref:`algm-ConvertUnits` 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**

.. testcode::

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

.. testoutput::

   There are 4 axis values
   Final theta value: 0.129645 (degrees)