LoadILLReflectometry v1

../_images/LoadILLReflectometry-v1_dlg.png

LoadILLReflectometry dialog.

Summary

Loads an ILL reflectometry Nexus file (instrument D17 or FIGARO).

Properties

Name Direction Type Default Description
Filename Input string Mandatory Name of the Nexus file to load. Allowed extensions: [‘.nxs’]
OutputWorkspace Output MatrixWorkspace Mandatory Name of the output workspace
BeamCentre Input number Optional Beam position in workspace indices (disables peak finding).
OutputBeamPosition Output TableWorkspace   Name of the fitted beam position output workspace
DirectBeamPosition Input TableWorkspace   A workspace defining the beam position; used to calculate the Bragg angle
BraggAngle Input number Optional User defined Bragg angle in degrees
XUnit Input string Wavelength X unit of the OutputWorkspace. Allowed values: [‘Wavelength’, ‘TimeOfFlight’]

Description

Loads data of a Nexus file obtained from an ILL reflectometry instrument D17 or FIGARO into a Workspace2D. Both time-of-flight and monochromatic instrument configurations are supported. In general, this loader reads detector and monitor counts and adds x-axis and error values. The output workspace contains histogram data. The x-axis can have units in time-of-flight or wavelength with non-varying and varying bins, respectively. The conversion to wavelength uses the algorithm ConvertUnits v1. The sample logs associated to the output workspace contain two additional entries, Facility, set to ILL, and loader.two_theta which writes the angle used to rotate the detector. Detector indices and spectrum numbers start with zero like workspace indices.

Time of flight axis

The chopper values are used for computing the time-of-flight values for the bin edges x_i by the following equation:

x_{i} = \left( i + 0.5 \right) w_{\mathrm{channel}} + \Delta_{t, \mathrm{tof}} -  60^{\circ} \cdot \frac{ p_{\mathrm{off}} - 45^{\circ} + \Omega_{c2} - \Omega_{c1} + \Delta_{\mathrm{open}} }{ 2 \cdot 360^{\circ} \cdot v_{c1} } \cdot 10^{6},

with the following variables: channel width w_{\mathrm{channel}}, time-of-flight delay \Delta_{t, \mathrm{tof}}, offset p_{\mathrm{off}}, phase of second chopper \Omega_{c2}, phase of first chopper \Omega_{c1}, open offset \Delta_{\mathrm{open}} and velocity of first chopper v_{c1}.

Detector position

This loader will update the detector position from what is defined in the instrument definition files. The detector will be moved to the current distance from origin and rotated around it either on the horizontal or vertical plane.

The rotation angle can be one of the following:

  • The detector angle in the sample logs. For FIGARO this will be calculated from the motor positions. This is the default behavior if neither BraggAngle nor DirectBeamPosition is given.
  • The detector angle calibrated by the direct beam measurement. This behavior is triggered when DirectBeamPosition is given.
  • An angle based on a user-specified angle given by the BraggAngle input property. This overrides all other angles.

Direct beam calibration

Calibration using a direct beam measurement is triggered when the DirectBeamPosition property is specified. In this mode, a direct beam file should be loaded separately and the OutputBeamPosition output property used to obtain a special TableWorkspace containing information on the direct beam position. This workspace can be further given as the DirectBeamPosition input to proceeding loads as exemplified in the following:

LoadILLReflectometry('directbeam.nxs', OutputWorkspace='direct_beam_ws', OutputBeamPosition='beam_position_ws')
LoadILLReflectometry('sample1.nxs', OutputWorkspace='sample1_ws', DirectBeamPosition='beam_position_ws')
LoadILLReflectometry('sample2.nxs', OutputWorkspace='sample2_ws', DirectBeamPosition='beam_position_ws')
# ...

The detector is rotated around angle \alpha, given by

\alpha = \alpha_{R} - \alpha_{D} - \Delta_{D}

where \alpha is the nominal detector angle, \alpha the detector angle of the direct beam reference and \Delta_{D} the beam position offset (see below) of the reference.

User angle

The BraggAngle option rotates the detector by an angle \alpha such that the angle between the direct beam axis and the reflected peak centre on the detector is twice BraggAngle

\alpha = 2 \theta_{user} - \Delta_{R}

where \Delta_{R} the beam position offset angle (see below). The angle \theta_{user} is BraggAngle in the simple case that the sample is in the origin. If a horizontal sample shift is present (FIGARO), the \theta_{user} angle is calculated so that the angle to the reflected peak on the detector seen from the shifted sample position is the requested BraggAngle.

Beam position offset

To calculate the angle between the detector centre and the beam, the reflectometry data is integrated using Integration v1, transposed using Transpose v1 and finally fitted by a Gaussian using Fit v1. The offset angle \Delta can then be calculated by

\Delta = \tan^{-1} \frac{(i_{centre} - i_{fit}) d_{pix}}{l_{2}},

where i_{centre} is the workspace index of the detector centre (127.5 for D17 and FIGARO), i_{fit} the fitted peak position, d_{pix} the physical pixel width and l_{2} the sample to detector centre distance.

The value of i_{fit} can be overridden by the BeamCentre property. This effectively disables the fitting procedure.

Source position

In the case of D17, this loader will move the source position (‘chopper1’ in the instrument definition file) on the z-axis to the position

z_{source} = -d_{ch} + \frac{1}{2} \delta_{ch},

where d_{ch} is the VirtualChopper.dist_chop_samp sample log entry and \delta_{ch} the Distance.ChopperGap entry.

Usage

Note

To run these usage examples please first download the usage data, and add these to your path. In MantidPlot this is done using Manage User Directories.

Example - Load ILL D17 Nexus file:

# Optional: set facility and default instrument
config['default.facility'] = 'ILL'
config['default.instrument'] = 'D17'

# Load ILL D17 data file (TOF mode) into a workspace 2D using default input options:
ws1 = LoadILLReflectometry('ILL/D17/317370.nxs')

print("Workspace {} has {} dimensions and {} histograms.".format(ws1.name(), ws1.getNumDims(), ws1.getNumberHistograms()))

Output:

Workspace ws1 has 2 dimensions and 258 histograms.

Example - Specify user angle:

import numpy

# Load ILL d17 data file (TOF mode) into a workspace 2D using a user-defined angle of 30 degrees:
ws2 = LoadILLReflectometry('ILL/D17/317370.nxs', BraggAngle=5.5)

# The original detector angle can be found in the sample logs:
angleOrig = ws2.getRun().getProperty("dan.value").value

# The reflected beam center is around pixel 202.
detId = 202
det = ws2.getInstrument().getDetector(detId)
angleDet = ws2.detectorTwoTheta(det) / numpy.pi * 180

print("The nominal angle in the NeXus file was {:.2} degrees.".format(angleOrig))
print("Pixel at detector ID {} was rotated to {:.1f} degrees.".format(detId, angleDet))

Output:

The nominal angle in the NeXus file was 3.2 degrees.
Pixel at detector ID 202 was rotated to 11.0 degrees.

Example - Calibration of detector angle by direct beam:

import numpy

directBeamWS = LoadILLReflectometry('ILL/D17/317369.nxs', OutputBeamPosition='beamPositionWS')

beamPosWS = mtd['beamPositionWS']
peakCentre = beamPosWS.cell('PeakCentre', 0)
print('Fitted direct beam maximum (in workspace indices): {:.5}'.format(peakCentre))

reflectedBeamWS = LoadILLReflectometry('ILL/D17/317370.nxs', DirectBeamPosition=beamPosWS)

# Lets load the data without detector angle calibration just for reference

refWS = LoadILLReflectometry('ILL/D17/317370.nxs')

det = reflectedBeamWS.getDetector(int(peakCentre))
detAngle = numpy.degrees(reflectedBeamWS.detectorTwoTheta(det))
det = refWS.getDetector(int(peakCentre))
refAngle = numpy.degrees(refWS.detectorTwoTheta(det))

print('Uncalibrated detector angle: {:.4} degrees.'.format(refAngle))
print('Detector angle after calibration using direct beam: {:.4} degrees.'.format(detAngle))

Output:

Fitted direct beam maximum (in workspace indices): 202.18
Uncalibrated detector angle: 1.537 degrees.
Detector angle after calibration using direct beam: 1.598 degrees.

Categories: AlgorithmIndex | DataHandling\Nexus | ILL\Reflectometry

Source

C++ source: LoadILLReflectometry.cpp (last modified: 2019-07-17)

C++ header: LoadILLReflectometry.h (last modified: 2019-02-19)