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

LoadSpiceXML2DDet v1

../_images/LoadSpiceXML2DDet-v1_dlg.png

LoadSpiceXML2DDet dialog.

Summary

Load 2-dimensional detector data file in XML format from SPICE.

See Also

LoadSpice2D

Properties

Name

Direction

Type

Default

Description

Filename

Input

string

Mandatory

XML file name for one scan including 2D detectors counts from SPICE. Allowed extensions: [‘.xml’, ‘.bin’]

OutputWorkspace

Output

MatrixWorkspace

Mandatory

Name of output matrix workspace. Output workspace will be an X by Y Workspace2D if instrument is not loaded.

DetectorLogName

Input

string

Detector

Log name (i.e., XML node name) for detector counts in XML file.By default, the name is ‘Detector’

DetectorGeometry

Input

unsigned int list

A size-2 unsigned integer array [X, Y] for detector geometry. Such that the detector contains X x Y pixels.If the input data is a binary file, input for DetectorGeometry will be overridden by detector geometry specified in the binary file

LoadInstrument

Input

boolean

True

Flag to load instrument to output workspace. HFIR’s HB3A will be loaded if InstrumentFileName is not specified.

InstrumentFilename

Input

string

The filename (including its full or relative path) of an instrument definition file. The file extension must either be .xml or .XML when specifying an instrument definition file. Note Filename or InstrumentName must be specified but not both. Allowed extensions: [‘.xml’]

SpiceTableWorkspace

Input

TableWorkspace

Name of TableWorkspace loaded from SPICE scan file by LoadSpiceAscii.

PtNumber

Input

number

0

Pt. value for the row to get sample log from.

UserSpecifiedWaveLength

Input

number

Optional

User can specify the wave length of the instrument if it is drifted from the designed value.It happens often.

ShiftedDetectorDistance

Input

number

0

Amount of shift of the distance between source and detector centre.It is used to apply instrument calibration.

DetectorCenterXShift

Input

number

0

The amount of shift of detector center along X direction in the unit meter.

DetectorCenterYShift

Input

number

0

The amount of shift of detector center along Y direction in the unit meter.

Description

This algorithm is to import SPICE-generated XML file and binary file that records data of one measurement by a (two-dimensional) Anger camera and create a MatrixWorkspace to contain the detectors’ counts, monitor counts and other sample log data.

Format of SPICE XML data file

The SPICE XML data file contains four sections under parent node SPICErack. Each section contains child nodes for detailed information.

  • Header: instrument name, reactor power, experiment title and number, scan number and etc.

  • Motor_Position: positions of motor m1, marc, 2theta, chi, phi, omega and etc.

  • Parameter_Positions: reading of sample environment devices, such as temperature at sample.

  • Counters: counting time, monitor counts, and N x N detectors’ counts,

Counts of 2D detector

Counts of an \(n\times m\) 2D detectors are recorded in XML file as below:

X(1,1)  X(1,2)  X(1,3) ... X(1,m)
.
.
.
X(n,1)  X(n,2) X(n,3) ... X(n,m)

And the (1,1) position is the bottom left corner of the Anger camera as seen from the sample position.

Format of SPICE binary data file

The SPICE binary data file contains 2 + N unsigned integers, where N is the number of detector pixels.

Here is the specification of the SPICE 2D detector binary file.

int0: number of rows in 2D detector int1: number of columns in 2D detector int2: counts of pixel on the lower left corner facing to detector from sample int3: counts of pixel just above the lower left corner . . . int(N+2): counts of pixel on the upper right corner

Note: int0 x int1 must be equal to N.

HB3A instrument facts

HB3A has 1 detector with \(256 \times 256\) pixels.

  • Pixel: width = \(2 \times 9.921875e-05\) m, height = \(2 \times 9.921875e-05\) m, depth = 0.0001 m.

  • Detector:

Output Worskpaces

The output from this algorithm is a MatrixWorskpaces.

MatrixWorskpace with instrument loaded

For a 2D detector with \(n\times m\) pixels, the output MatrixWorkspace will have \(n \times m\) spectrum. Each spectrum has 1 data point corresponding to 1 detector’s count.

All experiment information, sample environment devices’ readings and monitor counts, which are recorded in XML files, are converted to the properties in output MatrixWorkspace’s sample log.

MatrixWorkspace without instrument loaded

For a 2D detector with \(n\times m\) pixels, the output MatrixWorkspace will have \(n\) spectrum, each of which has a vector of length equal to \(m\). It can be mapped to the raw data as \(WS.readY(i)[j] = X(i+1,j+1)\).

All experiment information, sample environment devices’ readings and monitor counts, which are recorded in XML files, are converted to the properties in output MatrixWorkspace’s sample log.

Workflow

Algorithm LoadSpiceXML2DDet is one of a series of algorithms that are implemented to reduced HFIR HB3A data collected from Anger camera. It will be called next to LoadSpiceAscii to load the detector’s reading.

Usage

Example - load a HB3A SPICE .xml file without loading instrument:

# Load data by LoadSpiceXML2DDet()
LoadSpiceXML2DDet(Filename='HB3A_exp355_scan0001_0522.xml',
    OutputWorkspace='s0001_0522', DetectorGeometry='256,256',
    LoadInstrument=False)

# Access output workspace and print out some result
ws = mtd["s0001_0522"]

print("Number of spectrum = {}.".format(ws.getNumberHistograms()))
for i, j in [(0, 0), (255, 255), (136, 140), (143, 140)]:
    print("Y[{:<3}, {:<3}] = {:.5f}".format(i, j, ws.readY(i)[j]))

Output:

Number of spectrum = 256.
Y[0  , 0  ] = 0.00000
Y[255, 255] = 0.00000
Y[136, 140] = 0.00000
Y[143, 140] = 1.00000

Categories: AlgorithmIndex | DataHandling\XML

Source

C++ header: LoadSpiceXML2DDet.h

C++ source: LoadSpiceXML2DDet.cpp