DREAM instrument view#

This notebook is a simple example on how to use the instrument view for the DREAM instrument.

  • The DREAM-specific instrument view is capable of slicing the data with a slider widget along a dimension (e.g. tof) by using the dim argument.

  • There are also checkboxes to hide/show the different elements that make up the DREAM detectors.

[1]:
import pandas as pd
import scipp as sc
from ess import dream

Load the data#

We load a data set from a Geant4 simulation (stored as a .csv file). In each detector bank, the data is organised by wire, strip, module, segment, and counter. The end caps also have an additional sumo dimension.

[2]:
dg = dream.io.load_geant4_csv(
    dream.data.get_path('data_dream_HF_mil_closed_alldets_1e9.csv.zip')
)
dg = dg['instrument']  # Extract the instrument data

# Construct the pixel positions from event positions
for da in dg.values():
    da.coords['position'] = da.bins.coords['position'].bins.mean()

dg
Downloading file 'data_dream_HF_mil_closed_alldets_1e9.csv.zip' from 'https://public.esss.dk/groups/scipp/ess/dream/1/data_dream_HF_mil_closed_alldets_1e9.csv.zip' to '/home/runner/.cache/ess/dream/1'.
[2]:
  • mantle
    scipp
    DataArray
    (module: 14,
     segment: 6,
     counter: 2,
     wire: 32,
     strip: 256)
    DataArrayView
    binned data [len=8, len=8, ..., len=0, len=0]
  • high_resolution
    scipp
    DataArray
    (module: 9,
     segment: 8,
     counter: 2,
     wire: 16,
     strip: 32)
    DataArrayView
    binned data [len=0, len=0, ..., len=0, len=0]
  • endcap_backward
    scipp
    DataArray
    (sumo: 4,
     module: 23,
     segment: 10,
     counter: 2,
     wire: 16,
     strip: 16)
    DataArrayView
    binned data [len=17, len=9, ..., len=1, len=3]
  • endcap_forward
    scipp
    DataArray
    (sumo: 4,
     module: 23,
     segment: 10,
     counter: 2,
     wire: 16,
     strip: 16)
    DataArrayView
    binned data [len=1, len=1, ..., len=0, len=1]

Full instrument view#

We first histogram the data along the time-of-flight (tof) dimension, making sure the same bins are used for all elements:

[4]:
tof_edges = sc.linspace('tof', 1.0e7, 1.0e8, 51, unit='ns', dtype=int)
data = dg.hist(tof=tof_edges)

We now use the instrument_view function to show the 3D view of the instrument pixels, specifying that we wish to have a slider along the tof dimension:

[5]:
full_view = dream.instrument_view(data, dim='tof')
full_view
[5]:

Note that it is possible to use any dimension for the slider instead of tof, such as wavelength (if present in the data).

Displaying individual detector elements#

It is also possible to view a single detector element, selecting e.g. mantle from the original data:

[7]:
mantle_view = dream.instrument_view(dg['mantle'].hist(wavelength=50), dim='wavelength')
mantle_view
[7]:

The instrument view is designed to be flexible in terms of what it accepts as input. This means that you can easily inspect, for example, a single module by using the usual slicing notation for data arrays.

Below, we display the first module in the backward end-cap detector:

[9]:
dream.instrument_view(dg['endcap_backward']['module', 0].hist(tof=1))
[9]: