Skip to content

Commit

Permalink
Refs #9584 Add examples for SortPeaksWorkspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Jackson committed Jun 5, 2014
1 parent f2c8427 commit cb14971
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Code/Mantid/docs/source/algorithms/SortPeaksWorkspace-v1.rst
Expand Up @@ -15,4 +15,30 @@ 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:**

.. testcode:: 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: \n" + 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: \n" + str(peaks_ws.column('k'))

Output:

.. testoutput:: 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]

.. categories::
File renamed without changes.

0 comments on commit cb14971

Please sign in to comment.