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

SaveIsawUB v1

Summary

Save a UB matrix and lattice parameters from a workspace to an ISAW-style ASCII file.

See Also

LoadIsawUB

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

Workspace

Mandatory

An input workspace containing the orientation matrix.

Filename

Input

string

Mandatory

Path to an ISAW-style UB matrix text file. Allowed extensions: [‘.mat’, ‘.ub’, ‘.txt’]

RotateByGoniometerMatrix

Input

boolean

False

If True this option will rotate the UB by the goniometer rotation, R - i.e. will save R*UB. If the InputWorkspace is a PeaksWorkspace then the goniometer matrix will be taken from the first peak.

Description

This saves a workspace’s UB matrix to an ISAW-style UB matrix text file.

The resulting file can be loaded again into another workspace by using the LoadIsawUB v1 algorithm.

The matrix saved is the transpose of the UB matrix. The UB matrix maps the column vector (h,k,l ) to the column vector (q’x,q’y,q’z). |Q’|=1/dspacing and its coordinates are a right-hand coordinate system where x is the beam direction and z is vertically upward. (IPNS convention)

Usage

#A workspace with some UB matrix
w = CreateSingleValuedWorkspace()
SetUB(w, 2, 4, 5, 90, 90, 90, "0,0,1", "1,0,0")
#run the algorithm
import mantid
filename = mantid.config.getString("defaultsave.directory") + "saveIsawUBTest.mat"
SaveIsawUB(w, filename)

#check if the correct results are written in the file
f = open(filename, "r")
x, y, z = map(float, f.readline().split())
if (x==0) and (y==0.5) and (z==0):
    print("The first line is 0 0.5 0")
x, y, z = map(float, f.readline().split())
if (x==0) and (y==0) and (z==0.25):
    print("The second line is 0 0 0.25")
x, y, z = map(float, f.readline().split())
if (x==0.2) and (y==0) and (z==0):
    print("The third line is 0.2 0 0")
f.close()

Output:

The first line is 0 0.5 0
The second line is 0 0 0.25
The third line is 0.2 0 0

Categories: AlgorithmIndex | Crystal\DataHandling | DataHandling\Isaw | Crystal\UBMatrix

Source

C++ header: SaveIsawUB.h

C++ source: SaveIsawUB.cpp