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

SortXAxis v1

../_images/SortXAxis-v1_dlg.png

SortXAxis dialog.

Summary

Clones the input MatrixWorkspace(s) and orders the x-axis in an ascending or descending fashion.

Properties

Name Direction Type Default Description
InputWorkspace Input MatrixWorkspace Mandatory Input Workspace
OutputWorkspace Output MatrixWorkspace Mandatory Sorted Output Workspace
Ordering Input string Ascending Ascending or descending sorting. Allowed values: [‘Ascending’, ‘Descending’]

Description

Clones the input Matrix Workspaces and orders the x-axis in an ascending or descending fashion. Ensures that the y-axis and error data as well as optional Dx data are sorted in a consistent way with the x-axis.

This algorithm is for use with either point data based workspaces or histogram based workspaces. It is particularly suitable for reformatting workspaces loaded via LoadAscii.

Usage

#Import requirements
import numpy as np

# Create the workspace
dataX = [2., 1., 3.]
dataY = [2., 1., 3.]
dataE = [2., 1., 3.]
ws = CreateWorkspace(DataX=dataX,DataY=dataY,DataE=dataE,UnitX='TOF',Distribution=True)

# Print out the "Unordered X Axis"
print("Unordered Print")
print(ws.readX(0))
print(ws.readY(0))
print(ws.readE(0))

# Sort the X Axis in a Descending fashion
ws = SortXAxis(InputWorkspace='ws', Ordering='Descending')
print("In order print: Descending")
print(ws.readX(0))
print(ws.readY(0))
print(ws.readE(0))

# Sort the X Axis in a Ascending fashion
ws = SortXAxis(InputWorkspace='ws', Ordering='Ascending')
print("In order print: Ascending")
print(ws.readX(0))
print(ws.readY(0))
print(ws.readE(0))

Output:

Unordered Print
[ 2.  1.  3.]
[ 2.  1.  3.]
[ 2.  1.  3.]
In order print: Descending
[ 3.  2.  1.]
[ 3.  2.  1.]
[ 3.  2.  1.]
In order print: Ascending
[ 1.  2.  3.]
[ 1.  2.  3.]
[ 1.  2.  3.]

Categories: AlgorithmIndex | Transforms\Axes | Utility\Sorting

Source

C++ header: SortXAxis.h

C++ source: SortXAxis.cpp