\(\renewcommand\AA{\unicode{x212B}}\)

LoadILLReflectometry v1

Summary

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

See Also

LoadNexus

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

ForegroundPeakCentre

Input

number

Optional

Foreground peak position in fractional workspace index (if not given the peak is searched for and fitted).

DetectorCentreFractionalIndex

Input

number

127.5

The fractional workspace index of the geometric centre of the detector at incident beam axis (127.5 for D17 and Figaro).

Measurement

Input

string

DirectBeam

Load as direct or reflected beam. Allowed values: [‘DirectBeam’, ‘ReflectedBeam’]

BraggAngle

Input

number

Optional

The bragg angle necessary for reflected beam.

FitStartWorkspaceIndex

Input

number

0

Start workspace index used for peak fitting.

FitEndWorkspaceIndex

Input

number

255

End workspace index used for peak fitting.

FitRangeLower

Input

number

-1

Minimum wavelength used for peak fitting.

FitRangeUpper

Input

number

-1

Maximum wavelength used for peak fitting.

XUnit

Input

string

Wavelength

X unit of the OutputWorkspace. Allowed values: [‘Wavelength’, ‘TimeOfFlight’]

LogsToReplace

Input

Dictionary

A dictionary of key-pair values for logs to be replaced.

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. 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}\).

Measurement

The loader can load both types of data: direct and reflected beam. In both cases the foreground centre will be fitted. In case of direct beam, the detector will be rotated around the sample such that the fractional workspace index of the foreground centre will appear at 0 scattering angle. In case of reflected beam, BraggAngle is mandatory, and the detector will be driven such that the foreground centre will appear at 2*BraggAngle.

Replacing sample logs

It is possible to replace any sample log of the loaded data, or add a new log, using the LogsToReplace property. The key-value pairs must be provided as JSON-compatible strings or Python dictionaries. For an example, see the Usage section.

Usage

Note

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

Example - ReflectedBeam:

import numpy
# Load ILL d17 data file (TOF mode) into a workspace 2D using a user-defined angle of 5.5 degrees:
ws2 = LoadILLReflectometry('ILL/D17/317370.nxs', Measurement='ReflectedBeam', BraggAngle=5.5)
detId = 202 # the foreground centre is around 202
det = ws2.getInstrument().getDetector(detId)
angleDet = ws2.detectorTwoTheta(det) / numpy.pi * 180

print("Pixel at detector ID {} was rotated to {:.1f} degrees.".format(detId, angleDet))

Output:

Pixel at detector ID 202 was rotated to 11.0 degrees.

Example - Direct Beam

import numpy
directBeamWS = LoadILLReflectometry('ILL/D17/317369.nxs')
detId = 202 # the foreground centre is around 202
det = directBeamWS.getInstrument().getDetector(detId)
angleDet = directBeamWS.detectorTwoTheta(det) / numpy.pi * 180

print("Pixel at detector ID {} was rotated to {:.1f} degrees.".format(detId, angleDet))

Output:

Pixel at detector ID 202 was rotated to 0.0 degrees.

Example - Replace sample log

logs_to_replace = {"ChopperSetting.firstChopper": 2, "ChopperSetting.secondChopper": 1}
ws = LoadILLReflectometry('ILL/D17/317369.nxs', LogsToReplace=logs_to_replace)

print("The first chopper ID is: {}.".format(int(ws.getRun().getLogData("ChopperSetting.firstChopper").value)))

Output:

The first chopper ID is: 2.

Categories: AlgorithmIndex | DataHandling\Nexus | ILL\Reflectometry

Source

C++ header: LoadILLReflectometry.h

C++ source: LoadILLReflectometry.cpp