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

ReflectometryISISCalibration v1

../_images/ImageNotFound.png

Enable screenshots using DOCS_SCREENSHOTS in CMake

Summary

Corrects the positions of detector pixels by applying TwoTheta offsets provided in a calibration file

See Also

ReflectometryISISLoadAndProcess, SpecularReflectionPositionCorrect

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

Workspace

Mandatory

An input workspace or workspace group.

CalibrationFile

Input

string

Calibration data file containing a list of detector IDs and twoTheta offsets (in degrees).These should be provided as two spaced-delimited columns, labelled detectorid and theta_offset. Allowed values: [‘dat’]

OutputWorkspace

Output

Workspace

Mandatory

The calibrated output workspace.

ReflectometryISISCalibration

This algorithm adjusts the positions of individual detector pixels in a workspace based on the theta offset values provided in the calibration file. The algorithm takes a copy of the input workspace before applying the position changes, so the original workspace remains unchanged.

A .dat calibration file must be provided via the CalibrationFile property. This file should contain two, space-delimited columns labelled detectorid and theta_offset (the labels are not case-sensitive). The detector IDs are the IDs for the detector pixels that should be moved. The theta offsets are the change required to the two theta value for each detector, in degrees. Any lines in the calibration file that begin with # will be ignored to allow metadata to be added to the file, if desired.

The below is an example of a valid calibration file:

# Optional header that can be used
# to include any useful information
detectorid theta_offset
1 -0.05
2 -0.043
3 0.02

For each detector pixel in the calibration file, the algorithm finds the existing two theta value in degrees and then adds the theta offset to calculate the new two theta value (so new two theta = existing two theta + theta offset). This new two theta is then passed to SpecularReflectionPositionCorrect v2, which converts it to cartesian co-ordinates and moves the detector pixel to the new location.

Only the detectors specified in the file will be moved, all other detectors in the workspace will remain in their original positions.

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: Run calibration on a workspace

import os
import numpy as np

# Load an empty workspace
ws = LoadEmptyInstrument(InstrumentName='D17')
detector_info = ws.detectorInfo()
print(f"Before calibration:")
for i in range(1,4):
    two_theta = np.rad2deg(detector_info.twoTheta(detector_info.indexOf(i)))
    print(f"Detector ID {i} two theta: {two_theta}")

# Create a calibration file to change the first 3 detectors
file_name = os.path.join(config["defaultsave.directory"], "TestReflectometryISISCalibration.dat")
f = open(file_name,'w');
f.write('DetectorID Theta_Offset\n')
for i in range(1,4):
   f.write(f'{i} 0.1\n')
f.close();

# Run calibration
calibrated_ws = ReflectometryISISCalibration(InputWorkspace=ws, CalibrationFile=file_name)
detector_info = calibrated_ws.detectorInfo()
print(f"After calibration:")
for i in range(1,4):
    two_theta = np.rad2deg(detector_info.twoTheta(detector_info.indexOf(i)))
    print(f"Detector ID {i} two theta: {two_theta}")

Output:

Before calibration:
Detector ID 1 two theta: 2.791743331094234
Detector ID 2 two theta: 2.7697087152076083
Detector ID 3 two theta: 2.7476732793761274
After calibration:
Detector ID 1 two theta: 2.891743331094271
Detector ID 2 two theta: 2.869708715207532
Detector ID 3 two theta: 2.847673279376101

Categories: AlgorithmIndex | Reflectometry\ISIS | Workflow\Reflectometry

Source

Python: ReflectometryISISCalibration.py