\(\renewcommand\AA{\unicode{x212B}}\)

MDHistoToWorkspace2D v1

../_images/MDHistoToWorkspace2D-v1_dlg.png

MDHistoToWorkspace2D dialog.

Summary

Flattens a n dimensional MDHistoWorkspace into a Workspace2D with many spectra

Properties

Name Direction Type Default Description
InputWorkspace Input IMDHistoWorkspace Mandatory  
OutputWorkspace Output Workspace Mandatory  

Description

MDHistoToWorkspace2D flattens a MDHistoWorkspace into a Workspace2D. It can process MDHistoWorkspaces of any dimensionality. The last dimension of the MDHistoWorkspace becomes the spectra length. Flattening happens such that the first dimension of the MDHistoWorkspace is the slowest varying, the second the second slowest varying and so on.

This tool is useful as many algorithms in Mantid only apply to Workspace2D. After conversion with MDHistoToWorkspace2D such algorithms can also be applied to MD data.

Usage

Example - Flatten a small workspace:

# Create input workspace
CreateMDWorkspace(Dimensions=3, Extents='-10,10,-10,10,-10,10', Names='A,B,C', Units='U,U,U', OutputWorkspace='demo')
FakeMDEventData(InputWorkspace='demo', PeakParams='32,0,0,0,1')
input = BinMD(InputWorkspace='demo', AlignedDim0='A,-2,2,4', AlignedDim1='B,-2,2,4', AlignedDim2='C,-2,2,4')

# Run the algorithm
output = MDHistoToWorkspace2D(InputWorkspace='input')

# print 6th group of 4 bins in both input and output workspaces
print("part of MD workspace {}".format(input.getSignalArray()[1,1]))
print("corresponding part of 2D workspace {}".format(output.dataY(5) ))

Output:

part of MD workspace [ 0.  4.  5.  0.]
corresponding part of 2D workspace [ 0.  4.  5.  0.]

Categories: AlgorithmIndex | MDAlgorithms\Transforms

Source

C++ header: MDHistoToWorkspace2D.h (last modified: 2020-03-25)

C++ source: MDHistoToWorkspace2D.cpp (last modified: 2020-04-07)