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

FindDetectorsOutsideLimits v1

../_images/FindDetectorsOutsideLimits-v1_dlg.png

FindDetectorsOutsideLimits dialog.

Summary

Identifies histograms and their detectors that have total numbers of counts over a user defined maximum or less than the user define minimum.

Properties

Name Direction Type Default Description
InputWorkspace Input MatrixWorkspace Mandatory Name of the input workspace2D
OutputWorkspace Output MatrixWorkspace Mandatory Each histogram from the input workspace maps to a histogram in this workspace with one value that indicates if there was a dead detector
HighThreshold Input number Optional Spectra whose total number of counts are equal to or above this value will be marked bad (default off)
LowThreshold Input number 0 Spectra whose total number of counts are equal to or below this value will be marked bad (default 0)
StartWorkspaceIndex Input number 0 The index number of the first spectrum to include in the calculation (default 0)
EndWorkspaceIndex Input number Optional The index number of the last spectrum to include in the calculation (default the last histogram)
RangeLower Input number Optional No bin with a boundary at an x value less than this will be used in the summation that decides if a detector is ‘bad’ (default: the start of each histogram)
RangeUpper Input number Optional No bin with a boundary at an x value higher than this value will be used in the summation that decides if a detector is ‘bad’ (default: the end of each histogram)
NumberOfFailures Output number    

Description

This is intended to identify detectors that are grossly over or under counting. It reads the input workspace and identifies all histograms with numbers of counts outside the user defined upper and lower limits. Each spectra that fails has its spectra masked on the output workspace. Spectra that pass the test have their data set to a positive value, 1.0. The output workspace can be fed to MaskDetectors v1 to mask the same spectra on another workspace.

ChildAlgorithms used

Uses the Integration v1 algorithm to sum the spectra.

Usage

Example:

import numpy as np
ws = CreateSampleWorkspace(BankPixelWidth=10,NumBanks=1)

#create dome dead and noisy detectors
deadDetArray=[0.0] * ws.blocksize()
noisyDetArray= [100.0] * ws.blocksize()

for i in range(0,ws.getNumberHistograms(),5):
    ws.setY(i,np.array(deadDetArray))
    ws.setY(i+1,np.array(noisyDetArray))

print("With just the default LowThreshold of 0")
(wsOut,NumberOfFailures)=FindDetectorsOutsideLimits(ws)
print("{} spectra were outside the limits.".format(NumberOfFailures))
print("")

print("With a High and LowThreshold, as well as restricting the range to consider")
(wsOut2,NumberOfFailures)=FindDetectorsOutsideLimits(ws, HighThreshold=1000,
    LowThreshold=0, RangeLower=200, RangeUpper=10000)
print("{} spectra were outside the limits.".format(NumberOfFailures))

mtd.clear()

Output:

With just the default LowThreshold of 0
20 spectra were outside the limits.

With a High and LowThreshold, as well as restricting the range to consider
40 spectra were outside the limits.

Example:

ws = CreateSimulationWorkspace('MARI','0,1,10')
nh = ws.getNumberHistograms()
for ind in range(nh):
    y = ws.dataY(ind)
    if ind>=100 and ind < 300:
        y.fill(100)
    else:
        y.fill(1)

mws1,nMasked1 = FindDetectorsOutsideLimits(ws,100)
mws2,nMasked2 = FindDetectorsOutsideLimits(ws,100,startWorkspaceIndex = 200)

print("****************************************")
print("full mask ws has {0} masked detectors".format(nMasked1))
print("part mask ws  has {0} masked detectors".format(nMasked2))
print("****************************************")
selected_spec = [99,100,199,200,299,300]
for spec in selected_spec:
    print("full mask ws Spec N{0} is masked: {1}".format(spec,mws1.readY(spec)[0]>0.5))
    print("part mask ws Spec N{0} is masked: {1}".format(spec,mws2.readY(spec)[0]>0.5) )
print("****************************************")

Output:

****************************************
full mask ws has 200 masked detectors
part mask ws  has 100 masked detectors
****************************************
full mask ws Spec N99 is masked: False
part mask ws Spec N99 is masked: False
full mask ws Spec N100 is masked: True
part mask ws Spec N100 is masked: False
full mask ws Spec N199 is masked: True
part mask ws Spec N199 is masked: False
full mask ws Spec N200 is masked: True
part mask ws Spec N200 is masked: True
full mask ws Spec N299 is masked: True
part mask ws Spec N299 is masked: True
full mask ws Spec N300 is masked: False
part mask ws Spec N300 is masked: False
****************************************

Categories: AlgorithmIndex | Diagnostics

Source

C++ header: FindDetectorsOutsideLimits.h (last modified: 2020-03-20)

C++ source: FindDetectorsOutsideLimits.cpp (last modified: 2020-04-07)