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.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] = 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
[4]:
scipp.DataArray (921.04 KB)
- distance: 204
- event_time_offset: 287
- distance(distance)float64m59.85, 59.95, ..., 80.050, 80.150
Values:
array([59.85, 59.95, 60.05, 60.15, 60.25, 60.35, 60.45, 60.55, 60.65, 60.75, 60.85, 60.95, 61.05, 61.15, 61.25, 61.35, 61.45, 61.55, 61.65, 61.75, 61.85, 61.95, 62.05, 62.15, 62.25, 62.35, 62.45, 62.55, 62.65, 62.75, 62.85, 62.95, 63.05, 63.15, 63.25, 63.35, 63.45, 63.55, 63.65, 63.75, 63.85, 63.95, 64.05, 64.15, 64.25, 64.35, 64.45, 64.55, 64.65, 64.75, 64.85, 64.95, 65.05, 65.15, 65.25, 65.35, 65.45, 65.55, 65.65, 65.75, 65.85, 65.95, 66.05, 66.15, 66.25, 66.35, 66.45, 66.55, 66.65, 66.75, 66.85, 66.95, 67.05, 67.15, 67.25, 67.35, 67.45, 67.55, 67.65, 67.75, 67.85, 67.95, 68.05, 68.15, 68.25, 68.35, 68.45, 68.55, 68.65, 68.75, 68.85, 68.95, 69.05, 69.15, 69.25, 69.35, 69.45, 69.55, 69.65, 69.75, 69.85, 69.95, 70.05, 70.15, 70.25, 70.35, 70.45, 70.55, 70.65, 70.75, 70.85, 70.95, 71.05, 71.15, 71.25, 71.35, 71.45, 71.55, 71.65, 71.75, 71.85, 71.95, 72.05, 72.15, 72.25, 72.35, 72.45, 72.55, 72.65, 72.75, 72.85, 72.95, 73.05, 73.15, 73.25, 73.35, 73.45, 73.55, 73.65, 73.75, 73.85, 73.95, 74.05, 74.15, 74.25, 74.35, 74.45, 74.55, 74.65, 74.75, 74.85, 74.95, 75.05, 75.15, 75.25, 75.35, 75.45, 75.55, 75.65, 75.75, 75.85, 75.95, 76.05, 76.15, 76.25, 76.35, 76.45, 76.55, 76.65, 76.75, 76.85, 76.95, 77.05, 77.15, 77.25, 77.35, 77.45, 77.55, 77.65, 77.75, 77.85, 77.95, 78.05, 78.15, 78.25, 78.35, 78.45, 78.55, 78.65, 78.75, 78.85, 78.95, 79.05, 79.15, 79.25, 79.35, 79.45, 79.55, 79.65, 79.75, 79.85, 79.95, 80.05, 80.15]) - distance_resolution()float64m0.10000000000000142
Values:
array(0.1) - error_threshold()float64𝟙0.02
Values:
array(0.02) - event_time_offset(event_time_offset)float64µs0.0, 249.750, ..., 7.118e+04, 7.143e+04
Values:
array([ 0. , 249.75024975, 499.5004995 , 749.25074925, 999.000999 , 1248.75124875, 1498.5014985 , 1748.25174825, 1998.001998 , 2247.75224775, 2497.5024975 , 2747.25274725, 2997.002997 , 3246.75324675, 3496.5034965 , 3746.25374625, 3996.003996 , 4245.75424575, 4495.5044955 , 4745.25474525, 4995.004995 , 5244.75524476, 5494.50549451, 5744.25574426, 5994.00599401, 6243.75624376, 6493.50649351, 6743.25674326, 6993.00699301, 7242.75724276, 7492.50749251, 7742.25774226, 7992.00799201, 8241.75824176, 8491.50849151, 8741.25874126, 8991.00899101, 9240.75924076, 9490.50949051, 9740.25974026, 9990.00999001, 10239.76023976, 10489.51048951, 10739.26073926, 10989.01098901, 11238.76123876, 11488.51148851, 11738.26173826, 11988.01198801, 12237.76223776, 12487.51248751, 12737.26273726, 12987.01298701, 13236.76323676, 13486.51348651, 13736.26373626, 13986.01398601, 14235.76423576, 14485.51448551, 14735.26473526, 14985.01498501, 15234.76523477, 15484.51548452, 15734.26573427, 15984.01598402, 16233.76623377, 16483.51648352, 16733.26673327, 16983.01698302, 17232.76723277, 17482.51748252, 17732.26773227, 17982.01798202, 18231.76823177, 18481.51848152, 18731.26873127, 18981.01898102, 19230.76923077, 19480.51948052, 19730.26973027, 19980.01998002, 20229.77022977, 20479.52047952, 20729.27072927, 20979.02097902, 21228.77122877, 21478.52147852, 21728.27172827, 21978.02197802, 22227.77222777, 22477.52247752, 22727.27272727, 22977.02297702, 23226.77322677, 23476.52347652, 23726.27372627, 23976.02397602, 24225.77422577, 24475.52447552, 24725.27472527, 24975.02497502, 25224.77522478, 25474.52547453, 25724.27572428, 25974.02597403, 26223.77622378, 26473.52647353, 26723.27672328, 26973.02697303, 27222.77722278, 27472.52747253, 27722.27772228, 27972.02797203, 28221.77822178, 28471.52847153, 28721.27872128, 28971.02897103, 29220.77922078, 29470.52947053, 29720.27972028, 29970.02997003, 30219.78021978, 30469.53046953, 30719.28071928, 30969.03096903, 31218.78121878, 31468.53146853, 31718.28171828, 31968.03196803, 32217.78221778, 32467.53246753, 32717.28271728, 32967.03296703, 33216.78321678, 33466.53346653, 33716.28371628, 33966.03396603, 34215.78421578, 34465.53446553, 34715.28471528, 34965.03496503, 35214.78521479, 35464.53546454, 35714.28571429, 35964.03596404, 36213.78621379, 36463.53646354, 36713.28671329, 36963.03696304, 37212.78721279, 37462.53746254, 37712.28771229, 37962.03796204, 38211.78821179, 38461.53846154, 38711.28871129, 38961.03896104, 39210.78921079, 39460.53946054, 39710.28971029, 39960.03996004, 40209.79020979, 40459.54045954, 40709.29070929, 40959.04095904, 41208.79120879, 41458.54145854, 41708.29170829, 41958.04195804, 42207.79220779, 42457.54245754, 42707.29270729, 42957.04295704, 43206.79320679, 43456.54345654, 43706.29370629, 43956.04395604, 44205.79420579, 44455.54445554, 44705.29470529, 44955.04495504, 45204.7952048 , 45454.54545455, 45704.2957043 , 45954.04595405, 46203.7962038 , 46453.54645355, 46703.2967033 , 46953.04695305, 47202.7972028 , 47452.54745255, 47702.2977023 , 47952.04795205, 48201.7982018 , 48451.54845155, 48701.2987013 , 48951.04895105, 49200.7992008 , 49450.54945055, 49700.2997003 , 49950.04995005, 50199.8001998 , 50449.55044955, 50699.3006993 , 50949.05094905, 51198.8011988 , 51448.55144855, 51698.3016983 , 51948.05194805, 52197.8021978 , 52447.55244755, 52697.3026973 , 52947.05294705, 53196.8031968 , 53446.55344655, 53696.3036963 , 53946.05394605, 54195.8041958 , 54445.55444555, 54695.3046953 , 54945.05494505, 55194.80519481, 55444.55544456, 55694.30569431, 55944.05594406, 56193.80619381, 56443.55644356, 56693.30669331, 56943.05694306, 57192.80719281, 57442.55744256, 57692.30769231, 57942.05794206, 58191.80819181, 58441.55844156, 58691.30869131, 58941.05894106, 59190.80919081, 59440.55944056, 59690.30969031, 59940.05994006, 60189.81018981, 60439.56043956, 60689.31068931, 60939.06093906, 61188.81118881, 61438.56143856, 61688.31168831, 61938.06193806, 62187.81218781, 62437.56243756, 62687.31268731, 62937.06293706, 63186.81318681, 63436.56343656, 63686.31368631, 63936.06393606, 64185.81418581, 64435.56443556, 64685.31468531, 64935.06493506, 65184.81518482, 65434.56543457, 65684.31568432, 65934.06593407, 66183.81618382, 66433.56643357, 66683.31668332, 66933.06693307, 67182.81718282, 67432.56743257, 67682.31768232, 67932.06793207, 68181.81818182, 68431.56843157, 68681.31868132, 68931.06893107, 69180.81918082, 69430.56943057, 69680.31968032, 69930.06993007, 70179.82017982, 70429.57042957, 70679.32067932, 70929.07092907, 71178.82117882, 71428.57142857]) - pulse_period()float64µs71428.57142857142
Values:
array(71428.57142857) - pulse_stride()int641
Values:
array(1) - time_resolution()float64µs249.7502497502497
Values:
array(249.75024975)
- (distance, event_time_offset)float64µsnan, nan, ..., 6.975e+04, 7.002e+04σ = nan, nan, ..., 206.499, 180.395
Values:
array([[ nan, nan, nan, ..., nan, nan, nan], [ nan, nan, nan, ..., nan, nan, nan], [ nan, nan, nan, ..., nan, nan, nan], ..., [70009.20286516, 70313.87842294, 70569.95741317, ..., 69489.90287304, 69781.39514441, 70009.20286516], [70011.62386551, 70308.75716885, 70550.36091072, ..., 69469.76636845, 69784.53347276, 70011.62386551], [70016.91880707, 70281.58220837, 70528.09218571, ..., 69487.42744838, 69749.28125898, 70016.91880707]], shape=(204, 287))
Variances (σ²):
array([[ nan, nan, nan, ..., nan, nan, nan], [ nan, nan, nan, ..., nan, nan, nan], [ nan, nan, nan, ..., nan, nan, nan], ..., [32086.15833881, 28931.59936597, 34879.95248697, ..., 41964.37008744, 25873.51651456, 32086.15833881], [35256.65205708, 35110.26889642, 33830.23977112, ..., 35514.28297794, 36059.18608987, 35256.65205708], [32542.43968036, 35834.79016416, 28934.63079971, ..., 34425.33833899, 42641.82165578, 32542.43968036]], shape=(204, 287))
[5]:
table.plot()
[5]:
Save to file#
[6]:
# Save chopper metadata
# TODO: storing the choppers as a PyObject is skipped when saving to disk
table.coords['choppers'] = sc.scalar(disk_choppers)
# Write to file
table.save_hdf5('DREAM-high-flux-tof-lookup-table.h5')
Writing with dtype=PyObject not implemented, skipping.