Data reduction for POWGEN#

This notebook shows a basic reduction workflow for powder diffraction for the SNS POWGEN instrument. It serves mainly to develop and present routines for powder diffraction and will eventually be removed in favor of a workflow for DREAM at ESS.

Note that we load functions from external modules. These modules will be removed when their ESS counterparts exist.

[1]:
%matplotlib widget
import scipp as sc
import scippneutron as scn

import ess
from ess.diffraction.external import load_calibration
from ess.diffraction import powder
from ess import diffraction
from ess.external import powgen

Initialize the logging system to write logs to a file powgen.log. This also displays a widget which shows log messages emitted by the functions that we call.

[2]:
ess.logging.configure_workflow('powgen_reduction', filename='powgen.log')
[2]:
<Logger scipp.ess.powgen_reduction (INFO)>

Load data#

Load the sample data. We use the dedicated load function from powgen instead of scippneutron.load because the former passes the correct parameters to the underlying algorithm automatically.

Note: We get the file name from powgen.data. This module provides access to managed example files. In the real world, we would need to find the file name in a different way.

[3]:
sample = powgen.load(powgen.data.sample_file())
Downloading file 'PG3_4844_event.nxs' from 'https://public.esss.dk/groups/scipp/ess/powgen/1/PG3_4844_event.nxs' to '/home/runner/.cache/ess/powgen/1'.
[4]:
sample
[4]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (291.86 MB)
    • spectrum: 24794
    • tof: 1
    • detector_info
      ()
      Dataset
      <scipp.Dataset> Dimensions: Sizes[detector:24794, ] Coordinates: detector int32 <no unit> (detector) [27500, 27501, ..., 231076, 231077] spectrum int32 <no unit> (detector) [0, 1, ..., 24792, 24793]
      Values:
      <scipp.Dataset> Dimensions: Sizes[detector:24794, ] Coordinates: detector int32 <no unit> (detector) [27500, 27501, ..., 231076, 231077] spectrum int32 <no unit> (detector) [0, 1, ..., 24792, 24793]
    • position
      (spectrum)
      vector3
      m
      [ 1.17451004 -1.01106149 -2.03796699], [ 1.18147634 -0.95946649 -2.05334117], ..., [1.81428985 0.09565841 3.84338287], [1.81375055 0.1499371 3.84269584]
      Values:
      array([[ 1.17451004, -1.01106149, -2.03796699], [ 1.18147634, -0.95946649, -2.05334117], [ 1.18844265, -0.90787149, -2.06871534], ..., [ 1.81482915, 0.04137972, 3.8440699 ], [ 1.81428985, 0.09565841, 3.84338287], [ 1.81375055, 0.1499371 , 3.84269584]])
    • sample_position
      ()
      vector3
      m
      [0. 0. 0.]
      Values:
      array([0., 0., 0.])
    • source_position
      ()
      vector3
      m
      [ 0. 0. -60.]
      Values:
      array([ 0., 0., -60.])
    • spectrum
      (spectrum)
      int32
      1, 2, ..., 24793, 24794
      Values:
      array([ 1, 2, 3, ..., 24792, 24793, 24794], dtype=int32)
    • tof
      (tof [bin-edge])
      float64
      µs
      19.0, 1.669e+04
      Values:
      array([ 19. , 16694.30078125])
    • (spectrum, tof)
      DataArrayView
      binned data [len=0, len=0, ..., len=0, len=0]
      Values:
      [<scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: tof float64 [µs] (event) [] Data: float32 [counts] (event) [] [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: tof float64 [µs] (event) [] Data: float32 [counts] (event) [] [] , ..., <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: tof float64 [µs] (event) [] Data: float32 [counts] (event) [] [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: tof float64 [µs] (event) [] Data: float32 [counts] (event) [] [] ]
    • ChopperStatus1
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [dimensionless] (time) [4, 4]
    • ChopperStatus2
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.816000000, 2011-08-12T17:22:05.000000000] Data: float64 [dimensionless] (time) [4, 4]
    • ChopperStatus3
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.816000000, 2011-08-12T17:22:05.000000000] Data: float64 [dimensionless] (time) [4, 4]
    • CurrentSP
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [dimensionless] (time) [300, 300]
    • EnergyRequest
      ()
      DataArray
      {dims=[time: 2], unit=meV, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.784000000, 2011-08-12T17:22:05.000000000] Data: float64 [meV] (time) [287.955, 287.955]
    • Filename
      ()
      string
      𝟙
      /home/runner/.cache/ess/powgen/1/PG3_4844_event.nxs
      Values:
      '/home/runner/.cache/ess/powgen/1/PG3_4844_event.nxs'
    • LKSRampRate
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [dimensionless] (time) [0, 0]
    • LambdaRequest
      ()
      DataArray
      {dims=[time: 2], unit=Å, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.784000000, 2011-08-12T17:22:05.000000000] Data: float64 [Å] (time) [0.533, 0.533]
    • Phase1
      ()
      DataArray
      {dims=[time: 1794], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:1794, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T15:50:18.267000007, ..., 2011-08-12T17:22:02.999218750, 2011-08-12T17:22:05.000000000] Data: float64 [µs] (time) [8166.72, 8165.16, ..., 8163.85, 8163.85]
    • Phase2
      ()
      DataArray
      {dims=[time: 1793], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:1793, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T15:50:18.267000007, ..., 2011-08-12T17:22:02.999218750, 2011-08-12T17:22:05.000000000] Data: float64 [µs] (time) [8335.63, 8334.09, ..., 8332.86, 8332.86]
    • Phase3
      ()
      DataArray
      {dims=[time: 1777], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:1777, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T15:50:19.688999938, ..., 2011-08-12T17:22:04.421093750, 2011-08-12T17:22:05.000000000] Data: float64 [µs] (time) [14001.5, 14001.4, ..., 14002, 14002]
    • PhaseRequest1
      ()
      DataArray
      {dims=[time: 2], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [µs] (time) [8164.07, 8164.07]
    • PhaseRequest2
      ()
      DataArray
      {dims=[time: 2], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [µs] (time) [8332.89, 8332.89]
    • PhaseRequest3
      ()
      DataArray
      {dims=[time: 2], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [µs] (time) [14001.8, 14001.8]
    • S1HCenter
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [mm] (time) [0, 0]
    • S1HCenterOffset
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [dimensionless] (time) [0, 0]
    • S1HWidth
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [mm] (time) [10, 10]
    • S1VCenter
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [mm] (time) [5, 5]
    • S1VCenterOffset
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [dimensionless] (time) [0, 0]
    • S1VHeight
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.816000000, 2011-08-12T17:22:05.000000000] Data: float64 [mm] (time) [30, 30]
    • SampleTemp
      ()
      DataArray
      {dims=[time: 467], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:467, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.784000000, 2011-08-12T15:50:18.001000007, ..., 2011-08-12T17:21:58.623843750, 2011-08-12T17:22:05.000000000] Data: float64 [dimensionless] (time) [299.352, 299.446, ..., 300, 300]
    • Speed1
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [Hz] (time) [60, 60]
    • Speed2
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [Hz] (time) [60, 60]
    • Speed3
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [Hz] (time) [60, 60]
    • SpeedRequest1
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.784000000, 2011-08-12T17:22:05.000000000] Data: float64 [Hz] (time) [60, 60]
    • SpeedRequest2
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.784000000, 2011-08-12T17:22:05.000000000] Data: float64 [Hz] (time) [60, 60]
    • SpeedRequest3
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.784000000, 2011-08-12T17:22:05.000000000] Data: float64 [Hz] (time) [60, 60]
    • TolRequest
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [dimensionless] (time) [20, 20]
    • commErrs
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.784000000, 2011-08-12T17:22:05.000000000] Data: float64 [dimensionless] (time) [0, 0]
    • currentsample
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.784000000, 2011-08-12T17:22:05.000000000] Data: float64 [dimensionless] (time) [4, 4]
    • duration
      ()
      float64
      s
      5508.0
      Values:
      array(5508.)
    • end_time
      ()
      string
      𝟙
      2011-08-12T17:22:05
      Values:
      '2011-08-12T17:22:05'
    • experiment_identifier
      ()
      string
      𝟙
      IPTS-2767
      Values:
      'IPTS-2767'
    • fernsstatus
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.784000000, 2011-08-12T17:22:05.000000000] Data: float64 [dimensionless] (time) [3, 3]
    • file_notes
      ()
      string
      𝟙
      NONE
      Values:
      'NONE'
    • frequency
      ()
      DataArray
      {dims=[time: 330473], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:330473, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:17.000000000, 2011-08-12T15:50:17.016659999, ..., 2011-08-12T17:22:05.085449218, 2011-08-12T17:22:05.102050781] Data: float64 [Hz] (time) [0, 60.024, ..., 60.0024, 59.9988]
    • gd_prtn_chrg
      ()
      float64
      µAh
      1171.953902925
      Values:
      array(1171.95390292)
    • guide
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.784000000, 2011-08-12T17:22:05.000000000] Data: float64 [mm] (time) [-55.463, -55.463]
    • instrument_name
      ()
      string
      POWGEN
      Values:
      'POWGEN'
    • monitor1
      ()
      DataArray
      {dims=[tof: 200001], unit=counts, coords=[tof, position, source_position]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[tof:200001, ] Coordinates: position vector3 [m] () [(0, 0, -1)] source_position vector3 [m] () [(0, 0, -60)] tof float64 [µs] (tof [bin-edge]) [0, 1, ..., 200000, 200001] Data: float64 [counts] (tof) [25, 10, ..., 0, 0] [25, 10, ..., 0, 0] Attributes: instrument_name string <no unit> () ["POWGEN"] sample_position vector3 [m] () [(0, 0, 0)] spectrum int32 <no unit> () [1]
    • proton_charge
      ()
      DataArray
      {dims=[time: 330473], unit=pC, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:330473, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:17.000000000, 2011-08-12T15:50:17.016659999, ..., 2011-08-12T17:22:05.085449218, 2011-08-12T17:22:05.102050781] Data: float64 [pC] (time) [1.48434e+07, 1.48434e+07, ..., 1.48733e+07, 1.48391e+07]
    • rotation
      (spectrum)
      linear_transform3
      𝟙
      [[ 0.91311647 0.12832664 -0.38697621] [-0.00180396 0.95043423 0.31092043] [ 0.40769482 -0.28320848 0.86808864]], [[ 0.91311647 0.12832664 -0.38697621] [-0.00180396 0.95043423 0.31092043] [ 0.40769482 -0.28320848 0.86808864]], ..., [[-0.68827073 -0.00993442 -0.7253859 ] [ 0.00234388 0.99987056 -0.01591754] [ 0.72545014 -0.01265579 -0.68815836]], [[-0.68827073 -0.00993442 -0.7253859 ] [ 0.00234388 0.99987056 -0.01591754] [ 0.72545014 -0.01265579 -0.68815836]]
      Values:
      array([[[ 0.91311647, 0.12832664, -0.38697621], [-0.00180396, 0.95043423, 0.31092043], [ 0.40769482, -0.28320848, 0.86808864]], [[ 0.91311647, 0.12832664, -0.38697621], [-0.00180396, 0.95043423, 0.31092043], [ 0.40769482, -0.28320848, 0.86808864]], [[ 0.91311647, 0.12832664, -0.38697621], [-0.00180396, 0.95043423, 0.31092043], [ 0.40769482, -0.28320848, 0.86808864]], ..., [[-0.68827073, -0.00993442, -0.7253859 ], [ 0.00234388, 0.99987056, -0.01591754], [ 0.72545014, -0.01265579, -0.68815836]], [[-0.68827073, -0.00993442, -0.7253859 ], [ 0.00234388, 0.99987056, -0.01591754], [ 0.72545014, -0.01265579, -0.68815836]], [[-0.68827073, -0.00993442, -0.7253859 ], [ 0.00234388, 0.99987056, -0.01591754], [ 0.72545014, -0.01265579, -0.68815836]]])
    • run_number
      ()
      string
      𝟙
      4844
      Values:
      '4844'
    • run_start
      ()
      string
      𝟙
      2011-08-12T15:50:17
      Values:
      '2011-08-12T15:50:17'
    • run_title
      ()
      string
      𝟙
      diamond cw0.533 4.22e12 60Hz [10x30]
      Values:
      'diamond cw0.533 4.22e12 60Hz [10x30]'
    • running
      ()
      DataArray
      {dims=[time: 1], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:1, ] Coordinates: time datetime64 [ns] (time) [1990-01-01T00:00:00.000000000] Data: bool [dimensionless] (time) [True]
    • s1b
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.784000000, 2011-08-12T17:22:05.000000000] Data: float64 [mm] (time) [20, 20]
    • s1l
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [mm] (time) [5, 5]
    • s1r
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.784000000, 2011-08-12T17:22:05.000000000] Data: float64 [mm] (time) [-5, -5]
    • s1t
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.784000000, 2011-08-12T17:22:05.000000000] Data: float64 [mm] (time) [-10, -10]
    • sample
      ()
      PyObject
      <mantid.api._api.Sample object at 0x7f5beb78bb30>
      Values:
      <mantid.api._api.Sample object at 0x7f5beb78bb30>
    • samplerequest
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.784000000, 2011-08-12T17:22:05.000000000] Data: float64 [dimensionless] (time) [4, 4]
    • shape
      (spectrum)
      vector3
      m
      [0.005 0.054286 0.0001 ], [0.005 0.054286 0.0001 ], ..., [0.005 0.054286 0.0001 ], [0.005 0.054286 0.0001 ]
      Values:
      array([[0.005 , 0.054286, 0.0001 ], [0.005 , 0.054286, 0.0001 ], [0.005 , 0.054286, 0.0001 ], ..., [0.005 , 0.054286, 0.0001 ], [0.005 , 0.054286, 0.0001 ], [0.005 , 0.054286, 0.0001 ]])
    • start_time
      ()
      string
      𝟙
      2011-08-12T15:50:17
      Values:
      '2011-08-12T15:50:17'
    • vGuide
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:16.800000000, 2011-08-12T17:22:05.000000000] Data: float64 [dimensionless] (time) [2, 2]
    • veto_pulse_time
      ()
      DataArray
      {dims=[time: 1], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:1, ] Coordinates: time datetime64 [ns] (time) [2011-08-12T15:50:17.000000000] Data: float64 [dimensionless] (time) [0]

Inspect the raw data#

We can plot the data array to get an idea of its contents.

[5]:
sample.plot()
[5]:

We can see how that data maps onto the detector by using POWGEN’s instrument view.

[6]:
powgen.instrument_view(sample)
[6]:

Filter out invalid events#

The file contains events that cannot be associated with a specific pulse. We can get a range of valid time-of-flight values from the instrument characterization file associated with the current run. There is currently no mechanism in scippneutron or ess to load such a file as it is not clear if ESS will use this approach. The values used below are taken from PG3_characterization_2011_08_31-HR.txt which is part of the sample files of Mantid. See, e.g., PowderDiffractionReduction.

We remove all events that have a time-of-flight value outside the valid range:

[7]:
sample = sample.bin(
    tof=sc.array(dims=['tof'], values=[0.0, 16666.67], unit='us'))

Normalize by proton charge#

Next, we normalize the data by the proton charge.

[8]:
sample /= sample.attrs['gd_prtn_chrg']

We can check the unit of the event weight to see that the data was indeed divided by a charge.

[9]:
sample.data.values[0].unit
[9]:
counts/uAh

Compute d-spacing#

Here, we compute d-spacing using calibration parameters provided in an example file.

First, we load the calibration parameters. We need to specify an instrument definition that Mantid understands. It needs to be selected for the specific data that we are processing.

