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

ExtractMask v1

../_images/ImageNotFound.png

Enable screenshots using DOCS_SCREENSHOTS in CMake

Summary

Extracts the masking from a given workspace and places it in a new workspace.

See Also

ExtractMaskToTable

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

Mandatory

A workspace whose masking is to be extracted

OutputWorkspace

Output

MatrixWorkspace

Mandatory

A workspace containing the masked spectra as zeroes and ones.

DetectorList

Output

int list

A comma separated list or array containing a list of masked detector ID’s

Description

The masking from the InputWorkspace property is extracted by creating a new MatrixWorkspace with a single X bin where:

  • 0 = masked;

  • 1 = unmasked.

The spectra containing 0 are also marked as masked and the instrument link is preserved so that the instrument view functions correctly.

A list of masked detector IDs is also output. Note this contains the detector IDs which are masked rather than the index or spectrum number.

Usage

Example

#create a workspace with a 3*3 pixel detector
bankPixelWidth = 3
ws = CreateSampleWorkspace(NumBanks=1,BankPixelWidth=bankPixelWidth)

#Mask out every other detector
MaskDetectors(ws,WorkspaceIndexList=range(0,bankPixelWidth*bankPixelWidth,2))

wsMask, maskList = ExtractMask(ws)

#This mask can then be applied to another workspace
ws2 = CreateSampleWorkspace(NumBanks=1,BankPixelWidth=bankPixelWidth)
MaskDetectors(ws2,MaskedWorkspace="wsMask")

print("Masked Detectors")
print("n ws    ws2")
for i in range (ws.getNumberHistograms()):
    print("%i %-5s %s" % (i, ws.getDetector(i).isMasked(), ws2.getDetector(i).isMasked()))

print("\nMasked detector IDs")
print(maskList)

Output:

Masked Detectors
n ws    ws2
0 True  True
1 False False
2 True  True
3 False False
4 True  True
5 False False
6 True  True
7 False False
8 True  True

Masked detector IDs
[ 9 11 13 15 17]

Categories: AlgorithmIndex | Transforms\Masking

Source

C++ header: ExtractMask.h

C++ source: ExtractMask.cpp