\(\renewcommand\AA{\unicode{x212B}}\)
SaveRKH v1¶
Summary¶
Save a MatrixWorkspace to a file in the ISIS RKH format (for 1D or 2D data).
See Also¶
Properties¶
Name |
Direction |
Type |
Default |
Description |
---|---|---|---|---|
InputWorkspace |
Input |
Mandatory |
The name of the workspace to save |
|
Filename |
Input |
string |
Mandatory |
The name to use when saving the file. Allowed extensions: [‘.txt’, ‘.q’, ‘.dat’] |
Append |
Input |
boolean |
True |
If true and Filename already exists, append, else overwrite |
Description¶
Saves the given workspace to a file which will be formatted in one of the historic ISIS SANS (‘COLETTE’/‘FISH’) data formats devised by Richard K Heenan.
1D or 2D workspaces may be saved.
If a 1D workspace is ‘horizontal’ (a single spectrum) then the first column in the three column output will contain the X values of the spectrum (giving the bin centre if histogram data). For a ‘vertical’ (single column) 1D workspace, the first column of the file will contain the spectrum number.
The created file can be reloaded using the LoadRKH v1 algorithm.
Usage¶
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 = " + str(in_ws.readY(0)))
Output:
Contents of the file = [8. 4. 9. 7.]
Categories: AlgorithmIndex | DataHandling\Text
Source¶
C++ header: SaveRKH.h
C++ source: SaveRKH.cpp