SliceMD v1

../_images/SliceMD-v1_dlg.png

SliceMD dialog.

Summary

Make a MDEventWorkspace containing the events in a slice of an input MDEventWorkspace.

Properties

Name Direction Type Default Description
InputWorkspace Input IMDWorkspace Mandatory An input MDWorkspace.
AxisAligned Input boolean True Perform binning aligned with the axes of the input MDEventWorkspace?
AlignedDim0 Input string   Binning parameters for the 0th dimension. Enter it as a comma-separated list of values with the format: ‘name,minimum,maximum,number_of_bins’. Leave blank for NONE.
AlignedDim1 Input string   Binning parameters for the 1th dimension. Enter it as a comma-separated list of values with the format: ‘name,minimum,maximum,number_of_bins’. Leave blank for NONE.
AlignedDim2 Input string   Binning parameters for the 2th dimension. Enter it as a comma-separated list of values with the format: ‘name,minimum,maximum,number_of_bins’. Leave blank for NONE.
AlignedDim3 Input string   Binning parameters for the 3th dimension. Enter it as a comma-separated list of values with the format: ‘name,minimum,maximum,number_of_bins’. Leave blank for NONE.
AlignedDim4 Input string   Binning parameters for the 4th dimension. Enter it as a comma-separated list of values with the format: ‘name,minimum,maximum,number_of_bins’. Leave blank for NONE.
AlignedDim5 Input string   Binning parameters for the 5th dimension. Enter it as a comma-separated list of values with the format: ‘name,minimum,maximum,number_of_bins’. Leave blank for NONE.
BasisVector0 Input string   Description of the basis vector of the 0th output dimension.Format: ‘name, units, x,y,z,..’. name : string for the name of the output dimension. units : string for the units of the output dimension. x,y,z,...: vector definining the basis in the input dimensions space. Leave blank for NONE.
BasisVector1 Input string   Description of the basis vector of the 1th output dimension.Format: ‘name, units, x,y,z,..’. name : string for the name of the output dimension. units : string for the units of the output dimension. x,y,z,...: vector definining the basis in the input dimensions space. Leave blank for NONE.
BasisVector2 Input string   Description of the basis vector of the 2th output dimension.Format: ‘name, units, x,y,z,..’. name : string for the name of the output dimension. units : string for the units of the output dimension. x,y,z,...: vector definining the basis in the input dimensions space. Leave blank for NONE.
BasisVector3 Input string   Description of the basis vector of the 3th output dimension.Format: ‘name, units, x,y,z,..’. name : string for the name of the output dimension. units : string for the units of the output dimension. x,y,z,...: vector definining the basis in the input dimensions space. Leave blank for NONE.
BasisVector4 Input string   Description of the basis vector of the 4th output dimension.Format: ‘name, units, x,y,z,..’. name : string for the name of the output dimension. units : string for the units of the output dimension. x,y,z,...: vector definining the basis in the input dimensions space. Leave blank for NONE.
BasisVector5 Input string   Description of the basis vector of the 5th output dimension.Format: ‘name, units, x,y,z,..’. name : string for the name of the output dimension. units : string for the units of the output dimension. x,y,z,...: vector definining the basis in the input dimensions space. Leave blank for NONE.
Translation Input dbl list   Coordinates in the INPUT workspace that corresponds to (0,0,0) in the OUTPUT workspace. Enter as a comma-separated string. Default: 0 in all dimensions (no translation).
OutputExtents Input dbl list   The minimum, maximum edges of space of each dimension of the OUTPUT workspace, as a comma-separated list
OutputBins Input int list   The number of bins for each dimension of the OUTPUT workspace.
NormalizeBasisVectors Input boolean True Normalize the given basis vectors to unity. If true, then a distance of 1 in the INPUT dimensions = 1 in the OUTPUT dimensions. If false, then a distance of norm(basis_vector) in the INPUT dimension = 1 in the OUTPUT dimensions.
ForceOrthogonal Input boolean False Force the input basis vectors to form an orthogonal coordinate system. Only works in 3 dimension!
OutputWorkspace Output Workspace Mandatory Name of the output MDEventWorkspace.
OutputFilename Input string   Optional: Specify a NeXus file to write if you want the output workspace to be file-backed. Allowed extensions: [‘.nxs’]
Memory Input number -1 If OutputFilename is specified to use a file back end: The amount of memory (in MB) to allocate to the in-memory cache. If not specified, a default of 40% of free physical memory is used.
TakeMaxRecursionDepthFromInput Input boolean True Copy the maximum recursion depth from the input workspace.
MaxRecursionDepth Input number 1000 Sets the maximum recursion depth to use. Can be used to constrain the workspaces internal structure

Description

Algorithm that can take a slice out of an original MDEventWorkspace while preserving all the events contained therein.

It uses the same parameters as BinMD v1 to determine a transformation to make from input->output workspace. The difference is that BinMD v1 sums events in a regular grid whereas SliceMD moves the events into the output workspace, which boxes itself.

Please see BinMD v1 for a detailed description of the parameters.

Axis-Aligned Slice

Events outside the range of the slice are dropped. The new output MDEventWorkspace’s dimensions only extend as far as the limit specified.

Non-Axis-Aligned Slice

The coordinates of each event are transformed according to the new basis vectors, and placed in the output MDEventWorkspace. The dimensions of the output workspace are along the basis vectors specified.

Splitting Parameters

The OutputBins parameter is interpreted as the “SplitInto” parameter for each dimension. For instance, if you want the output workspace to split in 2x2x2, you would specify OutputBins=”2,2,2”.

For 1D slices, it may make sense to specify a SplitInto parameter of 1 in every other dimension - that way, boxes will only be split along the 1D direction.

Slicing a MDHistoWorkspace

It is possible to slice a MDHistoWorkspace. Each MDHistoWorkspace holds a reference to the MDEventWorkspace that created it, as well as the coordinate transformation that was used.

In this case, the algorithm is executed on the original MDEventWorkspace, in the proper coordinates. Perhaps surprisingly, the output of SliceMD on a MDHistoWorkspace is a MDEventWorkspace!

Only the non-axis aligned slice method can be performed on a MDHistoWorkspace! Of course, your basis vectors can be aligned with the dimensions, which is equivalent.

Usage

Example - Axis aligned binning

mdew = CreateMDWorkspace(Dimensions=3, Extents=[-10,10,-10,10,-10,10], Names='A, B, C', Units='U, U, U')
FakeMDEventData(mdew, PeakParams=[100000, 0, 0, 0, 1])

# Slice out all C > 0
sliced = SliceMD(InputWorkspace=mdew, AxisAligned=True, AlignedDim0='A,-10,10,10', AlignedDim1='B, -10, 10, 10', AlignedDim2='C,-10, 0, 10',)

dim0=sliced.getDimension(0)
dim1=sliced.getDimension(1)
dim2=sliced.getDimension(2)

print "A extents", dim0.getMinimum(), dim0.getMaximum()
print "B extents", dim1.getMinimum(), dim1.getMaximum()
print "C extents", dim2.getMinimum(), dim2.getMaximum()
print "Original MDEW should have 2*N events in sliced. We get a factor of : ",  int( mdew.getNEvents() / sliced.getNEvents()  )

Output:

A extents -10.0 10.0
B extents -10.0 10.0
C extents -10.0 0.0
Original MDEW should have 2*N events in sliced. We get a factor of :  2

Example - Non-axis aligned binning

import numpy

# Create a host workspace
mdew = CreateMDWorkspace(Dimensions=2, Extents=[-10,10,-10,10], Names='A, B', Units='U, U')
# Add a peak at -5,-5
FakeMDEventData(mdew, PeakParams=[100000, -5, -5, 1])
# Add a peak at 5, 5
FakeMDEventData(mdew, PeakParams=[100000, 5, 5, 1])
# Slice at 45 degrees. BasisVector0 now runs through both peaks
sliced = SliceMD(InputWorkspace=mdew, AxisAligned=False, BasisVector0='X, sqrt(2*U^2), 1,1', BasisVector1='Y, sqrt(2*U^2),-1,1',OutputBins=[100,1], OutputExtents=[-10,10,-10,10])

# Bin it to gather statistics
binned = BinMD(sliced, AxisAligned=True,  AlignedDim0='X, 0,10, 100', AlignedDim1='Y,-10,10,1')
signals = binned.getSignalArray()

dim_x = binned.getDimension(0)
x_axis= numpy.linspace(dim_x.getMinimum(), dim_x.getMaximum(), dim_x.getNBins())
x_at_max = x_axis[numpy.argmax(signals)]
print "Brighest region should be at x  = sqrt( 2*5*5 ) = 7.07. Found to be: ", "{0:.2f}".format(x_at_max)

Output:

Brighest region should be at x  = sqrt( 2*5*5 ) = 7.07. Found to be:  7.07

Categories: Algorithms | MDAlgorithms

Source

C++ source: SliceMD.cpp

C++ header: SliceMD.h