Table of Contents
Clones the input MatrixWorkspace(s) and orders the x-axis in an ascending or descending fashion.
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’] |
IgnoreHistogramValidation | Input | boolean | False | This will stop SortXAxis from throwing if the workspace is not a valid histogram for this algorithm to work on. THIS IS TEMPORARY, this item will be removed for 4.1 and thus should only be used internally for the TOSCA legacy data in indirect . |
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.
#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: Algorithm Index | Transforms\Axes | Utility\Sorting
C++ source: SortXAxis.cpp (last modified: 2019-03-20)
C++ header: SortXAxis.h (last modified: 2018-10-05)