LOKI Detector Diagnostics#
This notebook contains some tools that can be used to investigate/debug the Loki detectors:
loki.diagnostics.load_detectors: a detector data loader that can be used when traditional workflows failloki.LokiBankViewer: a 2D view of all detector panels with sliders to select straw and layerplopp.inspector: allows to draw rectangles on 2D views to display spectra along a third dimensionloki.instrument_view: a 3D view of the detector panels
[1]:
import plopp as pp
import scipp as sc
from ess import loki
import ess.loki.data # noqa: F401
%matplotlib widget
Loading detector bank data#
The ‘official’ way to load loki detector data is via the LokiWorkflow.
However, this can sometimes fail if some information in the file is missing, incomplete or incorrect. When debugging detectors or instrument setup, it is useful to have a loader that does its best to load the data, using fallback methods when information is missing.
Here we load all 9 detector banks from a Loki file using the ‘fail-safe’ loki.diagnostics.load_detectors:
[2]:
file = loki.data.loki_coda_file()
data = loki.diagnostics.load_detectors(file)
data.keys()
Downloading file 'loki-coda-5-pulses.hdf' from 'https://public.esss.dk/groups/scipp/ess/loki/3/loki-coda-5-pulses.hdf' to '/home/runner/.cache/ess/loki'.
[2]:
dict_keys(['loki_detector_0', 'loki_detector_1', 'loki_detector_2', 'loki_detector_3', 'loki_detector_4', 'loki_detector_5', 'loki_detector_6', 'loki_detector_7', 'loki_detector_8'])
Note that the equivalent loki.diagnostics.load_monitors also exists.
The LokiBankViewer#
[3]:
viewer = loki.LokiBankViewer(data.hist())
[5]:
viewer
[5]:
Time dimension inspector#
We can use the inspector tool (from Plopp) to draw rectangles on detector banks and display a time (event_time_offset) spectrum in a second panel.
We first have to histogram the data in the event_time_offset dimension.
[6]:
time_bins = sc.linspace(
'event_time_offset',
start=0.0,
stop=1.0 / 14.0,
num=201,
unit='s',
).to(unit='ns')
dhist = data.hist(event_time_offset=time_bins)
The inspector plot accepts 3D data, so we sum over the layer and straw dimensions.
[7]:
da = dhist['loki_detector_0'].sum(['layer', 'straw'])
p = pp.inspector(da, dim='event_time_offset', orientation='vertical', mode='rectangle', cmax=5)
[8]:
tool = p.children[0].toolbar['inspect']
tool.value = True
tool._tool.click(27, 20)
tool._tool.click(141, 40)
tool._tool.click(252, 35)
tool._tool.click(412, 42)
[9]:
p
[9]:
The instrument view#
The instrument_view will display a 3D rendering of the detector pixels, along with a slider to select slices in the event_time_offset dimension.
[11]:
loki.instrument_view(dhist, dim='event_time_offset')
[11]: