Saves a focused data set into a three column GSAS format containing X_i, Y_i*step, and E_I*step. Exclusively for the crystallography package GSAS and data needs to be in time-of-flight. For data where the focusing routine has generated several spectra (for example, multi-bank instruments), the option is provided for saving all spectra into a single file, separated by headers, or into several files that will be named "workspaceName_"+workspace_index_number.
From the GSAS manual a description of the format options:
- If BINTYP is 'SLOG' then the neutron TOF data was collected in constant ∆T/T steps. BCOEF(1) is the initial TOF in μsec, and BCOEF(3) is the value of ∆T/T used in the data collection. BCOEF(2) is a maximum TOF for the data set. BCOEF(4) is zero and ignored.
- If BINTYP equals 'RALF' then the data was collected at one of the TOF neutron diffractometers at the ISIS Facility, Rutherford-Appleton Laboratory. The width of the time bins is constant for a section of the data at small values of TOF and then varies (irregularly) in pseudoconstant ∆T/T steps. In this case BCOEF(1) is the starting TOF in μsec*32, BCOEF(2) is the width of the first step in μsec*32, BCOEF(3) is the start of the log scaled step portion of the data in μsec*32 and BCOEF(4) is the resolution to be used in approximating the size of each step beyond BCOEF(3).
The format is limited to saving 99 spectra in total. Trying to save more will generate an error.
Example - a basic example using SaveGSS.
ExSaveGSSimple
import os
ws = CreateSampleWorkspace() ws = ExtractSingleSpectrum(ws, WorkspaceIndex=0) file_name = "myworkspace.ascii" SaveGSS(ws, file_name)
path = os.path.join(config['defaultsave.directory'], file_name) print os.path.isfile(path)
Output:
ExSaveGSSimple
True
ExSaveGSSimple
import os def removeFiles(files): for ws in files: try: path = os.path.join(config['defaultsave.directory'], ws) os.remove(path) except: pass
removeFiles(file_name)
Example - an example using SaveGSS with additonal options.
ExSaveGSSOptions
import os
ws = CreateSampleWorkspace() #GSAS file cannot have more than 99 entries ws = CropWorkspace(ws, StartWorkspaceIndex=0, EndworkspaceIndex=98) file_name = "myworkspace.ascii" SaveGSS(ws, file_name, SplitFiles=False, ExtendedHeader=True, UseSpectrumNumberAsBankID=True)
path = os.path.join(config['defaultsave.directory'], file_name) print os.path.isfile(path)
Output:
ExSaveGSSOptions
True
ExSaveGSSOptions
import os def removeFiles(files): for ws in files: try: path = os.path.join(config['defaultsave.directory'], ws) os.remove(path) except: pass
removeFiles(file_name)