\(\renewcommand\AA{\unicode{x212B}}\)
Table of Contents
Name | Direction | Type | Default | Description |
---|---|---|---|---|
InputWorkspace | Input | MatrixWorkspace | Mandatory | Input workspace containing the sample log information. |
OutputFilename | Input | string | Mandatory | Output file of the experiment log. Allowed extensions: [‘.txt, .csv’] |
FileMode | Input | string | append | Optional to create a new file or append to an existing file. Allowed values: [‘append’, ‘fastappend’, ‘new’] |
SampleLogNames | Input | str list | Sample log names. | |
SampleLogTitles | Input | str list | Log sample titles as file header. | |
SampleLogOperation | Input | str list | Operation on each log, including None (as no operation), min, max, average, sum and “0”. | |
FileFormat | Input | string | tab | Output file format. ‘tab’ format will insert a tab between 2 adjacent values; ‘comma’ will put a , instead. With this option, the posfix of the output file is .csv automatically. Allowed values: [‘tab’, ‘comma (csv)’] |
OrderByTitle | Input | string | Log file will be ordered by the value of this title from low to high. | |
RemoveDuplicateRecord | Input | boolean | False | Coupled with OrderByTitle, duplicated record will be removed. |
OverrideLogValue | Input | str list | List of paired strings as log title and value to override values from workspace. | |
TimeZone | Input | string | America/New_York | Allowed values: [‘UTC’, ‘America/New_York’, ‘Asia/Shanghai’, ‘Australia/Sydney’, ‘Europe/London’, ‘GMT+0’, ‘Europe/Paris’, ‘Europe/Copenhagen’] |
Algorithm ExportExperimentLog obtains run information, sample information and sample log information from a MatrixWorkspace and write them to a csv file.
There are 3 modes to write the experiment log file.
2. “appendfast”: A line of experiment log information will be appended to an existing file;
3. “append”: A line of experiment log information will be appended to an existing file;
If there is any sample log specified in the properites but does not exist in the workspace, a zero float value will be put to the experiment log information line, as the preference of instrument scientist.
If the type of a sample log is TimeSeriesProperty, it must be one of the following 5 types.
If the type of a sample log is string and in fact it is a string for time, then there will an option as
Otherwise, there is no operation required. For example, log ‘duration’ or ‘run_number’ does not have any operation on its value. An empty string will serve for them in property ‘SampleLogOperation’.
There are two types of output file formats that are supported. They are csv (comma separated) file and tsv (tab separated) file. The csv file must have an extension as “.csv”. If a user gives the name of a log file, which is in csv format, does not have an extension as .csv, the algorithm will correct it automatically.
The time stamps of sample logs are recorded as UTC time. Some users wants to see the exported sample log as the neutron facility’s local time. So the input property ‘TimeZone’ is for this purpose.
Example - Export several experiment logs to a csv file:
import os
nxsfilename = "HYS_11092_event.nxs"
wsname = "HYS_11092_event"
defaultdir = config["default.savedirectory"]
if defaultdir == "":
defaultdir = config["defaultsave.directory"]
savefile = os.path.join(defaultdir, "testlog.txt")
Load(Filename = nxsfilename,
OutputWorkspace = wsname,
MetaDataOnly = True,
LoadLogs = True)
ExportExperimentLog(
InputWorkspace = wsname,
OutputFilename = savefile,
FileMode = "new",
SampleLogNames = "run_start, run_title",
SampleLogTitles = "AA, BB",
SampleLogOperation = "None, None",
FileFormat = "tab",
TimeZone = "America/New_York")
print("File is created = {}".format(os.path.exists(savefile)))
# Get lines of file
sfile = open(savefile, 'r')
slines = sfile.readlines()
sfile.close()
print("Number of lines in File = {}".format(len(slines)))
Output:
File is created = True
Number of lines in File = 2
Categories: AlgorithmIndex | DataHandling\Logs
Python: ExportExperimentLog.py