Note: ESS instruments will not use instrument definition files (IDF). Instead, the instrument parameters will be encoded in the ess module and the instrument can be identified using data in the NeXus file. But for the purposes of this example, we need to provide the IDF.

[10]:
cal = load_calibration(
    powgen.data.calibration_file(),
    instrument_filename='POWGEN_Definition_2011-02-25.xml',
)
Downloading file 'PG3_FERNS_d4832_2011_08_24.cal' from 'https://public.esss.dk/groups/scipp/ess/powgen/1/PG3_FERNS_d4832_2011_08_24.cal' to '/home/runner/.cache/ess/powgen/1'.

The calibration is loaded with a ‘detector’ dimension. Compute the corresponding spectrum indices using the detector info loaded as part of the sample data.

[11]:
cal = powgen.beamline.map_detector_to_spectrum(
    cal, detector_info=sample.coords['detector_info'].value)
[12]:
cal
[12]:
Show/Hide data repr Show/Hide attributes
scipp.Dataset (705.72 KB)
    • spectrum: 24794
    • spectrum
      (spectrum)
      int32
      1, 2, ..., 24793, 24794
      Values:
      array([ 1, 2, 3, ..., 24792, 24793, 24794], dtype=int32)
    • difa
      (spectrum)
      float64
      9290304000000s/ft^2
      0.0, 0.0, ..., 0.0, 0.0
      Values:
      array([0., 0., 0., ..., 0., 0., 0.])
    • difc
      (spectrum)
      float64
      10N/mW
      2.997e+04, 3.003e+04, ..., 7113.696, 7125.408
      Values:
      array([29971.33683513, 30030.72117038, 30087.70542759, ..., 7107.51320735, 7113.6962062 , 7125.40789494])
    • mask
      (spectrum)
      bool
      False, False, ..., False, False
      Values:
      array([False, False, False, ..., False, False, False])
    • tzero
      (spectrum)
      float64
      µs
      0.0, 0.0, ..., 0.0, 0.0
      Values:
      array([0., 0., 0., ..., 0., 0., 0.])

