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

SaveHKL v1

Summary

Save a PeaksWorkspace to a ASCII .hkl file.

See Also

LoadHKL, SaveHKLCW

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

PeaksWorkspace

Mandatory

An input PeaksWorkspace.

ScalePeaks

Input

number

1

Multiply FSQ and sig(FSQ) by scaleFactor

MinDSpacing

Input

number

0

Minimum d-spacing (Angstroms)

MinWavelength

Input

number

0

Minimum wavelength (Angstroms)

MaxWavelength

Input

number

100

Maximum wavelength (Angstroms)

AppendFile

Input

boolean

False

Append to file if true. Use same corrections as file. If false, new file (default).

ApplyAnvredCorrections

Input

boolean

False

Apply anvred corrections to peaks if true. If false, no corrections during save (default).

LinearScatteringCoef

Input

number

Optional

Linear scattering coefficient in 1/cm if not set with SetSampleMaterial

LinearAbsorptionCoef

Input

number

Optional

Linear absorption coefficient at 1.8 Angstroms in 1/cm if not set with SetSampleMaterial

Radius

Input

number

Optional

Radius of the sample in centimeters

PowerLambda

Input

number

4

Power of lambda

SpectraFile

Input

string

Spectrum data read from a spectrum file. Allowed extensions: [‘.dat’]

Filename

Input

string

Mandatory

Path to an hkl file to save. Allowed extensions: [‘.hkl’]

SortBy

Input

string

Sort the histograms by bank, run number or both (default). Allowed values: [‘Bank’, ‘RunNumber’, ‘’]

MinIsigI

Input

number

Optional

The minimum I/sig(I) ratio

WidthBorder

Input

number

Optional

Width of border of detectors

MinIntensity

Input

number

Optional

The minimum Intensity

OutputWorkspace

Output

PeaksWorkspace

SaveHKLOutput

Output PeaksWorkspace

HKLDecimalPlaces

Input

number

Optional

Number of decimal places for fractional HKL. Default is integer HKL.

DirectionCosines

Input

boolean

False

Extra columns (22 total) in file if true for direction cosines. If false, original 14 columns (default).

UBFilename

Input

string

Path to an ISAW-style UB matrix text file only needed for DirectionCosines if workspace does not have lattice. Allowed extensions: [‘.mat’, ‘.ub’, ‘.txt’]

Description

SaveHKL outputs the peaks with corrections applied in a format that works successfully in GSAS and SHELX. Peaks that have not been integrated and also peaks that were not indexed are removed.

hklFile.write(‘%4d%4d%4d%8.2f%8.2f%4d%8.4f%7.4f%7d%7d%7.4f%4d%9.5f%9.4f\n’% (H, K, L, FSQ, SIGFSQ, hstnum, WL, TBAR, CURHST, SEQNUM, TRANSMISSION, DN, TWOTH, DSP))

HKL is flipped by -1 due to different q convention in ISAW vs Mantid.

FSQ = integrated intensity of peak (scaled)

SIGFSQ = sigma from integrating peak

hstnum = number of sample orientation (starting at 1)

WL = wavelength of peak

TBAR = output of absorption correction (-log(transmission)/mu)

CURHST = run number of sample

SEQNUM = peak number (unique number for each peak in file)

TRANSMISSION = output of absorption correction (exp(-mu*tbar))

DN = detector bank number

TWOTH = two-theta scattering angle

DSP = d-Spacing of peak (Angstroms)/TR

Last line must have all 0’s

Direction cosines are required for certain absorption and extinction corrections. They are calculated according to [1] and are the dot products of the scattered and reverse incident beam directions with the direction of the reciprocal lattice vectors. The components are interleaved starting with the reverse incident part.

Usage

Example - a simple example of running SaveHKL.

import os

path = os.path.join(os.path.expanduser("~"), "MyPeaks.hkl")

#load a peaks workspace from file
peaks = LoadIsawPeaks(Filename=r'Peaks5637.integrate')
SaveHKL(peaks, path)

print(os.path.isfile(path))

Output:

True

Example - an example of running SaveHKL with sorting and filtering options.

import os

#load a peaks workspace from file
peaks = LoadIsawPeaks(Filename=r'Peaks5637.integrate')
print("Number of peaks in table {}".format(peaks.rowCount()))

path = os.path.join(os.path.expanduser("~"), "MyPeaks.hkl")
SaveHKL(peaks, path, MinWavelength=0.5, MaxWavelength=2, MinDSpacing=0.2, SortBy='Bank')

peaks = LoadHKL(path)
print("Number of peaks in table {}".format(peaks.rowCount()))

Output:

Number of peaks in table 434
Number of peaks in table 234

Example - SaveHKL with shape from SetSample

import os
path = os.path.join(os.path.expanduser("~"), "MyPeaks.hkl")

# load a peaks workspace from file
peaks = LoadIsawPeaks(Filename=r'SXD23767.peaks')
SetSample(peaks,
          Geometry={'Shape': 'Cylinder', 'Height': 4.0,
                    'Radius': 0.8,
                    'Center': [0.,0.,0.]},
          Material={'ChemicalFormula': 'V', 'SampleNumberDensity': 0.1})
SaveHKL(peaks, path)
print(os.path.isfile(path))

Output:

True

References

Categories: AlgorithmIndex | Crystal\DataHandling | DataHandling\Text

Source

C++ header: SaveHKL.h

C++ source: SaveHKL.cpp