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

EditInstrumentGeometry v1

Summary

Adds a new instrument or edits an existing one; currently works in an overwrite mode only.

Properties

Name

Direction

Type

Default

Description

Workspace

InOut

MatrixWorkspace

Mandatory

Workspace to edit the detector information

PrimaryFlightPath

Input

number

Optional

Primary flight path L1 of the powder diffractometer.

SpectrumIDs

Input

int list

Spectrum Numbers from the input workspace (note that it is not detector ID or workspace indices). The number of specified spectrum numbers must be either zero or the same as the number of histograms.

L2

Input

dbl list

Mandatory

Secondary flight (L2) paths for each detector. Number of L2 given must be same as the number of histograms.

Polar

Input

dbl list

Mandatory

Polar angles (two thetas) for detectors. Number of 2theta given must be the same as the number of histograms.

Azimuthal

Input

dbl list

Azimuthal angles (out-of-plane) for detectors. The number of azimuthal angles given must be the same as number of histograms.

DetectorIDs

Input

int list

User specified detector IDs of the spectra. The number of specified detector IDs must be either zero or the same as the number of histograms.

InstrumentName

Input

string

Name of the newly built instrument. If left empty, the original instrument will be used.

Description

This algorithm can:

  1. Add an Instrument to a Workspace without any real instrument associated with it, or

  2. Replace a Workspace’s Instrument with a new Instrument, or

  3. Edit all detector parameters of the instrument associated with a Workspace. (Partial instrument editing is not supported.)

Requirements on input properties

  1. PrimaryFightPath (L1): If it is not given, L1 will be the distance between source and sample in the original instrument. Otherwise, L1 is read from input. The source position of the modified instrument is (0, 0, -L1);

  2. SpectrumIDs: If not specified (empty list), then Spectrum Numbers will be set up to any array such that SpectrumNos[wsindex] is the spectrum Number of workspace index ‘wsindex’;

  3. L2 and Polar cannot be empty list;

  4. SpectrumIDs[i], L2[i], Polar[i], Azimuthal[i] and optional DetectorIDs[i] correspond to the detector of a same spectrum.

  5. Angles are specified in degrees.

Limitations

There are some limitations of this algorithm.

  1. The key to locate the detector is via spectrum Number;

  2. For each spectrum, there is only one and only one new detector. Thus, if one spectrum is associated with a group of detectors previously, the replacement (new) detector is the one which is (diffraction) focused on after this algorithm is called.

Usage

Example - Adding a new instrument to a workspace

import numpy
ws = CreateWorkspace(
    DataX=[0., 1.],
    DataY=[1., 2., 3.],
    NSpec=3)
EditInstrumentGeometry(
    ws,
    PrimaryFlightPath=5.,
    SpectrumIDs=[1, 2, 3],
    L2=[2.0, 2.3, 2.6],
    Polar=[10.0, 15.0, 23.0],
    Azimuthal=[0.0, 0.0, 0.0],
    DetectorIDs=[100, 101, 102],
    InstrumentName='Bizarrio')
spectrumInfo = ws.spectrumInfo()
for i in range(ws.getNumberHistograms()):
    print('Histogram {} scattering angle: {:.3} degrees'.format(i + 1, numpy.rad2deg(spectrumInfo.twoTheta(i))))

Output:

Histogram 1 scattering angle: 10.0 degrees
Histogram 2 scattering angle: 15.0 degrees
Histogram 3 scattering angle: 23.0 degrees

Categories: AlgorithmIndex | Diffraction\DataHandling | DataHandling\Instrument

Source

C++ header: EditInstrumentGeometry.h

C++ source: EditInstrumentGeometry.cpp