Now when can compute d-spacing for the sample using the calibration parameters.

[13]:
sample_dspacing = powder.to_dspacing_with_calibration(sample, calibration=cal)

Vanadium correction#

Before we can process the d-spacing distribution further, we need to normalize the data by a vanadium measurement. ess.diffraction provides a helper function to load event data for vanadium and process it in a similar way to what we did above.

[14]:
vana = powgen.load_and_preprocess_vanadium(
    powgen.data.vanadium_file(),
    powgen.data.empty_instrument_file())
Downloading file 'PG3_4866_event.nxs' from 'https://public.esss.dk/groups/scipp/ess/powgen/1/PG3_4866_event.nxs' to '/home/runner/.cache/ess/powgen/1'.
Downloading file 'PG3_5226_event.nxs' from 'https://public.esss.dk/groups/scipp/ess/powgen/1/PG3_5226_event.nxs' to '/home/runner/.cache/ess/powgen/1'.
[15]:
vana
[15]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (1.98 GB)
    • spectrum: 24794
    • wavelength: 1
    • spectrum
      (spectrum)
      int32
      1, 2, ..., 24793, 24794
      Values:
      array([ 1, 2, 3, ..., 24792, 24793, 24794], dtype=int32)
    • wavelength
      (spectrum, wavelength [bin-edge])
      float64
      Å
      0.001, 1.056, ..., 0.001, 1.028
      Values:
      array([[0.00120148, 1.05588829], [0.00120156, 1.05596205], [0.00120162, 1.05601645], ..., [0.00116986, 1.02810108], [0.00116986, 1.0281007 ], [0.00116984, 1.02808923]])
    • (spectrum, 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/pC] (event) [] [] Attributes: tof float64 [µs] (event) [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] wavelength float64 [Å] (event) [] Data: float32 [counts/pC] (event) [] [] Attributes: tof float64 [µs] (event) [] , ..., <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] wavelength float64 [Å] (event) [] Data: float32 [counts/pC] (event) [] [] Attributes: tof float64 [µs] (event) [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: pulse_time datetime64 [ns] (event) [] wavelength float64 [Å] (event) [] Data: float32 [counts/pC] (event) [] [] Attributes: tof float64 [µs] (event) [] ]
    • ChopperStatus1
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.409000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [4, 4]
    • ChopperStatus2
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.409000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [4, 4]
    • ChopperStatus3
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.409000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [4, 4]
    • CurrentSP
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [300, 300]
    • EnergyRequest
      ()
      DataArray
      {dims=[time: 2], unit=meV, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.362000000, 2011-08-13T22:08:26.000000000] Data: float64 [meV] (time) [287.955, 287.955]
    • Filename
      ()
      string
      𝟙
      /home/runner/.cache/ess/powgen/1/PG3_4866_event.nxs
      Values:
      '/home/runner/.cache/ess/powgen/1/PG3_4866_event.nxs'
    • L1
      ()
      float64
      m
      60.0
      Values:
      array(60.)
    • L2
      (spectrum)
      float64
      m
      2.560, 2.556, ..., 4.251, 4.252
      Values:
      array([2.56027902, 2.55590928, 2.55268677, ..., 4.25113991, 4.25116338, 4.25188 ])
    • LKSRampRate
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [0, 0]
    • LambdaRequest
      ()
      DataArray
      {dims=[time: 2], unit=Å, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.362000000, 2011-08-13T22:08:26.000000000] Data: float64 [Å] (time) [0.533, 0.533]
    • Ltotal
      (spectrum)
      float64
      m
      62.560, 62.556, ..., 64.251, 64.252
      Values:
      array([62.56027902, 62.55590928, 62.55268677, ..., 64.25113991, 64.25116338, 64.25188 ])
    • Phase1
      ()
      DataArray
      {dims=[time: 5796], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:5796, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T17:11:33.237000101, ..., 2011-08-13T22:08:25.150812500, 2011-08-13T22:08:26.000000000] Data: float64 [µs] (time) [8165.39, 8164.4, ..., 8164.09, 8164.09]
    • Phase2
      ()
      DataArray
      {dims=[time: 5788], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:5788, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T17:11:33.237000101, ..., 2011-08-13T22:08:23.619562500, 2011-08-13T22:08:26.682062500] Data: float64 [µs] (time) [8334.49, 8333.4, ..., 8333.14, 8333.06]
    • Phase3
      ()
      DataArray
      {dims=[time: 5764], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:5764, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T17:11:31.705999963, ..., 2011-08-13T22:08:25.150812500, 2011-08-13T22:08:26.000000000] Data: float64 [µs] (time) [14000.2, 14004.3, ..., 14002, 14002]
    • PhaseRequest1
      ()
      DataArray
      {dims=[time: 2], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [µs] (time) [8164.07, 8164.07]
    • PhaseRequest2
      ()
      DataArray
      {dims=[time: 2], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.409000000, 2011-08-13T22:08:26.000000000] Data: float64 [µs] (time) [8332.89, 8332.89]
    • PhaseRequest3
      ()
      DataArray
      {dims=[time: 2], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.409000000, 2011-08-13T22:08:26.000000000] Data: float64 [µs] (time) [14001.8, 14001.8]
    • S1HCenter
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [0, 0]
    • S1HCenterOffset
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [0, 0]
    • S1HWidth
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [10, 10]
    • S1VCenter
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [5, 5]
    • S1VCenterOffset
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [0, 0]
    • S1VHeight
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [30, 30]
    • SampleTemp
      ()
      DataArray
      {dims=[time: 823], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:823, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.362000000, 2011-08-13T17:12:25.822998535, ..., 2011-08-13T22:08:07.570984375, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [299.998, 299.997, ..., 300.002, 300.002]
    • Speed1
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [Hz] (time) [60, 60]
    • Speed2
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [Hz] (time) [60, 60]
    • Speed3
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [Hz] (time) [60, 60]
    • SpeedRequest1
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [Hz] (time) [60, 60]
    • SpeedRequest2
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [Hz] (time) [60, 60]
    • SpeedRequest3
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [Hz] (time) [60, 60]
    • TolRequest
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [5, 5]
    • commErrs
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.362000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [0, 0]
    • currentsample
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [2, 2]
    • duration
      ()
      float64
      s
      17816.0
      Values:
      array(17816.)
    • end_time
      ()
      string
      𝟙
      2011-08-13T22:08:26
      Values:
      '2011-08-13T22:08:26'
    • experiment_identifier
      ()
      string
      𝟙
      IPTS-2767
      Values:
      'IPTS-2767'
    • fernsstatus
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.362000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [3, 3]
    • file_notes
      ()
      string
      𝟙
      Calibration Standards;Cycle 2011-B Calibration
      Values:
      'Calibration Standards;Cycle 2011-B Calibration'
    • frequency
      ()
      DataArray
      {dims=[time: 1068931], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:1068931, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.000000000, 2011-08-13T17:11:30.016666000, ..., 2011-08-13T22:08:26.832031250, 2011-08-13T22:08:26.847656250] Data: float64 [Hz] (time) [0, 60.0024, ..., 60.0024, 60.006]
    • gd_prtn_chrg
      ()
      float64
      µAh
      3777.917473130555
      Values:
      array(3777.91747313)
    • guide
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.362000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [-55.463, -55.463]
    • incident_beam
      ()
      vector3
      m
      [ 0. 0. 60.]
      Values:
      array([ 0., 0., 60.])
    • instrument_name
      ()
      string
      POWGEN
      Values:
      'POWGEN'
    • position
      (spectrum)
      vector3
      m
      [ 1.17451004 -1.01106149 -2.03796699], [ 1.18147634 -0.95946649 -2.05334117], ..., [1.81428985 0.09565841 3.84338287], [1.81375055 0.1499371 3.84269584]
      Values:
      array([[ 1.17451004, -1.01106149, -2.03796699], [ 1.18147634, -0.95946649, -2.05334117], [ 1.18844265, -0.90787149, -2.06871534], ..., [ 1.81482915, 0.04137972, 3.8440699 ], [ 1.81428985, 0.09565841, 3.84338287], [ 1.81375055, 0.1499371 , 3.84269584]])
    • proton_charge
      ()
      DataArray
      {dims=[pulse_time: 1068931], unit=pC, coords=[pulse_time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[pulse_time:1068931, ] Coordinates: pulse_time datetime64 [ns] (pulse_time) [2011-08-13T17:11:30.000000000, 2011-08-13T17:11:30.016666000, ..., 2011-08-13T22:08:26.832031250, 2011-08-13T22:08:26.847656250] Data: float64 [pC] (pulse_time) [1.4437e+07, 1.4437e+07, ..., 1.46041e+07, 1.45998e+07]
    • run_number
      ()
      string
      𝟙
      4866
      Values:
      '4866'
    • run_start
      ()
      string
      𝟙
      2011-08-13T17:11:30
      Values:
      '2011-08-13T17:11:30'
    • run_title
      ()
      string
      𝟙
      V rod in sample stick
      Values:
      'V rod in sample stick'
    • running
      ()
      DataArray
      {dims=[time: 1], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:1, ] Coordinates: time datetime64 [ns] (time) [1990-01-01T00:00:00.000000000] Data: bool [dimensionless] (time) [True]
    • s1b
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [20, 20]
    • s1l
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [5, 5]
    • s1r
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [-5, -5]
    • s1t
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.362000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [-10, -10]
    • sample
      ()
      PyObject
      <mantid.api._api.Sample object at 0x7f5bddb65eb0>
      Values:
      <mantid.api._api.Sample object at 0x7f5bddb65eb0>
    • sample_position
      ()
      vector3
      m
      [0. 0. 0.]
      Values:
      array([0., 0., 0.])
    • samplerequest
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [2, 2]
    • scattered_beam
      (spectrum)
      vector3
      m
      [ 1.17451004 -1.01106149 -2.03796699], [ 1.18147634 -0.95946649 -2.05334117], ..., [1.81428985 0.09565841 3.84338287], [1.81375055 0.1499371 3.84269584]
      Values:
      array([[ 1.17451004, -1.01106149, -2.03796699], [ 1.18147634, -0.95946649, -2.05334117], [ 1.18844265, -0.90787149, -2.06871534], ..., [ 1.81482915, 0.04137972, 3.8440699 ], [ 1.81428985, 0.09565841, 3.84338287], [ 1.81375055, 0.1499371 , 3.84269584]])
    • source_position
      ()
      vector3
      m
      [ 0. 0. -60.]
      Values:
      array([ 0., 0., -60.])
    • start_time
      ()
      string
      𝟙
      2011-08-13T17:11:30
      Values:
      '2011-08-13T17:11:30'
    • tof
      (wavelength [bin-edge])
      float64
      µs
      19.0, 1.670e+04
      Values:
      array([ 19. , 16697.69921875])
    • vGuide
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [2, 2]
    • veto_pulse_time
      ()
      DataArray
      {dims=[time: 1], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:1, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.000000000] Data: float64 [dimensionless] (time) [0]

Currently, load_and_preprocess_vanadium uses a crude, preliminary event filtering mechanism which removed all events if the proton charge is too low. This happens with the empty instrument data in this case as can be seen in the log widget at the top of the notebook.

Now, we compute d-spacing using the same calibration parameters as before.

[16]:
vana_dspacing = powder.to_dspacing_with_calibration(vana, calibration=cal)
[17]:
vana_dspacing
[17]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (1.98 GB)
    • spectrum: 24794
    • dspacing: 1
    • dspacing
      (dspacing [bin-edge], spectrum)
      float64
      Å
      0.001, 0.001, ..., 2.347, 2.343
      Values:
      array([[6.33939023e-04, 6.32685439e-04, 6.31487172e-04, ..., 2.67322753e-03, 2.67090405e-03, 2.66651401e-03], [5.57122270e-01, 5.56020587e-01, 5.54967519e-01, ..., 2.34930259e+00, 2.34726066e+00, 2.34340258e+00]])
    • spectrum
      (spectrum)
      int32
      1, 2, ..., 24793, 24794
      Values:
      array([ 1, 2, 3, ..., 24792, 24793, 24794], dtype=int32)
    • (spectrum, dspacing)
      DataArrayView
      binned data [len=0, len=0, ..., len=0, len=0]
      Values:
      [<scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: dspacing float64 [Å] (event) [] pulse_time datetime64 [ns] (event) [] Data: float32 [counts/pC] (event) [] [] Attributes: tof float64 [µs] (event) [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: dspacing float64 [Å] (event) [] pulse_time datetime64 [ns] (event) [] Data: float32 [counts/pC] (event) [] [] Attributes: tof float64 [µs] (event) [] , ..., <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: dspacing float64 [Å] (event) [] pulse_time datetime64 [ns] (event) [] Data: float32 [counts/pC] (event) [] [] Attributes: tof float64 [µs] (event) [] , <scipp.DataArray> Dimensions: Sizes[event:0, ] Coordinates: dspacing float64 [Å] (event) [] pulse_time datetime64 [ns] (event) [] Data: float32 [counts/pC] (event) [] [] Attributes: tof float64 [µs] (event) [] ]
    • calibration
      (spectrum)
      bool
      False, False, ..., False, False
      Values:
      array([False, False, False, ..., False, False, False])
    • ChopperStatus1
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.409000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [4, 4]
    • ChopperStatus2
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.409000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [4, 4]
    • ChopperStatus3
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.409000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [4, 4]
    • CurrentSP
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [300, 300]
    • EnergyRequest
      ()
      DataArray
      {dims=[time: 2], unit=meV, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.362000000, 2011-08-13T22:08:26.000000000] Data: float64 [meV] (time) [287.955, 287.955]
    • Filename
      ()
      string
      𝟙
      /home/runner/.cache/ess/powgen/1/PG3_4866_event.nxs
      Values:
      '/home/runner/.cache/ess/powgen/1/PG3_4866_event.nxs'
    • L1
      ()
      float64
      m
      60.0
      Values:
      array(60.)
    • L2
      (spectrum)
      float64
      m
      2.560, 2.556, ..., 4.251, 4.252
      Values:
      array([2.56027902, 2.55590928, 2.55268677, ..., 4.25113991, 4.25116338, 4.25188 ])
    • LKSRampRate
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [0, 0]
    • LambdaRequest
      ()
      DataArray
      {dims=[time: 2], unit=Å, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.362000000, 2011-08-13T22:08:26.000000000] Data: float64 [Å] (time) [0.533, 0.533]
    • Ltotal
      (spectrum)
      float64
      m
      62.560, 62.556, ..., 64.251, 64.252
      Values:
      array([62.56027902, 62.55590928, 62.55268677, ..., 64.25113991, 64.25116338, 64.25188 ])
    • Phase1
      ()
      DataArray
      {dims=[time: 5796], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:5796, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T17:11:33.237000101, ..., 2011-08-13T22:08:25.150812500, 2011-08-13T22:08:26.000000000] Data: float64 [µs] (time) [8165.39, 8164.4, ..., 8164.09, 8164.09]
    • Phase2
      ()
      DataArray
      {dims=[time: 5788], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:5788, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T17:11:33.237000101, ..., 2011-08-13T22:08:23.619562500, 2011-08-13T22:08:26.682062500] Data: float64 [µs] (time) [8334.49, 8333.4, ..., 8333.14, 8333.06]
    • Phase3
      ()
      DataArray
      {dims=[time: 5764], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:5764, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T17:11:31.705999963, ..., 2011-08-13T22:08:25.150812500, 2011-08-13T22:08:26.000000000] Data: float64 [µs] (time) [14000.2, 14004.3, ..., 14002, 14002]
    • PhaseRequest1
      ()
      DataArray
      {dims=[time: 2], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [µs] (time) [8164.07, 8164.07]
    • PhaseRequest2
      ()
      DataArray
      {dims=[time: 2], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.409000000, 2011-08-13T22:08:26.000000000] Data: float64 [µs] (time) [8332.89, 8332.89]
    • PhaseRequest3
      ()
      DataArray
      {dims=[time: 2], unit=µs, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.409000000, 2011-08-13T22:08:26.000000000] Data: float64 [µs] (time) [14001.8, 14001.8]
    • S1HCenter
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [0, 0]
    • S1HCenterOffset
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [0, 0]
    • S1HWidth
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [10, 10]
    • S1VCenter
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [5, 5]
    • S1VCenterOffset
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [0, 0]
    • S1VHeight
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [30, 30]
    • SampleTemp
      ()
      DataArray
      {dims=[time: 823], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:823, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.362000000, 2011-08-13T17:12:25.822998535, ..., 2011-08-13T22:08:07.570984375, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [299.998, 299.997, ..., 300.002, 300.002]
    • Speed1
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [Hz] (time) [60, 60]
    • Speed2
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [Hz] (time) [60, 60]
    • Speed3
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [Hz] (time) [60, 60]
    • SpeedRequest1
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [Hz] (time) [60, 60]
    • SpeedRequest2
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [Hz] (time) [60, 60]
    • SpeedRequest3
      ()
      DataArray
      {dims=[time: 2], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [Hz] (time) [60, 60]
    • TolRequest
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [5, 5]
    • commErrs
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.362000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [0, 0]
    • currentsample
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [2, 2]
    • difa
      (spectrum)
      float64
      9290304000000s/ft^2
      0.0, 0.0, ..., 0.0, 0.0
      Values:
      array([0., 0., 0., ..., 0., 0., 0.])
    • difc
      (spectrum)
      float64
      10N/mW
      2.997e+04, 3.003e+04, ..., 7113.696, 7125.408
      Values:
      array([29971.33683513, 30030.72117038, 30087.70542759, ..., 7107.51320735, 7113.6962062 , 7125.40789494])
    • duration
      ()
      float64
      s
      17816.0
      Values:
      array(17816.)
    • end_time
      ()
      string
      𝟙
      2011-08-13T22:08:26
      Values:
      '2011-08-13T22:08:26'
    • experiment_identifier
      ()
      string
      𝟙
      IPTS-2767
      Values:
      'IPTS-2767'
    • fernsstatus
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.362000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [3, 3]
    • file_notes
      ()
      string
      𝟙
      Calibration Standards;Cycle 2011-B Calibration
      Values:
      'Calibration Standards;Cycle 2011-B Calibration'
    • frequency
      ()
      DataArray
      {dims=[time: 1068931], unit=Hz, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:1068931, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.000000000, 2011-08-13T17:11:30.016666000, ..., 2011-08-13T22:08:26.832031250, 2011-08-13T22:08:26.847656250] Data: float64 [Hz] (time) [0, 60.0024, ..., 60.0024, 60.006]
    • gd_prtn_chrg
      ()
      float64
      µAh
      3777.917473130555
      Values:
      array(3777.91747313)
    • guide
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.362000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [-55.463, -55.463]
    • incident_beam
      ()
      vector3
      m
      [ 0. 0. 60.]
      Values:
      array([ 0., 0., 60.])
    • instrument_name
      ()
      string
      POWGEN
      Values:
      'POWGEN'
    • position
      (spectrum)
      vector3
      m
      [ 1.17451004 -1.01106149 -2.03796699], [ 1.18147634 -0.95946649 -2.05334117], ..., [1.81428985 0.09565841 3.84338287], [1.81375055 0.1499371 3.84269584]
      Values:
      array([[ 1.17451004, -1.01106149, -2.03796699], [ 1.18147634, -0.95946649, -2.05334117], [ 1.18844265, -0.90787149, -2.06871534], ..., [ 1.81482915, 0.04137972, 3.8440699 ], [ 1.81428985, 0.09565841, 3.84338287], [ 1.81375055, 0.1499371 , 3.84269584]])
    • proton_charge
      ()
      DataArray
      {dims=[pulse_time: 1068931], unit=pC, coords=[pulse_time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[pulse_time:1068931, ] Coordinates: pulse_time datetime64 [ns] (pulse_time) [2011-08-13T17:11:30.000000000, 2011-08-13T17:11:30.016666000, ..., 2011-08-13T22:08:26.832031250, 2011-08-13T22:08:26.847656250] Data: float64 [pC] (pulse_time) [1.4437e+07, 1.4437e+07, ..., 1.46041e+07, 1.45998e+07]
    • run_number
      ()
      string
      𝟙
      4866
      Values:
      '4866'
    • run_start
      ()
      string
      𝟙
      2011-08-13T17:11:30
      Values:
      '2011-08-13T17:11:30'
    • run_title
      ()
      string
      𝟙
      V rod in sample stick
      Values:
      'V rod in sample stick'
    • running
      ()
      DataArray
      {dims=[time: 1], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:1, ] Coordinates: time datetime64 [ns] (time) [1990-01-01T00:00:00.000000000] Data: bool [dimensionless] (time) [True]
    • s1b
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [20, 20]
    • s1l
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.393000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [5, 5]
    • s1r
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [-5, -5]
    • s1t
      ()
      DataArray
      {dims=[time: 2], unit=mm, coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.362000000, 2011-08-13T22:08:26.000000000] Data: float64 [mm] (time) [-10, -10]
    • sample
      ()
      PyObject
      <mantid.api._api.Sample object at 0x7f5bddb65eb0>
      Values:
      <mantid.api._api.Sample object at 0x7f5bddb65eb0>
    • sample_position
      ()
      vector3
      m
      [0. 0. 0.]
      Values:
      array([0., 0., 0.])
    • samplerequest
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [2, 2]
    • scattered_beam
      (spectrum)
      vector3
      m
      [ 1.17451004 -1.01106149 -2.03796699], [ 1.18147634 -0.95946649 -2.05334117], ..., [1.81428985 0.09565841 3.84338287], [1.81375055 0.1499371 3.84269584]
      Values:
      array([[ 1.17451004, -1.01106149, -2.03796699], [ 1.18147634, -0.95946649, -2.05334117], [ 1.18844265, -0.90787149, -2.06871534], ..., [ 1.81482915, 0.04137972, 3.8440699 ], [ 1.81428985, 0.09565841, 3.84338287], [ 1.81375055, 0.1499371 , 3.84269584]])
    • source_position
      ()
      vector3
      m
      [ 0. 0. -60.]
      Values:
      array([ 0., 0., -60.])
    • start_time
      ()
      string
      𝟙
      2011-08-13T17:11:30
      Values:
      '2011-08-13T17:11:30'
    • tof
      (dspacing [bin-edge])
      float64
      µs
      19.0, 1.670e+04
      Values:
      array([ 19. , 16697.69921875])
    • tzero
      (spectrum)
      float64
      µs
      0.0, 0.0, ..., 0.0, 0.0
      Values:
      array([0., 0., 0., ..., 0., 0., 0.])
    • vGuide
      ()
      DataArray
      {dims=[time: 2], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:2, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.378000000, 2011-08-13T22:08:26.000000000] Data: float64 [dimensionless] (time) [2, 2]
    • veto_pulse_time
      ()
      DataArray
      {dims=[time: 1], coords=[time]}
      Values:
      <scipp.DataArray> Dimensions: Sizes[time:1, ] Coordinates: time datetime64 [ns] (time) [2011-08-13T17:11:30.000000000] Data: float64 [dimensionless] (time) [0]

Inspect d-spacing#

We need to histogram the events in order to normalize our sample data by vanadium. For consistency, we use these bin edges for both vanadium and the sample data.

[18]:
d = vana_dspacing.coords['dspacing']
dspacing_edges = sc.linspace('dspacing',
                             d.min().value,
                             d.max().value,
                             200,
                             unit=d.unit)

All spectra combined#

We start simple by combining all spectra using data.bins.concat('spectrum'). Then, we can normalize the same data by vanadium to get a d-spacing distribution.

[19]:
all_spectra = diffraction.normalize_by_vanadium(
    sample_dspacing.bins.concat('spectrum'),
    vanadium=vana_dspacing.bins.concat('spectrum'),
    edges=dspacing_edges,
)
'histogram' is deprecated. Use 'hist' instead.
[20]:
sc.histogram(all_spectra, bins=dspacing_edges).plot()
'histogram' is deprecated. Use 'hist' instead.
[20]:

Group into \(2\theta\) bins#

For a better resolution, we now group the sample and vanadium data into a number of bins in the scattering angle \(2\theta\) (see here) and normalize each individually.

[21]:
two_theta = sc.linspace(dim='two_theta',
                        unit='deg',
                        start=25.0,
                        stop=90.0,
                        num=16)
sample_by_two_theta = diffraction.group_by_two_theta(sample_dspacing,
                                                     edges=two_theta)
vana_by_two_theta = diffraction.group_by_two_theta(vana_dspacing,
                                                   edges=two_theta)
[22]:
normalized = diffraction.normalize_by_vanadium(sample_by_two_theta,
                                               vanadium=vana_by_two_theta,
                                               edges=dspacing_edges)
'histogram' is deprecated. Use 'hist' instead.

Histogram the results in order to get a useful binning in the following plots.

[23]:
normalized = sc.histogram(normalized, bins=dspacing_edges)
'histogram' is deprecated. Use 'hist' instead.

Now we can inspect the d-spacing distribution as a function of \(2\theta\).

[24]:
normalized.plot()
[24]:

In order to get 1-dimensional plots, we can select some ranges of scattering angles.

[25]:
angle = sc.midpoints(normalized.coords['two_theta']).values
results = {
    f'{round(angle[group], 3)} rad':
    normalized['two_theta', group]
    for group in range(2, 6)
}
sc.plot(results)
[25]:

Or interactively by plotting with a 1d projection.

[26]:
normalized.plot(projection='1d')
[26]: