Data reduction for Amor

In this notebook, we will look at the reduction workflow for reflectometry data collected from the PSI Amor instrument. This is a living document and there are plans to update this as necessary with changes in the data reduction methodology and code.

We will begin by importing the modules that are necessary for this notebook and loading the data. The sample.nxs file is the experimental data file of interest, while reference.nxs is the reference measurement of the neutron supermirror.

[1]:
import scipp as sc
from ess import amor
/usr/share/miniconda/envs/test/conda-bld/ess_1642525336443/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.9/site-packages/scipp/plotting/__init__.py:39: UserWarning: The ipympl backend, which is required for interactive plots in Jupyter, was not found. Falling back to a static backend. Use conda install -c conda-forge ipympl to install ipympl.
  warnings.warn("The ipympl backend, which is required for "

The Amor beamline

Before we can load the data, we need to define the parameters of the beamline. We begin by defining the convention for naming angles in our set-up. We use the Fig. 5 from the paper by Stahn & Glavic (2016), which is reproduced below (along with its caption).

Figure5

The yellow area shows the incoming and reflected beam, both with the divergence \(\Delta \theta\). The inclination of the sample relative to the centre of the incoming beam (here identical to the instrument horizon) is called \(\omega\), and the respective angle of the reflected beam relative to the same axis is \(\gamma\).

In general the detector centre is located at \(\gamma_{\rm D} = 2\omega\). These are instrument coordinates and should not be confused with the situation on the sample, where the take-off angle of an individual neutron trajectory is called \(\theta\).

The amor module provides a helper function that generates the default beamline parameters. This function requires the sample rotation angle (\(\omega\)) as an input to fully define the beamline. In the future, all these beamline parameters (including the sample rotation) will be included in the file meta data. For now, we must define this manually.

[2]:
sample_rotation = sc.scalar(0.7989, unit='deg')
amor_beamline = amor.make_beamline(sample_rotation=sample_rotation)

Loading the data

Using the amor.load function, we load the sample.nxs file and perform some early preprocessing:

  • The tof values are converted from nanoseconds to microseconds.

  • The raw data contains events coming from two pulses, and these get folded into a single tof range

[3]:
sample = amor.load(amor.data.get_path("sample.nxs"),
                   beamline=amor_beamline)
sample
Downloading file 'sample.nxs' from 'https://public.esss.dk/groups/scipp/ess/amor/1/sample.nxs' to '/home/runner/.cache/ess/amor/1'.
[3]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (6.38 MB)
    • detector_id: 9216
    • tof: 1
    • beam_size
      ()
      float64
      m
      0.001
      Values:
      array(0.001)
    • detector_id
      (detector_id)
      int32
      1, 2, ..., 9215, 9216
      Values:
      array([ 1, 2, 3, ..., 9214, 9215, 9216], dtype=int32)
    • detector_spatial_resolution
      ()
      float64
      m
      0.0025
      Values:
      array(0.0025)
    • gravity
      ()
      vector3
      m/s^2
      [ 0. -9.80665 0. ]
      Values:
      array([ 0. , -9.80665, 0. ])
    • position
      (detector_id)
      vector3
      m
      [-0.064 0.09459759 4.12644383], [-0.05987097 0.09459759 4.12644383], ..., [0.05987097 0. 4. ], [0.064 0. 4. ]
      Values:
      array([[-0.064 , 0.09459759, 4.12644383], [-0.05987097, 0.09459759, 4.12644383], [-0.05574194, 0.09459759, 4.12644383], ..., [ 0.05574194, 0. , 4. ], [ 0.05987097, 0. , 4. ], [ 0.064 , 0. , 4. ]])
    • sample_position
      ()
      vector3
      m
      [0. 0. 0.]
      Values:
      array([0., 0., 0.])
    • sample_rotation
      ()
      float64
      deg
      0.7989
      Values:
      array(0.7989)
    • sample_size
      ()
      float64
      m
      0.01
      Values:
      array(0.01)
    • source_chopper
      ()
      Dataset
      <scipp.Dataset> Dimensions: Sizes[] Data: frequency float64 [Hz] () [6.66667] phase float64 [deg] () [-8] position vector3 [m] () [(0, 0, -15)]
      Values:
      <scipp.Dataset> Dimensions: Sizes[] Data: frequency float64 [Hz] () [6.66667] phase float64 [deg] () [-8] position vector3 [m] () [(0, 0, -15)]
    • source_position
      ()
      vector3
      m
      [ 0. 0. -30.]
      Values:
      array([ 0., 0., -30.])
    • tof
      (tof [bin-edge])
      float64
      µs
      0.0, 7.500e+04
      Values:
      array([ 0., 75000.])
    • (detector_id, tof)
      DataArrayView
      binned data [len=0, len=0, ..., len=0, len=0]
      Values:
      [<scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] tof float64 [µs] (event) [] Data: float32 [counts] (event) [] [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] tof float64 [µs] (event) [] Data: float32 [counts] (event) [] [] , ..., <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] tof float64 [µs] (event) [] Data: float32 [counts] (event) [] [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] tof float64 [µs] (event) [] Data: float32 [counts] (event) [] [] ]
    • experiment_title
      ()
      string
      commissioning
      Values:
      'commissioning'
    • instrument_name
      ()
      string
      AMOR
      Values:
      'AMOR'
    • start_time
      ()
      string
      2020-11-25T16:03:10.000000000
      Values:
      '2020-11-25T16:03:10.000000000'

By simply plotting the data, we get a first glimpse into the data contents.

[4]:
sc.plot(sample)

Correcting the position of the detector pixels

Note: once new Nexus files are produced, this step should go away.

The pixel positions are wrong in the sample.nxs file, and require an ad-hoc correction. We apply an arbitrary shift in the vertical (y) direction. We first move the pixels down by 0.955 degrees, so that the centre of the beam goes through the centre of the top half of the detector blades (the bottom half of the detectors was turned off). Next, we move all the pixels so that the centre of the top half of the detector pixels lies at an angle of \(2 \omega\), as described in the beamline diagram.

[5]:
def pixel_position_correction(data: sc.DataArray):
    return data.coords['position'].fields.z * sc.tan(2.0 *
                                                     data.coords['sample_rotation'] -
                                                     (0.955 * sc.units.deg))
sample.coords['position'].fields.y += pixel_position_correction(sample)

We now check that the detector pixels are in the correct position by showing the instrument view

[6]:
amor.instrument_view(sample)

Coordinate transformation graph

To compute the wavelength \(\lambda\), the scattering angle \(\theta\), and the \(Q\) vector for our data, we construct a coordinate transformation graph.

It is based on classical conversions from tof and pixel position to \(\lambda\) (wavelength), \(\theta\) (theta) and \(Q\) (Q), but comprises a number of modifications.

The computation of the scattering angle \(\theta\) includes a correction for the Earth’s gravitational field which bends the flight path of the neutrons. The angle can be found using the following expression

\[\theta = \sin^{-1}\left(\frac{\left\lvert y + \frac{g m_{\rm n}}{2 h^{2}} \lambda^{2} L_{2}^{2} \right\rvert }{L_{2}}\right) - \omega\]

where \(m_{\rm n}\) is the neutron mass, \(g\) is the acceleration due to gravity, and \(h\) is Planck’s constant.

For a graphical representation of the above expression, we consider once again the situation with a convergent beam onto an inclined sample.

specular_reflection

The detector (in green), whose center is located at an angle \(\gamma_{\rm D}\) from the horizontal plane, has a physical extent and is measuring counts at multiple scattering angles at the same time. We consider two possible paths for neutrons. The first path (cyan) is travelling horizontally from the source to the sample and subsequently, following specular reflection, hits the detector at \(\gamma_{\rm D}\) from the horizontal plane. From the symmetry of Bragg’s law, the scattering angle for this path is \(\theta_{1} = \gamma_{\rm D} - \omega\).

The second path (red) is hitting the bottom edge of the detector. Assuming that all reflections are specular, the only way the detector can record neutron events at this location is if the neutron originated from the bottom part of the convergent beam. Using the same symmetry argument as above, the scattering angle is \(\theta_{2} = \gamma_{2} - \omega\).

This expression differs slightly from the equation found in the computation of the \(\theta\) angle in other techniques such as SANS, in that the horizontal \(x\) term is absent, because we assume a planar symmetry and only consider the vertical \(y\) component of the displacement.

The conversion graph is defined in the reflectometry module, and can be obtained via

[7]:
graph = amor.conversions.specular_reflection()
sc.show_graph(graph, simplified=True)
[7]:
../../_images/instruments_amor_amor_reduction_13_0.svg

Computing the wavelength

To compute the wavelength of the neutrons, we request the wavelength coordinate from the transform_coords method by supplying our graph defined above (see here for more information about using transform_coords).

We also exclude all neutrons with a wavelength lower than 2.4 Å.

[8]:
sample_wav = sample.transform_coords(["wavelength"], graph=graph)
wavelength_edges = sc.array(dims=['wavelength'], values=[2.4, 16.0], unit='angstrom')
sample_wav = sc.bin(sample_wav, edges=[wavelength_edges])
sample_wav
[8]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (8.68 MB)
    • detector_id: 9216
    • wavelength: 1
    • beam_size
      ()
      float64
      m
      0.001
      Values:
      array(0.001)
    • detector_id
      (detector_id)
      int32
      1, 2, ..., 9215, 9216
      Values:
      array([ 1, 2, 3, ..., 9214, 9215, 9216], dtype=int32)
    • detector_spatial_resolution
      ()
      float64
      m
      0.0025
      Values:
      array(0.0025)
    • gravity
      ()
      vector3
      m/s^2
      [ 0. -9.80665 0. ]
      Values:
      array([ 0. , -9.80665, 0. ])
    • sample_rotation
      ()
      float64
      deg
      0.7989
      Values:
      array(0.7989)
    • sample_size
      ()
      float64
      m
      0.01
      Values:
      array(0.01)
    • source_position
      ()
      vector3
      m
      [ 0. 0. -30.]
      Values:
      array([ 0., 0., -30.])
    • wavelength
      (wavelength [bin-edge])
      float64
      Å
      2.4, 16.0
      Values:
      array([ 2.4, 16. ])
    • (detector_id, wavelength)
      DataArrayView
      binned data [len=0, len=0, ..., len=0, len=0]
      Values:
      [<scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] wavelength float64 [Å] (event) [] Data: float32 [counts] (event) [] [] Attributes: tof float64 [µs] (event) [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] wavelength float64 [Å] (event) [] Data: float32 [counts] (event) [] [] Attributes: tof float64 [µs] (event) [] , ..., <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] wavelength float64 [Å] (event) [] Data: float32 [counts] (event) [] [] Attributes: tof float64 [µs] (event) [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] wavelength float64 [Å] (event) [] Data: float32 [counts] (event) [] [] Attributes: tof float64 [µs] (event) [] ]
    • L1
      ()
      float64
      m
      15.0
      Values:
      array(15.)
    • L2
      (detector_id)
      float64
      m
      4.129, 4.129, ..., 4.001, 4.001
      Values:
      array([4.12934447, 4.12928254, 4.12922474, ..., 4.0006401 , 4.00069976, 4.00076368])
    • Ltotal
      (detector_id)
      float64
      m
      19.129, 19.129, ..., 19.001, 19.001
      Values:
      array([19.12934447, 19.12928254, 19.12922474, ..., 19.0006401 , 19.00069976, 19.00076368])
    • experiment_title
      ()
      string
      commissioning
      Values:
      'commissioning'
    • incident_beam
      ()
      vector3
      m
      [ 0. 0. 15.]
      Values:
      array([ 0., 0., 15.])
    • instrument_name
      ()
      string
      AMOR
      Values:
      'AMOR'
    • position
      (detector_id)
      vector3
      m
      [-0.064 0.14089401 4.12644383], [-0.05987097 0.14089401 4.12644383], ..., [0.05987097 0.04487779 4. ], [0.064 0.04487779 4. ]
      Values:
      array([[-0.064 , 0.14089401, 4.12644383], [-0.05987097, 0.14089401, 4.12644383], [-0.05574194, 0.14089401, 4.12644383], ..., [ 0.05574194, 0.04487779, 4. ], [ 0.05987097, 0.04487779, 4. ], [ 0.064 , 0.04487779, 4. ]])
    • sample_position
      ()
      vector3
      m
      [0. 0. 0.]
      Values:
      array([0., 0., 0.])
    • scattered_beam
      (detector_id)
      vector3
      m
      [-0.064 0.14089401 4.12644383], [-0.05987097 0.14089401 4.12644383], ..., [0.05987097 0.04487779 4. ], [0.064 0.04487779 4. ]
      Values:
      array([[-0.064 , 0.14089401, 4.12644383], [-0.05987097, 0.14089401, 4.12644383], [-0.05574194, 0.14089401, 4.12644383], ..., [ 0.05574194, 0.04487779, 4. ], [ 0.05987097, 0.04487779, 4. ], [ 0.064 , 0.04487779, 4. ]])
    • source_chopper
      ()
      Dataset
      <scipp.Dataset> Dimensions: Sizes[] Data: frequency float64 [Hz] () [6.66667] phase float64 [deg] () [-8] position vector3 [m] () [(0, 0, -15)]
      Values:
      <scipp.Dataset> Dimensions: Sizes[] Data: frequency float64 [Hz] () [6.66667] phase float64 [deg] () [-8] position vector3 [m] () [(0, 0, -15)]
    • start_time
      ()
      string
      2020-11-25T16:03:10.000000000
      Values:
      '2020-11-25T16:03:10.000000000'
[9]:
sample_wav.bins.concatenate('detector_id').plot()

Compute the Q vector

Using the same method, we can compute the \(Q\) vector, which now depends on both detector position (id) and wavelength

