Skip to content

API for command line tools

pynxtools supports a number of command line applications. This page provides documentation for their current API.

Data conversion

Note that simply calling dataconverter defaults to dataconverter convert.

dataconverter

Usage:

dataconverter [OPTIONS] COMMAND [ARGS]...

Options:

Name Type Description Default
--help boolean Show this message and exit. False

Subcommands

  • convert: This command allows you to use the converter functionality of the dataconverter.
  • generate-template: Generates and prints a template to use for your nxdl.
  • get-readers: Prints a list of all installed readers.

dataconverter convert

This command allows you to use the converter functionality of the dataconverter.

Usage:

dataconverter convert [OPTIONS] [FILES]...

Options:

Name Type Description Default
--input-file text Deprecated: Please use the positional file arguments instead. The path to the input data file to read. Repeat for more than one file. default=[] This option is required if no '--params-file' is supplied. []
--reader choice (example | json_map | json_yml | multi) The reader to use. Examples are json_map or readers from a pynxtools plugin. default='json_map' This option is required if no '--params-file' is supplied. json_map
--nxdl text The name of the NeXus application definition file to use without the extension nxdl.xml. This option is required if no '--params-file' is supplied. None
--output text The path to the output NeXus file to be generated. default='output.nxs' output.nxs
--params-file filename Allows to pass a .yaml file with all the parameters the converter supports. None
--append boolean Appends instance data to the given file if the file already exists.Will prevent an overwriting of existent data and adding of new NXentry instances.If True, will skip the validation whatever irrespective if --skip-verify is passed. False
--ignore-undocumented boolean Ignore all undocumented concepts during validation. False
--fail boolean Fail conversion and don't create an output file if the validation fails. False
--skip-verify boolean Skips the verification routine during conversion.When --append is used the verification is always skippedirrespective if --skip-verify is used or not. False
--mapping text Takes a .mapping.json file and converts data from given input files. Deprecated. Will be removed in a future release. The --config flag can be used instead. Sentinel.UNSET
-c, --config file A json config file for the reader None
--help boolean Show this message and exit. False

dataconverter generate-template

Generates and prints a template to use for your nxdl.

Usage:

dataconverter generate-template [OPTIONS]

Options:

Name Type Description Default
--nxdl text The name of the NeXus application definition file to use without extension. For example: NXmpes _required
--required boolean Use this flag to only get the required template. False
--pythonic boolean Prints a valid Python dictionary instead of JSON False
--output path Writes the output into the filepath provided. Sentinel.UNSET
--help boolean Show this message and exit. False

dataconverter get-readers

Prints a list of all installed readers.

Usage:

dataconverter get-readers [OPTIONS]

Options:

Name Type Description Default
--help boolean Show this message and exit. False

NeXus file validation

validate_nexus

Validates a NeXus HDF5 file.

FILE: The path to the NeXus file to validate.

Usage:

validate_nexus [OPTIONS] FILE

Options:

Name Type Description Default
--ignore-undocumented boolean Ignore all undocumented concepts during validation. False
--help boolean Show this message and exit. False

NeXus annotator

read_nexus

Functionality to extract documentation and concept definition information about the individual parts of a NeXus/HDF5 file.

Usage:

read_nexus [OPTIONS]

Options:

Name Type Description Default
-f, --nexus-file text NeXus file with extension .nxs. None
-d, --documentation text Definition path in nexus output (.nxs) file. Returns debug log relevant with that definition path. Example input: /entry/data/delays None
-c, --concept text Concept path from application definition file (.nxdl.xml). Finds out all the available concept definition (IS-A relation) for a given concept path. Example input: /NXarpes/ENTRY/INSTRUMENT/analyser None
--help boolean Show this message and exit. False

NOTE: Only one option from (-d and -c) is acceptable.

ELN generation

generate_eln

Helper tool for generating ELN files in YAML format.

Usage:

generate_eln [OPTIONS]

Options:

Name Type Description Default
--nxdl text Name of NeXus definition without extension (.nxdl.xml). Sentinel.UNSET
--skip-top-levels integer To skip the level of parent hierarchy level. For example, by default the part Entry[ENTRY] from /Entry[ENTRY]/Instrument[INSTRUMENT]/... will be skipped. 0
--output-file text Name of file that is needed to generated output file. None
--eln-type choice (reader | schema) Choose a type of ELN output (reader or schema). eln
--optionality choice (required | recommended | optional) Level of requiredness to generate. If any of ('required', 'recommended', 'optional', only those concepts matching this requiredness level are created. required
--filter-file text JSON configuration file to filter NeXus concepts (based on the presence of the '@eln' keyword). This is a positive filter, i.e., all concepts in the filter file will be included in the ELN. None
--help boolean Show this message and exit. False