Table of Contents
Name | Direction | Type | Default | Description |
---|---|---|---|---|
InputWorkspace | Input | MatrixWorkspace | Mandatory | A ‘raw’ workspace from DirectILLCollectData to calculate the diagnostics from. |
OutputWorkspace | Output | Workspace | Mandatory | A diagnostics mask workspace. |
Cleanup | Input | string | Cleanup ON | What to do with intermediate workspaces. Allowed values: [‘Cleanup ON’, ‘Cleanup OFF’] |
SubalgorithmLogging | Input | string | Logging OFF | Enable or disable subalgorithms to print in the logs. Allowed values: [‘Logging OFF’, ‘Logging ON’] |
EPPWorkspace | Input | TableWorkspace | Table workspace containing results from the FindEPP algorithm. | |
ElasticPeakDiagnostics | Input | string | Peak Diagnostics AUTO | Enable or disable elastic peak diagnostics. Allowed values: [‘Peak Diagnostics AUTO’, ‘Peak Diagnostics ON’, ‘Peak Diagnostics OFF’] |
ElasticPeakWidthInSigmas | Input | number | 3 | Integration width of the elastic peak in multiples of ‘Sigma’ in the EPP table. |
ElasticPeakLowThreshold | Input | number | 0.1 | Multiplier for lower acceptance limit used in elastic peak diagnostics. |
ElasticPeakHighThreshold | Input | number | 3 | Multiplier for higher acceptance limit used in elastic peak diagnostics. |
ElasticPeakErrorThreshold | Input | number | 3.3 | To fail the elastic peak diagnostics, the intensity must also exceed this number of error bars with respect to the median intensity. |
BkgDiagnostics | Input | string | Bkg Diagnostics AUTO | Control the background diagnostics. Allowed values: [‘Bkg Diagnostics AUTO’, ‘Bkg Diagnostics ON’, ‘Bkg Diagnostics OFF’] |
NonBkgRegionInSigmas | Input | number | 10 | Width of the range excluded from background integration around the elastic peaks in multiplies of ‘Sigma’ in the EPP table |
NoisyBkgLowThreshold | Input | number | 0.1 | Multiplier for lower acceptance limit used in noisy background diagnostics. |
NoisyBkgHighThreshold | Input | number | 3.3 | Multiplier for higher acceptance limit used in noisy background diagnostics. |
NoisyBkgErrorThreshold | Input | number | 3.3 | To fail the background diagnostics, the background level must also exceed this number of error bars with respect to the median level. |
BeamStopDiagnostics | Input | string | Beam Stop Diagnostics AUTO | Control the beam stop diagnostics. Allowed values: [‘Beam Stop Diagnostics AUTO’, ‘Beam Stop Diagnostics ON’, ‘Beam Stop Diagnostics OFF’] |
BeamStopThreshold | Input | number | 0.67 | Multiplier for the lower acceptance limit for beam stop diagnostics. |
DefaultMask | Input | string | Default Mask ON | Enable or disable instrument specific default mask. Allowed values: [‘Default Mask ON’, ‘Default Mask OFF’] |
MaskedDetectors | Input | int list | List of spectra to mask. | |
MaskedComponents | Input | str list | List of instrument components to mask. | |
OutputReportWorkspace | Output | TableWorkspace | Output table workspace for detector diagnostics reporting. | |
OutputReport | Output | string | Diagnostics report as a string. |
This algorithm performs detector diagnostics and masking. It is part of ILL’s direct geometry data reduction suite. The diagnostics are calculated using the counts from InputWorkspace which is preferably the raw workspace provided by the OutputRawWorkspace property of DirectILLCollectData. The output is a special mask workspace which can be further fed to DirectILLReduction to mask the detectors diagnosed as bad. Optionally, an instrument specific default mask, a beam stop mask and/or a user specified hard mask given by MaskedDetectors or MaskedComponents can be added to the diagnostics mask.
A workflow diagram for the diagnostics is shown below:
The algorithm performs two tests for each spectrum in InputWorkspace: elastic peak diagnostics and flat background diagnostics. Basically both tests calculate the median of the test values over all spectra, then compare the individual values to the median. For more detailed information, see MedianDetectorTest.
The EPP table given in EPPWorkspace and the value of ElasticPeakWidthInSigmas are used to integrate the spectra around the elastic peaks, giving the elastic intensities. The intensities are further normalised by the opening solid angles of the detectors, given by SolidAngle before the actual diagnostics.
Similarly to elastic peak diagnostics, EPPWorkspace and NonBgkRegionInSigmas are used to integrate the time-independent background regions of InputWorkspace. NonBkgRegionInSigmas is a factor applied to the ‘Sigma’ column in EPPWorkspace and this interval around the elastic peak positions is excluded from the integration. No opening angle corrections are applied to the background diagnostics.
The shadow cast on the detectors by a beam stop can be masked by the diagnostics, as well. This functionality is automatically enabled when ‘beam_stop_diagnostics_spectra’ instrument parameter is defined and can be disabled by BeamStopDiagnostics. The algorithm tries to mask a continuous region within the spectra listed in ‘beam_stop_diagnostics_spectra’. The BeamStopThreshold property can be used to fine-tune the operation.
The ‘beam_stop_diagnostics_spectra’ instrument parameter lists ranges of spectrum numbers. Each range should cover a region of a physical detector tube, part of which is behind the beam stop.
The masking procedure proceeds as follows:
The default mask file is defined by the ‘Workflow.MaskFile’ instrument parameter.
Currently, there is a default mask available for ILL’s IN5 instrument which masks 8 pixels at both ends of every detector tube.
The optional OutputReportWorkspace property returns a table workspace summarizing the diagnostics. The table has six columns:
The columns can be plotted to get an overview of the diagnostics.
Additionally, a string listing the masked and diagnosed detectors can be accessed via the OutputReport property.
The following settings are used when the AUTO keyword is encountered:
Property | IN4 | IN5 | IN6 | Ohters |
---|---|---|---|---|
ElasticPeakDiagnostics | Peak Diagnostics ON | Peak Diagnostics OFF | Peak Diagnostics ON | Peak Diagnostics ON |
BkgDiagnostics | Bkg Diagnostics ON | Bkg Diagnostics OFF | Bkg Diagnostics ON | Bkg Diagnostics ON |
BeamStopDiagnostics | Beam Stop Diagnostics OFF | Beam Stop Diagnostics ON | Beam Stop Diagnostics OFF | Beam Stop Diagnostics OFF |
Example - Diagnostics on fake IN4 workspace
import numpy
import scipy.stats
# Create a fake IN4 workspace.
# We need an instrument and a template first.
empty_IN4 = LoadEmptyInstrument(InstrumentName='IN4')
nHist = empty_IN4.getNumberHistograms()
# Make TOF bin edges.
xs = numpy.arange(530.0, 2420.0, 4.0)
# Make some Gaussian spectra.
ys = 1000.0 * scipy.stats.norm.pdf(xs[:-1], loc=970, scale=60)
# Repeat data for each histogram.
xs = numpy.tile(xs, nHist)
ys = numpy.tile(ys, nHist)
ws = CreateWorkspace(
DataX=xs,
DataY=ys,
NSpec=nHist,
UnitX='TOF',
ParentWorkspace=empty_IN4
)
# Set some histograms to zero to see if the diagnostics can catch them.
ys = ws.dataY(13)
ys *= 0.0
ys = ws.dataY(101)
ys *= 0.0
# Manually correct monitor spectrum number as LoadEmptyInstrument does
# not know about such details.
SetInstrumentParameter(
Workspace=ws,
ParameterName='default-incident-monitor-spectrum',
ParameterType='Number',
Value=str(1)
)
# Add incident energy information to sample logs.
AddSampleLog(
Workspace=ws,
LogName='Ei',
LogText=str(57),
LogType='Number',
LogUnit='meV',
NumberType='Double'
)
# Elastic channel information is missing in the sample logs.
# It can be given as single valued workspace, as well.
elasticChannelWS = CreateSingleValuedWorkspace(107)
DirectILLCollectData(
InputWorkspace=ws,
OutputWorkspace='preprocessed',
ElasticChannelWorkspace=elasticChannelWS,
IncidentEnergyCalibration='Energy Calibration OFF', # Normally we would do this for IN4.
OutputEPPWorkspace='epps' # Needed for the diagnostics.
)
diagnostics = DirectILLDiagnostics(
InputWorkspace='preprocessed',
OutputWorkspace='diagnosed',
EPPWorkspace='epps',
NoisyBkgLowThreshold=0.01,
OutputReportWorkspace='diagnostics_report'
)
print(diagnostics.OutputReport)
print('Some small-angle detectors got diagnosed as bad due to detector solid angle corrections.')
report = mtd['diagnostics_report']
I0 = report.cell('ElasticIntensity', 0)
I304 = report.cell('ElasticIntensity', 303)
print('Solid-angle corrected elastic intensity of spectrum 1: {:.8}'.format(I0))
print('vs. corrected intensity of spectrum 304: {:.8}'.format(I304))
Output:
Spectra masked by default mask file:
None
Spectra masked by user:
None
Spectra masked by beam stop diagnostics:
None
Spectra marked as bad by elastic peak diagnostics:
14, 102, 302-305, 314-317, 326-329, 338-341, 350-353, 362-365, 374-377, 386-389
Spectra marked as bad by flat background diagnostics:
14, 102
Some small-angle detectors got diagnosed as bad due to detector solid angle corrections.
Solid-angle corrected elastic intensity of spectrum 1: 555524.7
vs. corrected intensity of spectrum 304: 1795774.9
Categories: Algorithms | ILL\Direct | Inelastic\Reduction | Workflow\Inelastic
Python: DirectILLDiagnostics.py (last modified: 2018-02-26)