Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
CutMD-v1.rst 6.59 KiB

Description

This algorithm performs slicing of multiDimensional data according to a chosen projection, limits and binning steps.

The synax is similar to that used by Horace.

Unlike most Mantid algorithms, CutMD can accept a list of workspaces as the input workspace, given as the name of a workspace in the analysis data service or the path to a workspace, or simply a workspace object in python. These will all then be processed sequentially with the same options. The only requirement is that the same number of output workspaces are also given so that CutMD knows what to call each output workspace created.

MDEventWorkspaces

For input of type :ref:`MDEventWorkspace <MDWorkspace>` the algorithm uses :ref:`algm-BinMD` or :ref:`algm-SliceMD` to achieve the binning of the data. The choice of child algorithm used for slicing in this case is controlled by the NoPix option.

MDHistoWorkspaces

If the input is an :ref:`MDHistoWorkspace <MDHistoWorkspace>` :ref:`algm-BinMD` and :ref:`algm-SliceMD` are not made available as they needto get hold of the original MDEvents associated with an :ref:`MDEventWorkspace <MDWorkspace>` in order to perform the rebinning. As this information is missing from the MDHistoWorkspace images, those operations are forbidden. Instead, a limited subset of the operations are allowed, and are performed via :ref:`algm-IntegrateMDHistoWorkspace`. In this case, the Projection and NoPix properties are ignored. See :ref:`algm-IntegrateMDHistoWorkspace` for how the binning parameters are used.

Creating Projections

Projections are used by CutMD to transform the multidimensional data prior to cutting it. Projections are provided to CutMD in the form of a :ref:`TableWorkspace <Table Workspaces>`. The format of these workspaces is as follows:

Column Type Purpose
name string Specifies the dimension the row controls. Can be 'u', 'v', or 'w'.
value V3D A 3 dimensional vector specifying the axis for the dimension. Example: [1,-1,0]
offset double The offset value to use for this dimension.
type string The type/unit of this dimension. 'r' is RLU, 'a' is inverse angstroms.

A projection table should have three rows: one for u, one for v, and one for w.

There is a helper class called Projection that can be used to construct these projection tables for you automatically. For example:

from mantid.api import Projection
# Create an identity projection
proj_id = Projection([1,0,0], [0,1,0], [0,0,1])

# Automatically infer third dimension as being orthogonal to the first two
proj_rot = Projection([1,1,0], [1,-1,0])

# Set other properties
proj_prop = Projection()
proj_prop.setOffset(0, 100) # Set u offset to 100
proj_prop.setOffset(1, -5.0) # Set v offset to -5
proj_prop.setType(1, 'r') # Set v type to be RLU
proj_prop.setType(2, 'a') # Set w type to be inverse angstroms

#Create table workspaces from these projections
ws_id = proj_id.createWorkspace() # Named ws_id
proj_rot.createWorkspace(OutputWorkspace="ws_rot") # Name ws_rot

When calling createWorkspace inside of algorithms like CutMD, the OutputWorkspace name must be provided, or createWorkspace will not know what to call the created workspace:

#Good:
CutMD(..., Projection=proj.createWorkspace(OutputWorkspace='proj_ws'), ...)

#Bad:
CutMD(..., Projection=proj.createWorkspace(), ...)

Usage

Example - Contrived example using projections:

Output:

Example - CutMD on MDHistoWorkspace:

Output: