\(\renewcommand\AA{\unicode{x212B}}\)

GenerateLogbook v1

../_images/ImageNotFound.png

Enable screenshots using DOCS_SCREENSHOTS in CMake

Summary

Generates logbook containing meta-data specific to the instrument and technique used to obtain the raw data

Properties

Name

Direction

Type

Default

Description

Directory

Input

string

Mandatory

Path to directory containing data files for logging.

OutputWorkspace

Output

TableWorkspace

Mandatory

The output table workspace.

NumorRange

Input

long list

0,0

Numor range or a list of numors to be analysed in the directory.

Facility

Input

string

ILL

Facility the data belongs to. Allowed values: [’ ‘, ‘ISIS’, ‘HFIR’, ‘SNS’, ‘NCNR’, ‘LENS’, ‘ILL’, ‘SINQ’, ‘SmuS’, ‘LLB’, ‘MLZ’, ‘ANSTO’, ‘HZB’, ‘TEST_LIVE’, ‘ESS’]

Instrument

Input

string

Mandatory

Instrument the data has been collected with.

OutputFile

Input

string

Comma-separated output file. Allowed extensions: [‘.csv’]

OptionalHeaders

Input

string

Names of optional metadata to be included in the logbook. Entries need to be specifiedin the instrument IPF.

CustomEntries

Input

string

Custom NeXus paths for additional metadata to be included in the logbook.

CustomHeaders

Input

string

Names of those additional custom entries.

Description

This is the algorithm that allows to create a TableWorkspace logbook containing metadata specific to the selected instrument and relevant technique, without the need to load NeXus data in Mantid.

There are three levels of entries that can be included in a logbook: default, optional, and custom. The default entries are always included, the optional entries are included when header for that entry is given, through OptionalHeaders, and custom entries are included when the full path in the NeXus file is provided through CustomEntries. The NeXus paths for the default and optional entries are specified in the Instrument Parameter File relevant to the instrument that the data comes from. The header for the custom entry can be specified through CustomHeaders, or not at all. In that case, the name for the custom entry will be derived from its NeXus path.

The files in the directory are expected to be uniquely raw data for the chosen instrument and facility, specified through Facility and Instrument, respectively. The range of files to be logged can be specified through NumorRange property, where both edges of the range are inclusive.

Basic binary arithmetic operations: addition (the only one supported if the data in the entry is a string), subtraction, multiplication and division on entries data are supported. No support is offered for organizing the operations using parentheses or scaling by read data by constant numbers.

Binary operations can also be defined for entries that are not always present in the data, for example in the case of D7 at the ILL, NeXus files contain a varying number of entries, from 1 to 6. There, by defining a sum over all possible entries containing polarisation identifier, it is possible to get to display in the logbook which polarisations are actually contained in the data file.

The logbook can be stored as a CSV file and read outside of the Mantid using spreadsheet software, such as Microsoft Excel.

Usage

Note

To run these usage examples please first download the usage data, and add these to your path. In Mantid this is done using Manage User Directories.

Example - GenerateLogbook for ILL D7 rawdata

data_dirs = config['datasearch.directories'].split(';')
unit_test_data_dir = [p for p in data_dirs if 'UnitTest' in p][0]
data_directory = os.path.abspath(os.path.join(unit_test_data_dir, 'ILL/D7'))

GenerateLogbook(Directory=data_directory,
                OutputWorkspace='d7_logbook', Facility='ILL', Instrument='D7',
                NumorRange=[396990,396991,396993], OptionalHeaders='TOF',
                CustomEntries='entry0/acquisition_mode')
print("Number of numors in the logbook: {}".format(len(mtd['d7_logbook'].column(0))))
print("Number of headers in the logbook: {}".format(len(mtd['d7_logbook'].row(0))))

Output:

Number of numors in the logbook: 3
Number of headers in the logbook: 9

Example - GenerateLogbook for ILL D7 rawdata with binary operations

data_dirs = config['datasearch.directories'].split(';')
unit_test_data_dir = [p for p in data_dirs if 'UnitTest' in p][0]
data_directory = os.path.abspath(os.path.join(unit_test_data_dir, 'ILL/D7'))

GenerateLogbook(Directory=data_directory,
                OutputWorkspace='d7_logbook', Facility='ILL', Instrument='D7',
                NumorRange="396990:396993", CustomHeaders='wavelength',
                CustomEntries='/entry0/D7/POL/actual_state+/entry0/D7/POL/actual_stateB1B2')
print("Number of numors in the logbook: {}".format(len(mtd['d7_logbook'].column(0))))
print("Number of headers in the logbook: {}".format(len(mtd['d7_logbook'].row(0))))

Output:

Number of numors in the logbook: 3
Number of headers in the logbook: 8

Categories: AlgorithmIndex | Utility

Source

Python: GenerateLogbook.py