BIFROST reduction of simulated data#

This notebook demonstrates the basic data reduction workflow for BIFROST. It uses data that was simulated with McStas and a dedicated workflow that can process McStas data.

[1]:
import numpy as np
import scipp as sc
import sciline

from ess import bifrost
from ess.bifrost.data import (
    simulated_elastic_incoherent_with_phonon,
    lookup_table_simulation
)
from ess.spectroscopy.types import *

Construct the workflow which is a sciline.Pipeline and encodes the entire reduction procedure. We need to provide a couple of parameters so we can run the workflow:

[2]:
workflow = bifrost.BifrostSimulationWorkflow()
# Set the input file name:
workflow[Filename[SampleRun]] = simulated_elastic_incoherent_with_phonon()
# Set the lookup table for frame unwrapping:
workflow[LookupTableFilename] = lookup_table_simulation()
# Set thresholds to mask wavelength regions with large uncertainties.
# For this example, we do not mask anything:
workflow[LookupTableRelativeErrorThreshold] = {
    'detector': np.inf,
    'normalization_monitor': np.inf,
}
# We need to read many objects from the file,
# keeping it open improves performance: (optional)
workflow[PreopenNeXusFile] = PreopenNeXusFile(True)
# We drop uncertainties where they would otherwise lead to correlations:
workflow[UncertaintyBroadcastMode] = UncertaintyBroadcastMode.drop

Next, draw the workflow as a graph to inspect the steps it will take to reduce the data.

Note the groups where entries are labeled with (triplet). (These labels will be (dim_0) if you don’t have Pandas installed.) These groups indicate functions that are applied separately to each detector triplet.

[3]:
workflow.visualize(EnergyQDetector[SampleRun], compact=True, graph_attr={"rankdir": "LR"})
[3]:
../../_images/user-guide_bifrost_bifrost-reduction_5_0.svg

We are ready to compute the reduced data. We use the naive scheduler of sciline because it tends to perform better for BIFROST than the Dask scheduler. But this is optional.

[4]:
scheduler = sciline.scheduler.NaiveScheduler()
data = workflow.compute(EnergyQDetector[SampleRun], scheduler=scheduler)

The result contains coordinates for the sample table and detector rotation angles a3 and a4, respectively. It also contains event coordinates for energy_transfer and two momentum transfers, one in the lab frame and one in the sample table frame.

[5]:
data
[5]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (191.18 MB)
    • arc: 5
    • channel: 9
    • tube: 3
    • length: 100
    • a4: 2
    • a3: 180
    • L1
      ()
      float64
      m
      161.99882399465903
      Values:
      array(161.99882399)
    • Ltotal
      ()
      float64
      m
      161.99882399465903
      Values:
      array(161.99882399)
    • a3
      (a3)
      float32
      deg
      0.0, 1.0, ..., 178.0, 179.0
      Values:
      array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36., 37., 38., 39., 40., 41., 42., 43., 44., 45., 46., 47., 48., 49., 50., 51., 52., 53., 54., 55., 56., 57., 58., 59., 60., 61., 62., 63., 64., 65., 66., 67., 68., 69., 70., 71., 72., 73., 74., 75., 76., 77., 78., 79., 80., 81., 82., 83., 84., 85., 86., 87., 88., 89., 90., 91., 92., 93., 94., 95., 96., 97., 98., 99., 100., 101., 102., 103., 104., 105., 106., 107., 108., 109., 110., 111., 112., 113., 114., 115., 116., 117., 118., 119., 120., 121., 122., 123., 124., 125., 126., 127., 128., 129., 130., 131., 132., 133., 134., 135., 136., 137., 138., 139., 140., 141., 142., 143., 144., 145., 146., 147., 148., 149., 150., 151., 152., 153., 154., 155., 156., 157., 158., 159., 160., 161., 162., 163., 164., 165., 166., 167., 168., 169., 170., 171., 172., 173., 174., 175., 176., 177., 178., 179.], dtype=float32)
    • a4
      (a4)
      float32
      deg
      90.0, 95.0
      Values:
      array([90., 95.], dtype=float32)
    • arc
      (arc, channel)
      int64
      0, 0, ..., 4, 4
      Values:
      array([[0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4]])
    • channel
      (arc, channel)
      int64
      0, 1, ..., 7, 8
      Values:
      array([[0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8]])
    • detector_number
      (arc, channel, tube, length)
      int64
      1, 2, ..., 13499, 13500
      Values:
      array([[[[ 1, 2, 3, ..., 98, 99, 100], [ 901, 902, 903, ..., 998, 999, 1000], [ 1801, 1802, 1803, ..., 1898, 1899, 1900]], [[ 101, 102, 103, ..., 198, 199, 200], [ 1001, 1002, 1003, ..., 1098, 1099, 1100], [ 1901, 1902, 1903, ..., 1998, 1999, 2000]], [[ 201, 202, 203, ..., 298, 299, 300], [ 1101, 1102, 1103, ..., 1198, 1199, 1200], [ 2001, 2002, 2003, ..., 2098, 2099, 2100]], ..., [[ 601, 602, 603, ..., 698, 699, 700], [ 1501, 1502, 1503, ..., 1598, 1599, 1600], [ 2401, 2402, 2403, ..., 2498, 2499, 2500]], [[ 701, 702, 703, ..., 798, 799, 800], [ 1601, 1602, 1603, ..., 1698, 1699, 1700], [ 2501, 2502, 2503, ..., 2598, 2599, 2600]], [[ 801, 802, 803, ..., 898, 899, 900], [ 1701, 1702, 1703, ..., 1798, 1799, 1800], [ 2601, 2602, 2603, ..., 2698, 2699, 2700]]], [[[ 2701, 2702, 2703, ..., 2798, 2799, 2800], [ 3601, 3602, 3603, ..., 3698, 3699, 3700], [ 4501, 4502, 4503, ..., 4598, 4599, 4600]], [[ 2801, 2802, 2803, ..., 2898, 2899, 2900], [ 3701, 3702, 3703, ..., 3798, 3799, 3800], [ 4601, 4602, 4603, ..., 4698, 4699, 4700]], [[ 2901, 2902, 2903, ..., 2998, 2999, 3000], [ 3801, 3802, 3803, ..., 3898, 3899, 3900], [ 4701, 4702, 4703, ..., 4798, 4799, 4800]], ..., [[ 3301, 3302, 3303, ..., 3398, 3399, 3400], [ 4201, 4202, 4203, ..., 4298, 4299, 4300], [ 5101, 5102, 5103, ..., 5198, 5199, 5200]], [[ 3401, 3402, 3403, ..., 3498, 3499, 3500], [ 4301, 4302, 4303, ..., 4398, 4399, 4400], [ 5201, 5202, 5203, ..., 5298, 5299, 5300]], [[ 3501, 3502, 3503, ..., 3598, 3599, 3600], [ 4401, 4402, 4403, ..., 4498, 4499, 4500], [ 5301, 5302, 5303, ..., 5398, 5399, 5400]]], [[[ 5401, 5402, 5403, ..., 5498, 5499, 5500], [ 6301, 6302, 6303, ..., 6398, 6399, 6400], [ 7201, 7202, 7203, ..., 7298, 7299, 7300]], [[ 5501, 5502, 5503, ..., 5598, 5599, 5600], [ 6401, 6402, 6403, ..., 6498, 6499, 6500], [ 7301, 7302, 7303, ..., 7398, 7399, 7400]], [[ 5601, 5602, 5603, ..., 5698, 5699, 5700], [ 6501, 6502, 6503, ..., 6598, 6599, 6600], [ 7401, 7402, 7403, ..., 7498, 7499, 7500]], ..., [[ 6001, 6002, 6003, ..., 6098, 6099, 6100], [ 6901, 6902, 6903, ..., 6998, 6999, 7000], [ 7801, 7802, 7803, ..., 7898, 7899, 7900]], [[ 6101, 6102, 6103, ..., 6198, 6199, 6200], [ 7001, 7002, 7003, ..., 7098, 7099, 7100], [ 7901, 7902, 7903, ..., 7998, 7999, 8000]], [[ 6201, 6202, 6203, ..., 6298, 6299, 6300], [ 7101, 7102, 7103, ..., 7198, 7199, 7200], [ 8001, 8002, 8003, ..., 8098, 8099, 8100]]], [[[ 8101, 8102, 8103, ..., 8198, 8199, 8200], [ 9001, 9002, 9003, ..., 9098, 9099, 9100], [ 9901, 9902, 9903, ..., 9998, 9999, 10000]], [[ 8201, 8202, 8203, ..., 8298, 8299, 8300], [ 9101, 9102, 9103, ..., 9198, 9199, 9200], [10001, 10002, 10003, ..., 10098, 10099, 10100]], [[ 8301, 8302, 8303, ..., 8398, 8399, 8400], [ 9201, 9202, 9203, ..., 9298, 9299, 9300], [10101, 10102, 10103, ..., 10198, 10199, 10200]], ..., [[ 8701, 8702, 8703, ..., 8798, 8799, 8800], [ 9601, 9602, 9603, ..., 9698, 9699, 9700], [10501, 10502, 10503, ..., 10598, 10599, 10600]], [[ 8801, 8802, 8803, ..., 8898, 8899, 8900], [ 9701, 9702, 9703, ..., 9798, 9799, 9800], [10601, 10602, 10603, ..., 10698, 10699, 10700]], [[ 8901, 8902, 8903, ..., 8998, 8999, 9000], [ 9801, 9802, 9803, ..., 9898, 9899, 9900], [10701, 10702, 10703, ..., 10798, 10799, 10800]]], [[[10801, 10802, 10803, ..., 10898, 10899, 10900], [11701, 11702, 11703, ..., 11798, 11799, 11800], [12601, 12602, 12603, ..., 12698, 12699, 12700]], [[10901, 10902, 10903, ..., 10998, 10999, 11000], [11801, 11802, 11803, ..., 11898, 11899, 11900], [12701, 12702, 12703, ..., 12798, 12799, 12800]], [[11001, 11002, 11003, ..., 11098, 11099, 11100], [11901, 11902, 11903, ..., 11998, 11999, 12000], [12801, 12802, 12803, ..., 12898, 12899, 12900]], ..., [[11401, 11402, 11403, ..., 11498, 11499, 11500], [12301, 12302, 12303, ..., 12398, 12399, 12400], [13201, 13202, 13203, ..., 13298, 13299, 13300]], [[11501, 11502, 11503, ..., 11598, 11599, 11600], [12401, 12402, 12403, ..., 12498, 12499, 12500], [13301, 13302, 13303, ..., 13398, 13399, 13400]], [[11601, 11602, 11603, ..., 11698, 11699, 11700], [12501, 12502, 12503, ..., 12598, 12599, 12600], [13401, 13402, 13403, ..., 13498, 13499, 13500]]]], shape=(5, 9, 3, 100))
    • secondary_flight_time
      (arc, channel, a4, tube, length)
      float64
      ms
      3.198, 3.198, ..., 3.379, 3.379
      Values:
      array([[[[[3.19800155, 3.19800155, 3.19800155, ..., 3.19800155, 3.19800155, 3.19800155], [3.18487009, 3.18487009, 3.18487009, ..., 3.18487009, 3.18487009, 3.18487009], [3.17185761, 3.17185761, 3.17185761, ..., 3.17185761, 3.17185761, 3.17185761]], [[3.19800155, 3.19800155, 3.19800155, ..., 3.19800155, 3.19800155, 3.19800155], [3.18487009, 3.18487009, 3.18487009, ..., 3.18487009, 3.18487009, 3.18487009], [3.17185761, 3.17185761, 3.17185761, ..., 3.17185761, 3.17185761, 3.17185761]]], [[[3.32234051, 3.32234051, 3.32234051, ..., 3.32234051, 3.32234051, 3.32234051], [3.30870296, 3.30870296, 3.30870296, ..., 3.30870296, 3.30870296, 3.30870296], [3.29518009, 3.29518009, 3.29518009, ..., 3.29518009, 3.29518009, 3.29518009]], [[3.32234051, 3.32234051, 3.32234051, ..., 3.32234051, 3.32234051, 3.32234051], [3.30870296, 3.30870296, 3.30870296, ..., 3.30870296, 3.30870296, 3.30870296], [3.29518009, 3.29518009, 3.29518009, ..., 3.29518009, 3.29518009, 3.29518009]]], [[[3.44388534, 3.44388534, 3.44388534, ..., 3.44388534, 3.44388534, 3.44388534], [3.42975307, 3.42975307, 3.42975307, ..., 3.42975307, 3.42975307, 3.42975307], [3.41573128, 3.41573128, 3.41573128, ..., 3.41573128, 3.41573128, 3.41573128]], [[3.44388534, 3.44388534, 3.44388534, ..., 3.44388534, 3.44388534, 3.44388534], [3.42975307, 3.42975307, 3.42975307, ..., 3.42975307, 3.42975307, 3.42975307], [3.41573128, 3.41573128, 3.41573128, ..., 3.41573128, 3.41573128, 3.41573128]]], ..., [[[3.19800155, 3.19800155, 3.19800155, ..., 3.19800155, 3.19800155, 3.19800155], [3.18487009, 3.18487009, 3.18487009, ..., 3.18487009, 3.18487009, 3.18487009], [3.17185761, 3.17185761, 3.17185761, ..., 3.17185761, 3.17185761, 3.17185761]], [[3.19800155, 3.19800155, 3.19800155, ..., 3.19800155, 3.19800155, 3.19800155], [3.18487009, 3.18487009, 3.18487009, ..., 3.18487009, 3.18487009, 3.18487009], [3.17185761, 3.17185761, 3.17185761, ..., 3.17185761, 3.17185761, 3.17185761]]], [[[3.32234051, 3.32234051, 3.32234051, ..., 3.32234051, 3.32234051, 3.32234051], [3.30870296, 3.30870296, 3.30870296, ..., 3.30870296, 3.30870296, 3.30870296], [3.29518009, 3.29518009, 3.29518009, ..., 3.29518009, 3.29518009, 3.29518009]], [[3.32234051, 3.32234051, 3.32234051, ..., 3.32234051, 3.32234051, 3.32234051], [3.30870296, 3.30870296, 3.30870296, ..., 3.30870296, 3.30870296, 3.30870296], [3.29518009, 3.29518009, 3.29518009, ..., 3.29518009, 3.29518009, 3.29518009]]], [[[3.44388534, 3.44388534, 3.44388534, ..., 3.44388534, 3.44388534, 3.44388534], [3.42975307, 3.42975307, 3.42975307, ..., 3.42975307, 3.42975307, 3.42975307], [3.41573128, 3.41573128, 3.41573128, ..., 3.41573128, 3.41573128, 3.41573128]], [[3.44388534, 3.44388534, 3.44388534, ..., 3.44388534, 3.44388534, 3.44388534], [3.42975307, 3.42975307, 3.42975307, ..., 3.42975307, 3.42975307, 3.42975307], [3.41573128, 3.41573128, 3.41573128, ..., 3.41573128, 3.41573128, 3.41573128]]]], [[[[3.27937469, 3.27937469, 3.27937469, ..., 3.27937469, 3.27937469, 3.27937469], [3.26417712, 3.26417712, 3.26417712, ..., 3.26417712, 3.26417712, 3.26417712], [3.24907754, 3.24907754, 3.24907754, ..., 3.24907754, 3.24907754, 3.24907754]], [[3.27937469, 3.27937469, 3.27937469, ..., 3.27937469, 3.27937469, 3.27937469], [3.26417712, 3.26417712, 3.26417712, ..., 3.26417712, 3.26417712, 3.26417712], [3.24907754, 3.24907754, 3.24907754, ..., 3.24907754, 3.24907754, 3.24907754]]], [[[3.37952495, 3.37952495, 3.37952495, ..., 3.37952495, 3.37952495, 3.37952495], [3.36386616, 3.36386616, 3.36386616, ..., 3.36386616, 3.36386616, 3.36386616], [3.34830254, 3.34830254, 3.34830254, ..., 3.34830254, 3.34830254, 3.34830254]], [[3.37952495, 3.37952495, 3.37952495, ..., 3.37952495, 3.37952495, 3.37952495], [3.36386616, 3.36386616, 3.36386616, ..., 3.36386616, 3.36386616, 3.36386616], [3.34830254, 3.34830254, 3.34830254, ..., 3.34830254, 3.34830254, 3.34830254]]], [[[3.47710726, 3.47710726, 3.47710726, ..., 3.47710726, 3.47710726, 3.47710726], [3.46099907, 3.46099907, 3.46099907, ..., 3.46099907, 3.46099907, 3.46099907], [3.44498331, 3.44498331, 3.44498331, ..., 3.44498331, 3.44498331, 3.44498331]], [[3.47710726, 3.47710726, 3.47710726, ..., 3.47710726, 3.47710726, 3.47710726], [3.46099907, 3.46099907, 3.46099907, ..., 3.46099907, 3.46099907, 3.46099907], [3.44498331, 3.44498331, 3.44498331, ..., 3.44498331, 3.44498331, 3.44498331]]], ..., [[[3.27937469, 3.27937469, 3.27937469, ..., 3.27937469, 3.27937469, 3.27937469], [3.26417712, 3.26417712, 3.26417712, ..., 3.26417712, 3.26417712, 3.26417712], [3.24907754, 3.24907754, 3.24907754, ..., 3.24907754, 3.24907754, 3.24907754]], [[3.27937469, 3.27937469, 3.27937469, ..., 3.27937469, 3.27937469, 3.27937469], [3.26417712, 3.26417712, 3.26417712, ..., 3.26417712, 3.26417712, 3.26417712], [3.24907754, 3.24907754, 3.24907754, ..., 3.24907754, 3.24907754, 3.24907754]]], [[[3.37952495, 3.37952495, 3.37952495, ..., 3.37952495, 3.37952495, 3.37952495], [3.36386616, 3.36386616, 3.36386616, ..., 3.36386616, 3.36386616, 3.36386616], [3.34830254, 3.34830254, 3.34830254, ..., 3.34830254, 3.34830254, 3.34830254]], [[3.37952495, 3.37952495, 3.37952495, ..., 3.37952495, 3.37952495, 3.37952495], [3.36386616, 3.36386616, 3.36386616, ..., 3.36386616, 3.36386616, 3.36386616], [3.34830254, 3.34830254, 3.34830254, ..., 3.34830254, 3.34830254, 3.34830254]]], [[[3.47710726, 3.47710726, 3.47710726, ..., 3.47710726, 3.47710726, 3.47710726], [3.46099907, 3.46099907, 3.46099907, ..., 3.46099907, 3.46099907, 3.46099907], [3.44498331, 3.44498331, 3.44498331, ..., 3.44498331, 3.44498331, 3.44498331]], [[3.47710726, 3.47710726, 3.47710726, ..., 3.47710726, 3.47710726, 3.47710726], [3.46099907, 3.46099907, 3.46099907, ..., 3.46099907, 3.46099907, 3.46099907], [3.44498331, 3.44498331, 3.44498331, ..., 3.44498331, 3.44498331, 3.44498331]]]], [[[[3.25608801, 3.25608801, 3.25608801, ..., 3.25608801, 3.25608801, 3.25608801], [3.23936353, 3.23936353, 3.23936353, ..., 3.23936353, 3.23936353, 3.23936353], [3.22272221, 3.22272221, 3.22272221, ..., 3.22272221, 3.22272221, 3.22272221]], [[3.25608801, 3.25608801, 3.25608801, ..., 3.25608801, 3.25608801, 3.25608801], [3.23936353, 3.23936353, 3.23936353, ..., 3.23936353, 3.23936353, 3.23936353], [3.22272221, 3.22272221, 3.22272221, ..., 3.22272221, 3.22272221, 3.22272221]]], [[[3.34803896, 3.34803896, 3.34803896, ..., 3.34803896, 3.34803896, 3.34803896], [3.33084447, 3.33084447, 3.33084447, ..., 3.33084447, 3.33084447, 3.33084447], [3.31373091, 3.31373091, 3.31373091, ..., 3.31373091, 3.31373091, 3.31373091]], [[3.34803896, 3.34803896, 3.34803896, ..., 3.34803896, 3.34803896, 3.34803896], [3.33084447, 3.33084447, 3.33084447, ..., 3.33084447, 3.33084447, 3.33084447], [3.31373091, 3.31373091, 3.31373091, ..., 3.31373091, 3.31373091, 3.31373091]]], [[[3.43881105, 3.43881105, 3.43881105, ..., 3.43881105, 3.43881105, 3.43881105], [3.42115257, 3.42115257, 3.42115257, ..., 3.42115257, 3.42115257, 3.42115257], [3.40357284, 3.40357284, 3.40357284, ..., 3.40357284, 3.40357284, 3.40357284]], [[3.43881105, 3.43881105, 3.43881105, ..., 3.43881105, 3.43881105, 3.43881105], [3.42115257, 3.42115257, 3.42115257, ..., 3.42115257, 3.42115257, 3.42115257], [3.40357284, 3.40357284, 3.40357284, ..., 3.40357284, 3.40357284, 3.40357284]]], ..., [[[3.25608801, 3.25608801, 3.25608801, ..., 3.25608801, 3.25608801, 3.25608801], [3.23936353, 3.23936353, 3.23936353, ..., 3.23936353, 3.23936353, 3.23936353], [3.22272221, 3.22272221, 3.22272221, ..., 3.22272221, 3.22272221, 3.22272221]], [[3.25608801, 3.25608801, 3.25608801, ..., 3.25608801, 3.25608801, 3.25608801], [3.23936353, 3.23936353, 3.23936353, ..., 3.23936353, 3.23936353, 3.23936353], [3.22272221, 3.22272221, 3.22272221, ..., 3.22272221, 3.22272221, 3.22272221]]], [[[3.34803896, 3.34803896, 3.34803896, ..., 3.34803896, 3.34803896, 3.34803896], [3.33084447, 3.33084447, 3.33084447, ..., 3.33084447, 3.33084447, 3.33084447], [3.31373091, 3.31373091, 3.31373091, ..., 3.31373091, 3.31373091, 3.31373091]], [[3.34803896, 3.34803896, 3.34803896, ..., 3.34803896, 3.34803896, 3.34803896], [3.33084447, 3.33084447, 3.33084447, ..., 3.33084447, 3.33084447, 3.33084447], [3.31373091, 3.31373091, 3.31373091, ..., 3.31373091, 3.31373091, 3.31373091]]], [[[3.43881105, 3.43881105, 3.43881105, ..., 3.43881105, 3.43881105, 3.43881105], [3.42115257, 3.42115257, 3.42115257, ..., 3.42115257, 3.42115257, 3.42115257], [3.40357284, 3.40357284, 3.40357284, ..., 3.40357284, 3.40357284, 3.40357284]], [[3.43881105, 3.43881105, 3.43881105, ..., 3.43881105, 3.43881105, 3.43881105], [3.42115257, 3.42115257, 3.42115257, ..., 3.42115257, 3.42115257, 3.42115257], [3.40357284, 3.40357284, 3.40357284, ..., 3.40357284, 3.40357284, 3.40357284]]]], [[[[3.24833745, 3.24833745, 3.24833745, ..., 3.24833745, 3.24833745, 3.24833745], [3.23057385, 3.23057385, 3.23057385, ..., 3.23057385, 3.23057385, 3.23057385], [3.21288228, 3.21288228, 3.21288228, ..., 3.21288228, 3.21288228, 3.21288228]], [[3.24833745, 3.24833745, 3.24833745, ..., 3.24833745, 3.24833745, 3.24833745], [3.23057385, 3.23057385, 3.23057385, ..., 3.23057385, 3.23057385, 3.23057385], [3.21288228, 3.21288228, 3.21288228, ..., 3.21288228, 3.21288228, 3.21288228]]], [[[3.33381815, 3.33381815, 3.33381815, ..., 3.33381815, 3.33381815, 3.33381815], [3.31558895, 3.31558895, 3.31558895, ..., 3.31558895, 3.31558895, 3.31558895], [3.29742997, 3.29742997, 3.29742997, ..., 3.29742997, 3.29742997, 3.29742997]], [[3.33381815, 3.33381815, 3.33381815, ..., 3.33381815, 3.33381815, 3.33381815], [3.31558895, 3.31558895, 3.31558895, ..., 3.31558895, 3.31558895, 3.31558895], [3.29742997, 3.29742997, 3.29742997, ..., 3.29742997, 3.29742997, 3.29742997]]], [[[3.41929886, 3.41929886, 3.41929886, ..., 3.41929886, 3.41929886, 3.41929886], [3.40060405, 3.40060405, 3.40060405, ..., 3.40060405, 3.40060405, 3.40060405], [3.38197767, 3.38197767, 3.38197767, ..., 3.38197767, 3.38197767, 3.38197767]], [[3.41929886, 3.41929886, 3.41929886, ..., 3.41929886, 3.41929886, 3.41929886], [3.40060405, 3.40060405, 3.40060405, ..., 3.40060405, 3.40060405, 3.40060405], [3.38197767, 3.38197767, 3.38197767, ..., 3.38197767, 3.38197767, 3.38197767]]], ..., [[[3.24833745, 3.24833745, 3.24833745, ..., 3.24833745, 3.24833745, 3.24833745], [3.23057385, 3.23057385, 3.23057385, ..., 3.23057385, 3.23057385, 3.23057385], [3.21288228, 3.21288228, 3.21288228, ..., 3.21288228, 3.21288228, 3.21288228]], [[3.24833745, 3.24833745, 3.24833745, ..., 3.24833745, 3.24833745, 3.24833745], [3.23057385, 3.23057385, 3.23057385, ..., 3.23057385, 3.23057385, 3.23057385], [3.21288228, 3.21288228, 3.21288228, ..., 3.21288228, 3.21288228, 3.21288228]]], [[[3.33381815, 3.33381815, 3.33381815, ..., 3.33381815, 3.33381815, 3.33381815], [3.31558895, 3.31558895, 3.31558895, ..., 3.31558895, 3.31558895, 3.31558895], [3.29742997, 3.29742997, 3.29742997, ..., 3.29742997, 3.29742997, 3.29742997]], [[3.33381815, 3.33381815, 3.33381815, ..., 3.33381815, 3.33381815, 3.33381815], [3.31558895, 3.31558895, 3.31558895, ..., 3.31558895, 3.31558895, 3.31558895], [3.29742997, 3.29742997, 3.29742997, ..., 3.29742997, 3.29742997, 3.29742997]]], [[[3.41929886, 3.41929886, 3.41929886, ..., 3.41929886, 3.41929886, 3.41929886], [3.40060405, 3.40060405, 3.40060405, ..., 3.40060405, 3.40060405, 3.40060405], [3.38197767, 3.38197767, 3.38197767, ..., 3.38197767, 3.38197767, 3.38197767]], [[3.41929886, 3.41929886, 3.41929886, ..., 3.41929886, 3.41929886, 3.41929886], [3.40060405, 3.40060405, 3.40060405, ..., 3.40060405, 3.40060405, 3.40060405], [3.38197767, 3.38197767, 3.38197767, ..., 3.38197767, 3.38197767, 3.38197767]]]], [[[[3.26998914, 3.26998914, 3.26998914, ..., 3.26998914, 3.26998914, 3.26998914], [3.25139647, 3.25139647, 3.25139647, ..., 3.25139647, 3.25139647, 3.25139647], [3.23286679, 3.23286679, 3.23286679, ..., 3.23286679, 3.23286679, 3.23286679]], [[3.26998914, 3.26998914, 3.26998914, ..., 3.26998914, 3.26998914, 3.26998914], [3.25139647, 3.25139647, 3.25139647, ..., 3.25139647, 3.25139647, 3.25139647], [3.23286679, 3.23286679, 3.23286679, ..., 3.23286679, 3.23286679, 3.23286679]]], [[[3.33785555, 3.33785555, 3.33785555, ..., 3.33785555, 3.33785555, 3.33785555], [3.31887828, 3.31887828, 3.31887828, ..., 3.31887828, 3.31887828, 3.31887828], [3.29996275, 3.29996275, 3.29996275, ..., 3.29996275, 3.29996275, 3.29996275]], [[3.33785555, 3.33785555, 3.33785555, ..., 3.33785555, 3.33785555, 3.33785555], [3.31887828, 3.31887828, 3.31887828, ..., 3.31887828, 3.31887828, 3.31887828], [3.29996275, 3.29996275, 3.29996275, ..., 3.29996275, 3.29996275, 3.29996275]]], [[[3.41806131, 3.41806131, 3.41806131, ..., 3.41806131, 3.41806131, 3.41806131], [3.39862952, 3.39862952, 3.39862952, ..., 3.39862952, 3.39862952, 3.39862952], [3.37925798, 3.37925798, 3.37925798, ..., 3.37925798, 3.37925798, 3.37925798]], [[3.41806131, 3.41806131, 3.41806131, ..., 3.41806131, 3.41806131, 3.41806131], [3.39862952, 3.39862952, 3.39862952, ..., 3.39862952, 3.39862952, 3.39862952], [3.37925798, 3.37925798, 3.37925798, ..., 3.37925798, 3.37925798, 3.37925798]]], ..., [[[3.26998914, 3.26998914, 3.26998914, ..., 3.26998914, 3.26998914, 3.26998914], [3.25139647, 3.25139647, 3.25139647, ..., 3.25139647, 3.25139647, 3.25139647], [3.23286679, 3.23286679, 3.23286679, ..., 3.23286679, 3.23286679, 3.23286679]], [[3.26998914, 3.26998914, 3.26998914, ..., 3.26998914, 3.26998914, 3.26998914], [3.25139647, 3.25139647, 3.25139647, ..., 3.25139647, 3.25139647, 3.25139647], [3.23286679, 3.23286679, 3.23286679, ..., 3.23286679, 3.23286679, 3.23286679]]], [[[3.33785555, 3.33785555, 3.33785555, ..., 3.33785555, 3.33785555, 3.33785555], [3.31887828, 3.31887828, 3.31887828, ..., 3.31887828, 3.31887828, 3.31887828], [3.29996275, 3.29996275, 3.29996275, ..., 3.29996275, 3.29996275, 3.29996275]], [[3.33785555, 3.33785555, 3.33785555, ..., 3.33785555, 3.33785555, 3.33785555], [3.31887828, 3.31887828, 3.31887828, ..., 3.31887828, 3.31887828, 3.31887828], [3.29996275, 3.29996275, 3.29996275, ..., 3.29996275, 3.29996275, 3.29996275]]], [[[3.41806131, 3.41806131, 3.41806131, ..., 3.41806131, 3.41806131, 3.41806131], [3.39862952, 3.39862952, 3.39862952, ..., 3.39862952, 3.39862952, 3.39862952], [3.37925798, 3.37925798, 3.37925798, ..., 3.37925798, 3.37925798, 3.37925798]], [[3.41806131, 3.41806131, 3.41806131, ..., 3.41806131, 3.41806131, 3.41806131], [3.39862952, 3.39862952, 3.39862952, ..., 3.39862952, 3.39862952, 3.39862952], [3.37925798, 3.37925798, 3.37925798, ..., 3.37925798, 3.37925798, 3.37925798]]]]], shape=(5, 9, 2, 3, 100))
    • (arc, channel, tube, length, a4, a3)
      float64
      100m*counts*s^-1*A^-1
      binned data [len=0, len=0, ..., len=0, len=0]
      dim='event',
      content=DataArray(
                dims=(event: 2497491),
                data=float64[100m*counts*s^-1*A^-1],
                coords={'energy_transfer':float64[meV], 'sample_table_momentum_transfer':vector3[1/Å]},
                masks={'_monitor_mask':bool})

We can plot the counts as a function of energy transfer and \(a_3\) by removing the unused dimensions. As expected, it is independent of \(a_3\).

[6]:
(
    data
    .bins.concat()
    .hist(energy_transfer=500)
).plot()
[6]:
../../_images/user-guide_bifrost_bifrost-reduction_11_0.svg

We can also plot the counts as a function of the momentum transfer in the sample table frame \(Q\). For this, we first need to create a 2D slice in \(Q\) and \(\Delta E\). For simplicity, we use the x and z axes or \(Q\) (see https://scipp.github.io/scippneutron/user-guide/coordinate-transformations.html for definitions). But we could use any other normalized, orthogonal vectors in the dot products.

We can make a second plot using one of the projections and the energy transfer.

The plots are a bit coarse because we only used two triplets.

[7]:
d = data.bins.concat().copy()
x = sc.vector([1, 0, 0])
z = sc.vector([0, 0, 1])
d.bins.coords['Qx'] = sc.dot(x, d.bins.coords['sample_table_momentum_transfer'])
d.bins.coords['Qz'] = sc.dot(z, d.bins.coords['sample_table_momentum_transfer'])
d.hist(Qz=100, Qx=100).plot(norm='log') / d.hist(energy_transfer=100, Qz=100).plot(norm='log')
[7]:
../../_images/user-guide_bifrost_bifrost-reduction_13_0.svg