Skip to content

Commit

Permalink
refs #10693. Doctest and better docs
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Dec 15, 2014
1 parent 726ebd8 commit 1e827aa
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
Expand Up @@ -196,7 +196,6 @@ def __verify_input_workspace(self, to_cut):
def __verify_projection_input(self, projection_table):
if isinstance(projection_table, ITableWorkspace):
column_names = set(projection_table.getColumnNames())
logger.warning(str(column_names))
if not column_names == set([Projection.u, Projection.v, 'type']):
if not column_names == set([Projection.u, Projection.v, 'offsets', 'type']):
if not column_names == set([Projection.u, Projection.v, Projection.w, 'offsets', 'type']):
Expand Down
68 changes: 68 additions & 0 deletions Code/Mantid/docs/source/algorithms/CutMD-v1.rst
@@ -0,0 +1,68 @@
.. algorithm::

.. summary::

.. alias::

.. properties::

Description
-----------

This algorithm performs slicing of multiDimensional data according to a chosen projection, and binning choice. The algorithm uses :ref:`algm-BinMD` or
:ref:`algm-SliceMD` to achieve the binning of the data. The choice of child algorithm used for the slicing is controlled by the NoPix option.

The synax is similar to that used by `Horace <http://horace.isis.rl.ac.uk/Manipulating_and_extracting_data_from_SQW_files_and_objects#cut_sqw>`__.

Usage
-----

**Example - Contrived example using projections:**

.. testcode:: Example4D

to_cut = CreateMDWorkspace(Dimensions=4, Extents=[-1,1,-1,1,-1,1,-10,10], Names="H,K,L,E", Units="U,U,U,V")
# Add two fake peaks so that we can see the effect of the basis transformation

FakeMDEventData(InputWorkspace='to_cut', PeakParams=[10000,-0.5,0,0,0,0.1])

FakeMDEventData(InputWorkspace='to_cut', PeakParams=[10000,0.5,0,0,0,0.1])


SetUB(Workspace=to_cut, a=1, b=1, c=1, alpha=90, beta=90, gamma=90)
SetSpecialCoordinates(InputWorkspace=to_cut, SpecialCoordinates='HKL')
projection = CreateEmptyTableWorkspace()
# Correct number of columns, and names

projection.addColumn("double", "u")
projection.addColumn("double", "v")

projection.addColumn("double", "w")
projection.addColumn("double", "offsets")

projection.addColumn("str", "type")

projection.addRow([1,-1, 0, 0, "r"])

projection.addRow([1, 1, 0, 0, "r"])
projection.addRow([0, 0, 1, 0, "r"])

# Apply the cut

out_md = CutMD(to_cut, Projection=projection, P1Bin=[0.1], P2Bin=[0.1], P3Bin=[0.1], P4Bin=[-5,5], NoPix=True)
print 'number of dimensions', out_md.getNumDims()
print 'number of dimensions not integrated', len(out_md.getNonIntegratedDimensions())
dim_dE = out_md.getDimension(3)
print 'min dE', dim_dE.getMaximum()
print 'max dE', dim_dE.getMinimum()

Output:

.. testoutput:: Example4D

number of dimensions 4
number of dimensions not integrated 3
min dE 5.0
max dE -5.0

.. categories::

0 comments on commit 1e827aa

Please sign in to comment.