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

SortPeaksWorkspace v1

../_images/SortPeaksWorkspace-v1_dlg.png

SortPeaksWorkspace dialog.

Summary

Sort a peaks workspace by a column of the workspace

See Also

CreatePeaksWorkspace

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

IPeaksWorkspace

Mandatory

An input workspace.

OutputWorkspace

Output

IPeaksWorkspace

Mandatory

An output workspace.

ColumnNameToSortBy

Input

string

Mandatory

Column to sort by

SortAscending

Input

boolean

True

Sort the OutputWorkspace by the target column in a Ascending fashion.

Description

Sort a peaks workspace by a single column. Sorting of that PeaksWorkspace by that column can either happen in an ascending or descending fashion. The algorithm can either be used to generate a new OutputWorkspace, which is sorted as requested, or to perform an in-place sort of the InputWorkspace.

Usage

Example - sort a peaks workspace by column name:

peaks_ws = LoadIsawPeaks(Filename='TOPAZ_1204.peaks')

#sort the table by column k
peaks_ws = SortPeaksWorkspace(peaks_ws, ColumnNameToSortBy='k')
print("Column k in ascending order: " + str(peaks_ws.column('k')))

#the algorithm can also sort in descending order
peaks_ws = SortPeaksWorkspace(peaks_ws, ColumnNameToSortBy='k', SortAscending=False)
print("Column k in descending order: " + str(peaks_ws.column('k')))

Output:

Column k in ascending order: [-3.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -0.0, -0.0, -0.0, 0.0, -0.0, -0.0, 0.0, -0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 4.0, 5.0, 5.0]
Column k in descending order: [5.0, 5.0, 4.0, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -0.0, -0.0, -0.0, 0.0, -0.0, -0.0, 0.0, -0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -3.0]

Categories: AlgorithmIndex | Crystal\Peaks | Utility\Sorting

Source

C++ header: SortPeaksWorkspace.h

C++ source: SortPeaksWorkspace.cpp