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

CopyDetectorMapping v1

Summary

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

See Also

CopyLogs

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++ header: CopyDetectorMapping.h

C++ source: CopyDetectorMapping.cpp