Create a time-of-flight lookup table for DREAM#
This notebook shows how to create a time-of-flight lookup table for the DREAM instrument.
[1]:
import scipp as sc
from ess.reduce import time_of_flight
from ess.reduce.nexus.types import AnyRun
from ess.dream.beamline import InstrumentConfiguration, choppers
Select the choppers#
We select the choppers for the ‘high-flux’ configuration.
[2]:
disk_choppers = choppers(InstrumentConfiguration.high_flux)
Setting up the workflow#
[3]:
wf = time_of_flight.TofLookupTableWorkflow()
wf[time_of_flight.LtotalRange] = sc.scalar(60.0, unit="m"), sc.scalar(80.0, unit="m")
wf[time_of_flight.NumberOfSimulatedNeutrons] = 200_000 # Increase this number for more reliable results
wf[time_of_flight.SourcePosition] = sc.vector([0, 0, 0], unit='m')
wf[time_of_flight.DiskChoppers[AnyRun]] = disk_choppers
wf[time_of_flight.DistanceResolution] = sc.scalar(0.1, unit="m")
wf[time_of_flight.TimeResolution] = sc.scalar(250.0, unit='us')
wf[time_of_flight.LookupTableRelativeErrorThreshold] = 0.02
wf[time_of_flight.PulsePeriod] = 1.0 / sc.scalar(14.0, unit="Hz")
wf[time_of_flight.PulseStride] = 1
wf[time_of_flight.PulseStrideOffset] = None
Compute the table#
[4]:
table = wf.compute(time_of_flight.TimeOfFlightLookupTable)
table
Downloading file 'ess/ess.h5' from 'https://github.com/scipp/tof-sources/raw/refs/heads/main/1/ess/ess.h5' to '/home/runner/.cache/tof'.
[4]:
TimeOfFlightLookupTable(array=<scipp.DataArray>
Dimensions: Sizes[distance:204, event_time_offset:287, ]
Coordinates:
* distance float64 [m] (distance) [59.85, 59.95, ..., 80.05, 80.15]
* event_time_offset float64 [µs] (event_time_offset) [0, 249.75, ..., 71178.8, 71428.6]
Data:
float64 [µs] (distance, event_time_offset) [-nan, -nan, ..., 69738.6, 70025.1] [-nan, -nan, ..., 27647, 34836.2]
, pulse_period=<scipp.Variable> () float64 [µs] 71428.6, pulse_stride=1, distance_resolution=<scipp.Variable> () float64 [m] 0.1, time_resolution=<scipp.Variable> () float64 [µs] 249.75, error_threshold=0.02, choppers=DataGroup(sizes={'cutout': None}, keys=[
psc1: DataGroup(8, {'cutout': 8}),
psc2: DataGroup(8, {'cutout': 8}),
oc: DataGroup(8, {'cutout': 1}),
bcc: DataGroup(8, {'cutout': 2}),
t0: DataGroup(8, {'cutout': 1}),
]))
[5]:
table.plot()
[5]:
Save to file#
[6]:
table.save_hdf5('DREAM-high-flux-tof-lookup-table.h5')