[10]:
sample_q = sample_wav.transform_coords(["Q"], graph=graph)
sample_q
[10]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (12.93 MB)
    • detector_id: 9216
    • Q: 1
    • Q
      (Q [bin-edge], detector_id)
      float64
      1/Å
      0.106, 0.106, ..., -0.002, -0.002
      Values:
      array([[ 0.1056337 , 0.10563638, 0.10563888, ..., -0.01430872, -0.0143096 , -0.01431054], [ 0.01559069, 0.01559109, 0.01559147, ..., -0.00239267, -0.0023928 , -0.00239295]])
    • beam_size
      ()
      float64
      m
      0.001
      Values:
      array(0.001)
    • detector_id
      (detector_id)
      int32
      1, 2, ..., 9215, 9216
      Values:
      array([ 1, 2, 3, ..., 9214, 9215, 9216], dtype=int32)
    • detector_spatial_resolution
      ()
      float64
      m
      0.0025
      Values:
      array(0.0025)
    • sample_size
      ()
      float64
      m
      0.01
      Values:
      array(0.01)
    • source_position
      ()
      vector3
      m
      [ 0. 0. -30.]
      Values:
      array([ 0., 0., -30.])
    • (detector_id, Q)
      DataArrayView
      binned data [len=0, len=0, ..., len=0, len=0]
      Values:
      [<scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: Q float64 [1/Å] (event) [] pulse_time datetime64 [ns] (event) [] Data: float32 [counts] (event) [] [] Attributes: theta float64 [rad] (event) [] tof float64 [µs] (event) [] wavelength float64 [Å] (event) [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: Q float64 [1/Å] (event) [] pulse_time datetime64 [ns] (event) [] Data: float32 [counts] (event) [] [] Attributes: theta float64 [rad] (event) [] tof float64 [µs] (event) [] wavelength float64 [Å] (event) [] , ..., <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: Q float64 [1/Å] (event) [] pulse_time datetime64 [ns] (event) [] Data: float32 [counts] (event) [] [] Attributes: theta float64 [rad] (event) [] tof float64 [µs] (event) [] wavelength float64 [Å] (event) [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: Q float64 [1/Å] (event) [] pulse_time datetime64 [ns] (event) [] Data: float32 [counts] (event) [] [] Attributes: theta float64 [rad] (event) [] tof float64 [µs] (event) [] wavelength float64 [Å] (event) [] ]
    • L1
      ()
      float64
      m
      15.0
      Values:
      array(15.)
    • L2
      (detector_id)
      float64
      m
      4.129, 4.129, ..., 4.001, 4.001
      Values:
      array([4.12934447, 4.12928254, 4.12922474, ..., 4.0006401 , 4.00069976, 4.00076368])
    • Ltotal
      (detector_id)
      float64
      m
      19.129, 19.129, ..., 19.001, 19.001
      Values:
      array([19.12934447, 19.12928254, 19.12922474, ..., 19.0006401 , 19.00069976, 19.00076368])
    • experiment_title
      ()
      string
      commissioning
      Values:
      'commissioning'
    • gravity
      ()
      vector3
      m/s^2
      [ 0. -9.80665 0. ]
      Values:
      array([ 0. , -9.80665, 0. ])
    • incident_beam
      ()
      vector3
      m
      [ 0. 0. 15.]
      Values:
      array([ 0., 0., 15.])
    • instrument_name
      ()
      string
      AMOR
      Values:
      'AMOR'
    • position
      (detector_id)
      vector3
      m
      [-0.064 0.14089401 4.12644383], [-0.05987097 0.14089401 4.12644383], ..., [0.05987097 0.04487779 4. ], [0.064 0.04487779 4. ]
      Values:
      array([[-0.064 , 0.14089401, 4.12644383], [-0.05987097, 0.14089401, 4.12644383], [-0.05574194, 0.14089401, 4.12644383], ..., [ 0.05574194, 0.04487779, 4. ], [ 0.05987097, 0.04487779, 4. ], [ 0.064 , 0.04487779, 4. ]])
    • sample_position
      ()
      vector3
      m
      [0. 0. 0.]
      Values:
      array([0., 0., 0.])
    • sample_rotation
      ()
      float64
      deg
      0.7989
      Values:
      array(0.7989)
    • scattered_beam
      (detector_id)
      vector3
      m
      [-0.064 0.14089401 4.12644383], [-0.05987097 0.14089401 4.12644383], ..., [0.05987097 0.04487779 4. ], [0.064 0.04487779 4. ]
      Values:
      array([[-0.064 , 0.14089401, 4.12644383], [-0.05987097, 0.14089401, 4.12644383], [-0.05574194, 0.14089401, 4.12644383], ..., [ 0.05574194, 0.04487779, 4. ], [ 0.05987097, 0.04487779, 4. ], [ 0.064 , 0.04487779, 4. ]])
    • source_chopper
      ()
      Dataset
      <scipp.Dataset> Dimensions: Sizes[] Data: frequency float64 [Hz] () [6.66667] phase float64 [deg] () [-8] position vector3 [m] () [(0, 0, -15)]
      Values:
      <scipp.Dataset> Dimensions: Sizes[] Data: frequency float64 [Hz] () [6.66667] phase float64 [deg] () [-8] position vector3 [m] () [(0, 0, -15)]
    • start_time
      ()
      string
      2020-11-25T16:03:10.000000000
      Values:
      '2020-11-25T16:03:10.000000000'
    • theta
      (Q [bin-edge], detector_id)
      float64
      rad
      0.020, 0.020, ..., -0.003, -0.003
      Values:
      array([[ 0.02017592, 0.02017643, 0.02017691, ..., -0.00273277, -0.00273294, -0.00273312], [ 0.01985198, 0.0198525 , 0.01985298, ..., -0.00304645, -0.00304662, -0.0030468 ]])
    • wavelength
      (Q [bin-edge])
      float64
      Å
      2.4, 16.0
      Values:
      array([ 2.4, 16. ])
[11]:
q_edges = sc.geomspace(dim='Q', start=0.008, stop=0.08, num=201, unit='1/angstrom')
sample_q_binned = sc.bin(sample_q, edges=[q_edges])
sample_q_summed = sample_q_binned.sum('detector_id')
sc.plot(sample_q_summed, norm="log")

Normalize by the super-mirror

To perform the normalization, we load the super-mirror reference.nxs file.

[12]:
reference = amor.load(amor.data.get_path("reference.nxs"),
                      beamline=amor_beamline)
reference.coords['position'].fields.y += pixel_position_correction(reference)
reference
Downloading file 'reference.nxs' from 'https://public.esss.dk/groups/scipp/ess/amor/1/reference.nxs' to '/home/runner/.cache/ess/amor/1'.
[12]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (109.46 MB)
    • detector_id: 9216
    • tof: 1
    • beam_size
      ()
      float64
      m
      0.001
      Values:
      array(0.001)
    • detector_id
      (detector_id)
      int32
      1, 2, ..., 9215, 9216
      Values:
      array([ 1, 2, 3, ..., 9214, 9215, 9216], dtype=int32)
    • detector_spatial_resolution
      ()
      float64
      m
      0.0025
      Values:
      array(0.0025)
    • gravity
      ()
      vector3
      m/s^2
      [ 0. -9.80665 0. ]
      Values:
      array([ 0. , -9.80665, 0. ])
    • position
      (detector_id)
      vector3
      m
      [-0.064 0.14089401 4.12644383], [-0.05987097 0.14089401 4.12644383], ..., [0.05987097 0.04487779 4. ], [0.064 0.04487779 4. ]
      Values:
      array([[-0.064 , 0.14089401, 4.12644383], [-0.05987097, 0.14089401, 4.12644383], [-0.05574194, 0.14089401, 4.12644383], ..., [ 0.05574194, 0.04487779, 4. ], [ 0.05987097, 0.04487779, 4. ], [ 0.064 , 0.04487779, 4. ]])
    • sample_position
      ()
      vector3
      m
      [0. 0. 0.]
      Values:
      array([0., 0., 0.])
    • sample_rotation
      ()
      float64
      deg
      0.7989
      Values:
      array(0.7989)
    • sample_size
      ()
      float64
      m
      0.01
      Values:
      array(0.01)
    • source_chopper
      ()
      Dataset
      <scipp.Dataset> Dimensions: Sizes[] Data: frequency float64 [Hz] () [6.66667] phase float64 [deg] () [-8] position vector3 [m] () [(0, 0, -15)]
      Values:
      <scipp.Dataset> Dimensions: Sizes[] Data: frequency float64 [Hz] () [6.66667] phase float64 [deg] () [-8] position vector3 [m] () [(0, 0, -15)]
    • source_position
      ()
      vector3
      m
      [ 0. 0. -30.]
      Values:
      array([ 0., 0., -30.])
    • tof
      (tof [bin-edge])
      float64
      µs
      0.0, 7.500e+04
      Values:
      array([ 0., 75000.])
    • (detector_id, tof)
      DataArrayView
      binned data [len=1, len=4, ..., len=0, len=0]
      Values:
      [<scipp.DataArray> Dimensions: Sizes[event:1, ] Coordinates: pulse_time datetime64 [ns] (event) [2020-11-25T15:57:08.000000000] tof float64 [µs] (event) [39553.5] Data: float32 [counts] (event) [1] [1] , <scipp.DataArray> Dimensions: Sizes[event:4, ] Coordinates: pulse_time datetime64 [ns] (event) [2020-11-25T16:01:47.000000000, 2020-11-25T16:01:02.000000000, 2020-11-25T16:03:00.000000000, 2020-11-25T16:06:11.000000000] tof float64 [µs] (event) [19204.7, 44955.1, 19295.1, 22223.5] Data: float32 [counts] (event) [1, 1, 1, 1] [1, 1, 1, 1] , ..., <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] tof float64 [µs] (event) [] Data: float32 [counts] (event) [] [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] tof float64 [µs] (event) [] Data: float32 [counts] (event) [] [] ]
    • experiment_title
      ()
      string
      commissioning
      Values:
      'commissioning'
    • instrument_name
      ()
      string
      AMOR
      Values:
      'AMOR'
    • start_time
      ()
      string
      2020-11-25T16:56:50.000000000
      Values:
      '2020-11-25T16:56:50.000000000'

We convert the reference to wavelength using the same graph

[13]:
reference_wav = reference.transform_coords(["wavelength"], graph=graph)
reference_wav = sc.bin(reference_wav, edges=[wavelength_edges])
reference_wav.bins.concatenate('detector_id').plot()

And we then convert to \(Q\) as well

[14]:
reference_q = reference_wav.transform_coords(["Q"], graph=graph)
reference_q_binned = sc.bin(reference_q, edges=[q_edges])
reference_q_summed = reference_q_binned.sum('detector_id')
sc.plot(reference_q_summed, norm="log")

Finally, we divide the sample by the reference to obtain

[15]:
normalized = sample_q_summed / reference_q_summed
sc.plot(normalized, norm="log")

Make a \((\lambda, \theta)\) map

A good sanity check is to create a two-dimensional map of the counts in \(\lambda\) and \(\theta\) bins. To achieve this, we request two output coordinates from the transform_coords method.

[16]:
sample_theta = sample.transform_coords(["theta", "wavelength"], graph=graph)
sample_theta
[16]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (11.01 MB)
    • detector_id: 9216
    • theta: 1
    • beam_size
      ()
      float64
      m
      0.001
      Values:
      array(0.001)
    • detector_id
      (detector_id)
      int32
      1, 2, ..., 9215, 9216
      Values:
      array([ 1, 2, 3, ..., 9214, 9215, 9216], dtype=int32)
    • detector_spatial_resolution
      ()
      float64
      m
      0.0025
      Values:
      array(0.0025)
    • sample_size
      ()
      float64
      m
      0.01
      Values:
      array(0.01)
    • source_position
      ()
      vector3
      m
      [ 0. 0. -30.]
      Values:
      array([ 0., 0., -30.])
    • theta
      (detector_id, theta [bin-edge])
      float64
      rad
      0.020, 0.020, ..., -0.003, -0.003
      Values:
      array([[ 0.02018338, 0.01987196], [ 0.02018389, 0.01987247], [ 0.02018437, 0.01987295], ..., [-0.00272555, -0.0030312 ], [-0.00272572, -0.00303137], [-0.00272589, -0.00303156]])
    • wavelength
      (detector_id, theta [bin-edge])
      float64
      Å
      0.0, 15.510, ..., 0.0, 15.615
      Values:
      array([[ 0. , 15.51033551], [ 0. , 15.51038573], [ 0. , 15.51043259], ..., [ 0. , 15.61539766], [ 0. , 15.61534863], [ 0. , 15.6152961 ]])
    • (detector_id, theta)
      DataArrayView
      binned data [len=0, len=0, ..., len=0, len=0]
      Values:
      [<scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] theta float64 [rad] (event) [] wavelength float64 [Å] (event) [] Data: float32 [counts] (event) [] [] Attributes: tof float64 [µs] (event) [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] theta float64 [rad] (event) [] wavelength float64 [Å] (event) [] Data: float32 [counts] (event) [] [] Attributes: tof float64 [µs] (event) [] , ..., <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] theta float64 [rad] (event) [] wavelength float64 [Å] (event) [] Data: float32 [counts] (event) [] [] Attributes: tof float64 [µs] (event) [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] theta float64 [rad] (event) [] wavelength float64 [Å] (event) [] Data: float32 [counts] (event) [] [] Attributes: tof float64 [µs] (event) [] ]
    • L1
      ()
      float64
      m
      15.0
      Values:
      array(15.)
    • L2
      (detector_id)
      float64
      m
      4.129, 4.129, ..., 4.001, 4.001
      Values:
      array([4.12934447, 4.12928254, 4.12922474, ..., 4.0006401 , 4.00069976, 4.00076368])
    • Ltotal
      (detector_id)
      float64
      m
      19.129, 19.129, ..., 19.001, 19.001
      Values:
      array([19.12934447, 19.12928254, 19.12922474, ..., 19.0006401 , 19.00069976, 19.00076368])
    • experiment_title
      ()
      string
      commissioning
      Values:
      'commissioning'
    • gravity
      ()
      vector3
      m/s^2
      [ 0. -9.80665 0. ]
      Values:
      array([ 0. , -9.80665, 0. ])
    • incident_beam
      ()
      vector3
      m
      [ 0. 0. 15.]
      Values:
      array([ 0., 0., 15.])
    • instrument_name
      ()
      string
      AMOR
      Values:
      'AMOR'
    • position
      (detector_id)
      vector3
      m
      [-0.064 0.14089401 4.12644383], [-0.05987097 0.14089401 4.12644383], ..., [0.05987097 0.04487779 4. ], [0.064 0.04487779 4. ]
      Values:
      array([[-0.064 , 0.14089401, 4.12644383], [-0.05987097, 0.14089401, 4.12644383], [-0.05574194, 0.14089401, 4.12644383], ..., [ 0.05574194, 0.04487779, 4. ], [ 0.05987097, 0.04487779, 4. ], [ 0.064 , 0.04487779, 4. ]])
    • sample_position
      ()
      vector3
      m
      [0. 0. 0.]
      Values:
      array([0., 0., 0.])
    • sample_rotation
      ()
      float64
      deg
      0.7989
      Values:
      array(0.7989)
    • scattered_beam
      (detector_id)
      vector3
      m
      [-0.064 0.14089401 4.12644383], [-0.05987097 0.14089401 4.12644383], ..., [0.05987097 0.04487779 4. ], [0.064 0.04487779 4. ]
      Values:
      array([[-0.064 , 0.14089401, 4.12644383], [-0.05987097, 0.14089401, 4.12644383], [-0.05574194, 0.14089401, 4.12644383], ..., [ 0.05574194, 0.04487779, 4. ], [ 0.05987097, 0.04487779, 4. ], [ 0.064 , 0.04487779, 4. ]])
    • source_chopper
      ()
      Dataset
      <scipp.Dataset> Dimensions: Sizes[] Data: frequency float64 [Hz] () [6.66667] phase float64 [deg] () [-8] position vector3 [m] () [(0, 0, -15)]
      Values:
      <scipp.Dataset> Dimensions: Sizes[] Data: frequency float64 [Hz] () [6.66667] phase float64 [deg] () [-8] position vector3 [m] () [(0, 0, -15)]
    • start_time
      ()
      string
      2020-11-25T16:03:10.000000000
      Values:
      '2020-11-25T16:03:10.000000000'
    • tof
      (theta [bin-edge])
      float64
      µs
      0.0, 7.500e+04
      Values:
      array([ 0., 75000.])

Then, we concatenate all the events in the detector_id dimension

[17]:
sample_theta = sample_theta.bins.concatenate('detector_id')
sample_theta
[17]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (9.99 MB)
    • theta: 1
    • beam_size
      ()
      float64
      m
      0.001
      Values:
      array(0.001)
    • detector_spatial_resolution
      ()
      float64
      m
      0.0025
      Values:
      array(0.0025)
    • sample_size
      ()
      float64
      m
      0.01
      Values:
      array(0.01)
    • source_position
      ()
      vector3
      m
      [ 0. 0. -30.]
      Values:
      array([ 0., 0., -30.])
    • theta
      (theta [bin-edge])
      float64
      rad
      -0.003, 0.020
      Values:
      array([-0.00303156, 0.02018747])
    • (theta)
      DataArrayView
      binned data [len=261790]
      Values:
      [<scipp.DataArray> Dimensions: Sizes[event:261790, ] Coordinates: pulse_time datetime64 [ns] (event) [2020-11-25T15:04:39.000000000, 2020-11-25T15:03:23.000000000, ..., 2020-11-25T15:03:38.000000000, 2020-11-25T15:05:09.000000000] theta float64 [rad] (event) [0.020137, 0.0199556, ..., 0.00735572, 0.00734498] wavelength float64 [Å] (event) [6.19738, 13.3795, ..., 4.4004, 5.26105] Data: float32 [counts] (event) [1, 1, ..., 1, 1] [1, 1, ..., 1, 1] Attributes: tof float64 [µs] (event) [29966.7, 64694.6, ..., 21135.4, 25269.2] ]
    • L1
      ()
      float64
      m
      15.0
      Values:
      array(15.)
    • experiment_title
      ()
      string
      commissioning
      Values:
      'commissioning'
    • gravity
      ()
      vector3
      m/s^2
      [ 0. -9.80665 0. ]
      Values:
      array([ 0. , -9.80665, 0. ])
    • incident_beam
      ()
      vector3
      m
      [ 0. 0. 15.]
      Values:
      array([ 0., 0., 15.])
    • instrument_name
      ()
      string
      AMOR
      Values:
      'AMOR'
    • sample_position
      ()
      vector3
      m
      [0. 0. 0.]
      Values:
      array([0., 0., 0.])
    • sample_rotation
      ()
      float64
      deg
      0.7989
      Values:
      array(0.7989)
    • source_chopper
      ()
      Dataset
      <scipp.Dataset> Dimensions: Sizes[] Data: frequency float64 [Hz] () [6.66667] phase float64 [deg] () [-8] position vector3 [m] () [(0, 0, -15)]
      Values:
      <scipp.Dataset> Dimensions: Sizes[] Data: frequency float64 [Hz] () [6.66667] phase float64 [deg] () [-8] position vector3 [m] () [(0, 0, -15)]
    • start_time
      ()
      string
      2020-11-25T16:03:10.000000000
      Values:
      '2020-11-25T16:03:10.000000000'

