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

SelectNexusFilesByMetadata v1

../_images/ImageNotFound.png

Enable screenshots using DOCS_SCREENSHOTS in CMake

Summary

Filters nexus files by metadata criteria

Properties

Name

Direction

Type

Default

Description

FileList

Input

list of str lists

Mandatory

List of input files. Allowed values: [‘nxs’, ‘hdf’]

NexusCriteria

Input

string

Logical expresion for metadata criteria using python syntax. Provide full absolute names for nexus entries enclosed with $ symbol from both sides.

Result

Output

string

Comma separated list of the fully resolved file names satisfying the given criteria.

Description

This algorithm returns the nexus (HDF) files in the given files list that satisfy the specified criteria. This is done without actually loading the data, but just the needed metadata. Input files need to exist and be specified following the Mantid rules in MultipleFileProperty. Criteria could be any python logical expression involving the nexus entry names enclosed with $ symbol. Arbitrary number of criteria can be combined. The metadata entry should contain only one element. Note, that if the entry is of string type, string comparison will be performed. As a result, a string of the fully resolved file names satisfying the criteria (and following the same algebra as in input, i.e. + or ,) will be returned. Note, that this algorithm requires h5py package installed.

Example - Running SelectNexusFilesByMetadata

res = SelectNexusFilesByMetadata(FileList='INTER00013460,13463,13464.nxs',
                                 NexusCriteria='$raw_data_1/duration$ > 1000 or $raw_data_1/good_frames$ > 10000')
print("res is now a string containing comma separated paths of {} file names that satisfy the criteria".format(len(res.split(','))))

Output:

res is now a string containing comma separated paths of 2 file names that satisfy the criteria

Categories: AlgorithmIndex | DataHandling\Nexus

Source

Python: SelectNexusFilesByMetadata.py