Table of Contents
Name | Direction | Type | Default | Description |
---|---|---|---|---|
Workspace1 | Input | IMDWorkspace | Mandatory | First MDWorkspace to compare. |
Workspace2 | Input | IMDWorkspace | Mandatory | Second MDWorkspace to compare. |
Tolerance | Input | number | 0 | The maximum amount by which values may differ between the workspaces. |
CheckEvents | Input | boolean | True | Whether to compare each MDEvent. If False, will only look at the box structure. |
Equals | Output | boolean | Boolean set to true if the workspaces match. | |
Result | Output | string | String describing the difference found between the workspaces | |
IgnoreBoxID | Input | boolean | False | To ignore box ID-s when comparing MD boxes as Multithreaded splitting assigns box id-s randomly |
Compare two MDWorkspaces (MDEventWorkspace or MDHistoWorkspace) to see if they are the same. This is mostly meant for testing/debugging use by developers.
What is compared: The dimensions, as well as the signal and error for each bin of each workspace will be compared.
MDEventWorkspace : the events in each box will be compared if the CheckEvents option is checked. The events would need to be in the same order to match.
Example - compare two MD workspaces:
# create sample inelastic workspace for MARI instrument containing 1 at all spectra
ws1=CreateSimulationWorkspace(Instrument='MAR',BinParams='-10,1,10',UnitX='DeltaE')
AddSampleLog(ws1,'Ei','12.','Number')
# create the copy of first workspace
ws1a=ws1
# create second workspace which has different signals
ws2=ws1*2;
# Convert to MD
mdWs1 =ConvertToMD(InputWorkspace=ws1,QDimensions='|Q|',QConversionScales='Q in A^-1',SplitInto='100,100',MaxRecursionDepth='1')
mdWs1a=ConvertToMD(InputWorkspace=ws1a,QDimensions='|Q|',QConversionScales='Q in A^-1',SplitInto='100,100',MaxRecursionDepth='1')
mdWs2=ConvertToMD(InputWorkspace=ws2,QDimensions='|Q|',QConversionScales='Q in A^-1',SplitInto='100,100',MaxRecursionDepth='1')
# compare the workspaces
comp_rez1=CompareMDWorkspaces(mdWs1,mdWs1a)
comp_rez2=CompareMDWorkspaces(mdWs1,mdWs2)
# print comparison results
print("Workspaces mdWs1 and mdWs1a are equal? : {0} : Comparison result: {1}".format(comp_rez1[0], comp_rez1[1]))
print("Workspaces mdWs1 and mdWs2 are equal? : {0} : Comparison result: {1}".format(comp_rez2[0], comp_rez2[1]))
Output:
Workspaces mdWs1 and mdWs1a are equal? : True : Comparison result: Success!
Workspaces mdWs1 and mdWs2 are equal? : False : Comparison result: Box signal does not match (18360 vs 36720)
Categories: AlgorithmIndex | MDAlgorithms\Utility\Workspaces
C++ source: CompareMDWorkspaces.cpp (last modified: 2019-07-17)
C++ header: CompareMDWorkspaces.h (last modified: 2018-10-05)