\(\renewcommand\AA{\unicode{x212B}}\)
Table of Contents
Name | Direction | Type | Default | Description |
---|---|---|---|---|
Filename | Input | string | Mandatory | Name of the RKH file to load. Allowed extensions: [‘.txt’, ‘.q’, ‘.dat’] |
OutputWorkspace | Output | MatrixWorkspace | Mandatory | The name to use for the output workspace |
FirstColumnValue | Input | string | Wavelength | Only used for 1D files, the units of the first column in the RKH file (default Wavelength). Allowed values: [‘AtomicDistance’, ‘Degrees’, ‘DeltaE’, ‘DeltaE_inFrequency’, ‘DeltaE_inWavenumber’, ‘dSpacing’, ‘dSpacingPerpendicular’, ‘Empty’, ‘Energy’, ‘Energy_inWavenumber’, ‘Label’, ‘Momentum’, ‘MomentumTransfer’, ‘Phi’, ‘QSquared’, ‘SpinEchoLength’, ‘SpinEchoTime’, ‘Temperature’, ‘Time’, ‘TOF’, ‘Wavelength’, ‘SpectrumNumber’] |
Loads the given file in the RKH text format, which can be a file with three columns of numbers. If the FirstColumnValue is a recognised Mantid unit the workspace is created with just one spectrum. Alteratively if FirstColumnValue is set to ‘SpectrumNumber’ then the workspace can have many spectra with the spectrum Numbers equal to the first column in the file.
Example - Save/Load “Roundtrip”
import os
import numpy
# Create dummy workspace.
dataX = [1,2,3,4,5]
dataY = [8,4,9,7]
dataE = [2,1,1,3]
out_ws = CreateWorkspace(dataX, dataY, dataE, UnitX="MomentumTransfer")
file_path = os.path.join(config["defaultsave.directory"], "example.out")
# Do a "roundtrip" of the data.
SaveRKH(out_ws, file_path)
in_ws = LoadRKH(file_path)
print("Contents of the file = {}".format(in_ws.readY(0)))
Output:
Contents of the file = [ 8. 4. 9. 7.]
Categories: AlgorithmIndex | DataHandling\Text | SANS\DataHandling