Table of Contents
Name | Direction | Type | Default | Description |
---|---|---|---|---|
InputWorkspace | Input | MatrixWorkspace | 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 |
Saves the the given workspace to a file which will be formatted in one of the LOQ data formats. 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.
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: Algorithms | DataHandling\Text