Skip to content

Latest commit

 

History

History
42 lines (27 loc) · 1.44 KB

SortPeaksWorkspace-v1.rst

File metadata and controls

42 lines (27 loc) · 1.44 KB

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:

ExSortPeaksWorkspaceSimple

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:

ExSortPeaksWorkspaceSimple

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]