Finally, we bin into the existing theta dimension, and into a new wavelength dimension, to create a 2D output

[18]:
nbins = 165
theta_edges = sc.linspace(dim='theta', start=0.4, stop=1.2, num=nbins, unit='deg')
wavelength_edges = sc.linspace(dim='wavelength', start=1.0, stop=15.0, num=nbins, unit='angstrom')
binned = sc.bin(sample_theta, edges=[sc.to_unit(theta_edges, 'rad'), wavelength_edges])
binned
[18]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (10.34 MB)
    • theta: 164
    • wavelength: 164
    • beam_size
      ()
      float64
      m
      0.001
      Values:
      array(0.001)
    • detector_spatial_resolution
      ()
      float64
      m
      0.0025
      Values:
      array(0.0025)
    • sample_size
      ()
      float64
      m
      0.01
      Values:
      array(0.01)
    • source_position
      ()
      vector3
      m
      [ 0. 0. -30.]
      Values:
      array([ 0., 0., -30.])
    • theta
      (theta [bin-edge])
      float64
      rad
      0.007, 0.007, ..., 0.021, 0.021
      Values:
      array([0.00698132, 0.00706646, 0.00715159, 0.00723673, 0.00732187, 0.00740701, 0.00749215, 0.00757728, 0.00766242, 0.00774756, 0.0078327 , 0.00791784, 0.00800297, 0.00808811, 0.00817325, 0.00825839, 0.00834353, 0.00842866, 0.0085138 , 0.00859894, 0.00868408, 0.00876922, 0.00885435, 0.00893949, 0.00902463, 0.00910977, 0.00919491, 0.00928004, 0.00936518, 0.00945032, 0.00953546, 0.0096206 , 0.00970573, 0.00979087, 0.00987601, 0.00996115, 0.01004629, 0.01013142, 0.01021656, 0.0103017 , 0.01038684, 0.01047198, 0.01055711, 0.01064225, 0.01072739, 0.01081253, 0.01089767, 0.0109828 , 0.01106794, 0.01115308, 0.01123822, 0.01132336, 0.01140849, 0.01149363, 0.01157877, 0.01166391, 0.01174905, 0.01183418, 0.01191932, 0.01200446, 0.0120896 , 0.01217474, 0.01225987, 0.01234501, 0.01243015, 0.01251529, 0.01260043, 0.01268556, 0.0127707 , 0.01285584, 0.01294098, 0.01302612, 0.01311125, 0.01319639, 0.01328153, 0.01336667, 0.01345181, 0.01353694, 0.01362208, 0.01370722, 0.01379236, 0.0138775 , 0.01396263, 0.01404777, 0.01413291, 0.01421805, 0.01430319, 0.01438832, 0.01447346, 0.0145586 , 0.01464374, 0.01472888, 0.01481401, 0.01489915, 0.01498429, 0.01506943, 0.01515457, 0.0152397 , 0.01532484, 0.01540998, 0.01549512, 0.01558026, 0.01566539, 0.01575053, 0.01583567, 0.01592081, 0.01600595, 0.01609108, 0.01617622, 0.01626136, 0.0163465 , 0.01643164, 0.01651677, 0.01660191, 0.01668705, 0.01677219, 0.01685733, 0.01694246, 0.0170276 , 0.01711274, 0.01719788, 0.01728302, 0.01736815, 0.01745329, 0.01753843, 0.01762357, 0.01770871, 0.01779384, 0.01787898, 0.01796412, 0.01804926, 0.0181344 , 0.01821953, 0.01830467, 0.01838981, 0.01847495, 0.01856009, 0.01864522, 0.01873036, 0.0188155 , 0.01890064, 0.01898578, 0.01907091, 0.01915605, 0.01924119, 0.01932633, 0.01941147, 0.0194966 , 0.01958174, 0.01966688, 0.01975202, 0.01983716, 0.01992229, 0.02000743, 0.02009257, 0.02017771, 0.02026285, 0.02034798, 0.02043312, 0.02051826, 0.0206034 , 0.02068854, 0.02077367, 0.02085881, 0.02094395])
    • wavelength
      (wavelength [bin-edge])
      float64
      Å
      1.0, 1.085, ..., 14.915, 15.0
      Values:
      array([ 1. , 1.08536585, 1.17073171, 1.25609756, 1.34146341, 1.42682927, 1.51219512, 1.59756098, 1.68292683, 1.76829268, 1.85365854, 1.93902439, 2.02439024, 2.1097561 , 2.19512195, 2.2804878 , 2.36585366, 2.45121951, 2.53658537, 2.62195122, 2.70731707, 2.79268293, 2.87804878, 2.96341463, 3.04878049, 3.13414634, 3.2195122 , 3.30487805, 3.3902439 , 3.47560976, 3.56097561, 3.64634146, 3.73170732, 3.81707317, 3.90243902, 3.98780488, 4.07317073, 4.15853659, 4.24390244, 4.32926829, 4.41463415, 4.5 , 4.58536585, 4.67073171, 4.75609756, 4.84146341, 4.92682927, 5.01219512, 5.09756098, 5.18292683, 5.26829268, 5.35365854, 5.43902439, 5.52439024, 5.6097561 , 5.69512195, 5.7804878 , 5.86585366, 5.95121951, 6.03658537, 6.12195122, 6.20731707, 6.29268293, 6.37804878, 6.46341463, 6.54878049, 6.63414634, 6.7195122 , 6.80487805, 6.8902439 , 6.97560976, 7.06097561, 7.14634146, 7.23170732, 7.31707317, 7.40243902, 7.48780488, 7.57317073, 7.65853659, 7.74390244, 7.82926829, 7.91463415, 8. , 8.08536585, 8.17073171, 8.25609756, 8.34146341, 8.42682927, 8.51219512, 8.59756098, 8.68292683, 8.76829268, 8.85365854, 8.93902439, 9.02439024, 9.1097561 , 9.19512195, 9.2804878 , 9.36585366, 9.45121951, 9.53658537, 9.62195122, 9.70731707, 9.79268293, 9.87804878, 9.96341463, 10.04878049, 10.13414634, 10.2195122 , 10.30487805, 10.3902439 , 10.47560976, 10.56097561, 10.64634146, 10.73170732, 10.81707317, 10.90243902, 10.98780488, 11.07317073, 11.15853659, 11.24390244, 11.32926829, 11.41463415, 11.5 , 11.58536585, 11.67073171, 11.75609756, 11.84146341, 11.92682927, 12.01219512, 12.09756098, 12.18292683, 12.26829268, 12.35365854, 12.43902439, 12.52439024, 12.6097561 , 12.69512195, 12.7804878 , 12.86585366, 12.95121951, 13.03658537, 13.12195122, 13.20731707, 13.29268293, 13.37804878, 13.46341463, 13.54878049, 13.63414634, 13.7195122 , 13.80487805, 13.8902439 , 13.97560976, 14.06097561, 14.14634146, 14.23170732, 14.31707317, 14.40243902, 14.48780488, 14.57317073, 14.65853659, 14.74390244, 14.82926829, 14.91463415, 15. ])
    • (theta, wavelength)
      DataArrayView
      binned data [len=0, len=0, ..., len=0, len=0]
      Values:
      [<scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] theta float64 [rad] (event) [] wavelength float64 [Å] (event) [] Data: float32 [counts] (event) [] [] Attributes: tof float64 [µs] (event) [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] theta float64 [rad] (event) [] wavelength float64 [Å] (event) [] Data: float32 [counts] (event) [] [] Attributes: tof float64 [µs] (event) [] , ..., <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] theta float64 [rad] (event) [] wavelength float64 [Å] (event) [] Data: float32 [counts] (event) [] [] Attributes: tof float64 [µs] (event) [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] theta float64 [rad] (event) [] wavelength float64 [Å] (event) [] Data: float32 [counts] (event) [] [] Attributes: tof float64 [µs] (event) [] ]
    • L1
      ()
      float64
      m
      15.0
      Values:
      array(15.)
    • experiment_title
      ()
      string
      commissioning
      Values:
      'commissioning'
    • gravity
      ()
      vector3
      m/s^2
      [ 0. -9.80665 0. ]
      Values:
      array([ 0. , -9.80665, 0. ])
    • incident_beam
      ()
      vector3
      m
      [ 0. 0. 15.]
      Values:
      array([ 0., 0., 15.])
    • instrument_name
      ()
      string
      AMOR
      Values:
      'AMOR'
    • sample_position
      ()
      vector3
      m
      [0. 0. 0.]
      Values:
      array([0., 0., 0.])
    • sample_rotation
      ()
      float64
      deg
      0.7989
      Values:
      array(0.7989)
    • source_chopper
      ()
      Dataset
      <scipp.Dataset> Dimensions: Sizes[] Data: frequency float64 [Hz] () [6.66667] phase float64 [deg] () [-8] position vector3 [m] () [(0, 0, -15)]
      Values:
      <scipp.Dataset> Dimensions: Sizes[] Data: frequency float64 [Hz] () [6.66667] phase float64 [deg] () [-8] position vector3 [m] () [(0, 0, -15)]
    • start_time
      ()
      string
      2020-11-25T16:03:10.000000000
      Values:
      '2020-11-25T16:03:10.000000000'
[19]:
binned.bins.sum().plot()

This plot can be used to check if the value of the sample rotation angle \(\omega\) is correct. The bright triangles should be pointing back to the origin \(\lambda = \theta = 0\).