$$\renewcommand\AA{\unicode{x212B}}$$

## Properties¶

Name

Direction

Type

Default

Description

Instrument

Input

string

Mandatory

The name of the instrument to apply the mask.

InputFile

Input

string

Mandatory

Masking file for masking. Supported file format is XML and ISIS ASCII. Allowed extensions: [‘.xml’, ‘.msk’]

RefWorkspace

Input

MatrixWorkspace

The name of the workspace wich defines instrument and spectra, used as the source of the spectra-detector map for the mask to load. The instrument, attached to this workspace has to be the same as the one specified by ‘Instrument’ property

OutputWorkspace

Output

## Description¶

This algorithm is used to load a masking file, which can be in XML format (defined later in this page) or old-styled calibration file. The Instrument can be a IDF.

## File Format¶

### XML File Format¶

Example 1:

<?xml version="1.0" encoding="UTF-8" ?>
<group>
<detids>3,34-44,47</detids>
<component>bank123</component>
<component>bank124</component>
</group>


### ISIS File Format¶

Example 2:

1-3 62-64
65-67 126-128
129-131 190-192
193-195 254-256
257-259 318-320
321-323 382-384
385 387 446 448
... ...


All the integers in file of this format are spectrum Numbers to mask. Two spectrum Numbers with “-” in between indicate a continuous range of spectra to mask. It does not matter if there is any space between integer number and “-”. There is no restriction on how the line is structured. Be noticed that any line starting with a non-digit character, except space, will be treated as a comment line.

Supporting

* Component ID --> Detector IDs --> Workspace Indexes
* Detector ID --> Workspace Indexes
* Spectrum Number --> Workspace Indexes


When a spectra mask (ISIS) is used on multiple workspaces, the same masking is produced only if all masked workspaces have the same spectra-detector map. When mask is generated for one workspace and applied to workspace with different spectra-detector mapping, the same masking can be produced by using Workspace option, using this workspace as the source of the spectra-detector mapping. See the Spectra mask usage sample below.

## Usage¶

Note

ws = Load('HYS_11092_event.nxs')
# One can alternatively do

# Check some pixels


Output:

Is detector 0 masked: True


Example: Using reference workspace with Spectra Mask

# Load workspace with real spectra-derector mask

#

# Apply spectra mask using real workspace spectra-detector map.
# it just needs to contain the same spectra-detector map as the initial workspace
# you may want to try rows below to be sure:

# Load Mask using  instrument and spectra-detector map provided with source workspace

# Clear up rubbish
os.remove(file2remove)

# See the difference:
for ind in range(0,nhist):
try:
det = rws.getDetector(ind)
#  1:1 map generated from instrument definitions
# Real spectra-detector map:
except:
pass
print("*** ************************************ **********************************************")
print( "*** Initial workspace masking parameters **********************************************")
print("*** One to one mask workspace has masked the same spectra numbers but different detectors")
print("*** Real spectra-det-map workspace has masked different spectra numbers but the same detectors")
print("*** indeed the same:")
print("*** ************************************ **********************************************")
print("*** note spectra with id 4 is a monitor, not present in the masking workspaces")
print("*** ************************************ **********************************************")


Output:

*** ************************************ **********************************************
*** Masked Spec. Id(s):  [  4  10  11  12  13 100 110 120 130 140 200 300]
*** Initial workspace masking parameters **********************************************
Masked Spectra Numbers:  [9, 10, 11, 12, 99, 109, 119, 129, 139, 199, 299]
Masked Detector IDs   :  [4106, 4107, 4108, 4109, 4608, 4702, 4712, 4806, 4816, 2220, 2524]
*** One to one mask workspace has masked the same spectra numbers but different detectors
ws 1to1 Masked spectra:  [9, 10, 11, 12, 99, 109, 119, 129, 139, 199, 299]
ws 1to1 Masked DedIDs :  [1110, 1111, 1112, 1113, 1401, 1411, 1421, 1431, 1509, 1705, 2201]
*** Real spectra-det-map workspace has masked different spectra numbers but the same detectors
ws RSDM Masked spectra:  [318, 418, 787, 788, 789, 790, 877, 887, 897, 907, 917]
ws RSDM Masked DedIDs :  [2220, 2524, 4106, 4107, 4108, 4109, 4608, 4702, 4712, 4806, 4816]
*** indeed the same:
sorted initial DetIDs :  [2220, 2524, 4106, 4107, 4108, 4109, 4608, 4702, 4712, 4806, 4816]
sorted RSDM    DedIDs :  [2220, 2524, 4106, 4107, 4108, 4109, 4608, 4702, 4712, 4806, 4816]
*** ************************************ **********************************************
*** note spectra with id 4 is a monitor, not present in the masking workspaces
*** ************************************ **********************************************