CopyDetectorMapping v1

../_images/CopyDetectorMapping-v1_dlg.png

CopyDetectorMapping dialog.

Summary

Copies spectra to detector mapping from one Matrix Workspace to another.

Properties

Name Direction Type Default Description
WorkspaceToMatch Input MatrixWorkspace Mandatory  
WorkspaceToRemap InOut MatrixWorkspace Mandatory  
IndexBySpectrumNumber Input boolean False Will use mapping indexed by spectrum number rather than the default ofWorkspace Index (recommended when both workspaces have a vertical axis in spectrum number).

Description

This algorithm will copy the spectra to detector ID mapping form one workspace to the other, either on a workspace index or spectrum number basis.

Typically if both the workspace to be remapped and the workspace being matched both have their vertical axes in spectrum number then the IndexBySpectrumNumber option should be considered. With the option disabled the algorithm will copy the mapping based on the index of the spectrum in the workspace.

Both workspaces must be a Matrix Workspace with the same number of histograms.

Usage:

Example: CopyDetectorMapping on generated workspaces

# Create a sample workspace and a workspace to copy mapping to
to_match = CreateSimulationWorkspace(Instrument='IRIS',
                                     BinParams='-0.5,0.05,0.5')
to_remap = CreateSampleWorkspace(NumBanks=10, BankPixelWidth=1)

# Group the spectra in the sample workspace
grouping_ws = CreateGroupingWorkspace(InstrumentName='IRIS',
                                      FixedGroupCount=10,
                                      ComponentName='graphite')
to_match = GroupDetectors(InputWorkspace=to_match, PreserveEvents=False,
                          CopyGroupingFromWorkspace='grouping_ws')

print('Spectrum 0 detectors before copy: {}'.format(to_remap.getSpectrum(0).getDetectorIDs()))

# Copy the grouping to another workspace
CopyDetectorMapping(WorkspaceToMatch='to_match',
                    WorkspaceToRemap='to_remap',
                    IndexBySpectrumNumber=True)

print('Spectrum 0 detectors after copy: {}'.format(to_remap.getSpectrum(0).getDetectorIDs()))

Output:

Spectrum 0 detectors before copy: set(1)
Spectrum 0 detectors after copy: set(3,4,5,6,7)

Categories: AlgorithmIndex | Utility\Workspaces

Source

C++ source: CopyDetectorMapping.cpp (last modified: 2019-06-05)

C++ header: CopyDetectorMapping.h (last modified: 2018-10-05)