APE-HE NeXus File to JSON Document Converter
Description:
This script is designed to automate the tasks of extracting metadata from NeXus (.nxs
) files generated by the Advanced Photoelectric Effect - High Energy (APE-HE) experiment, and the mapping of extracted metadata to a predifined JSON schema to generate a structured JSON document. The NeXus file is parsed using the Python library H5py
, which allows to efficiently navigate and manipulate HDF5-based files like NeXus.
The current script processes individual NeXus files and zipped NeXus files from APE-HE experiments, transforming the extracted metadata into a structured JSON
format or zipped JSON
files suitable for storage.
Inputs:
- Path to the Schema file (
.json
): A JSON schema that defines the desired structure of the output document. - Path to the NeXus file (
.nxs
) or zipped NeXus files (.zip
): A NeXus file containing experimental metadata and data. - Name of the output file (
.json
) for a single NeXus file input or (.zip
) for zipped NeXus files input: The desired name of the output file where the metadata document will be saved.
Output:
A structured JSON file containing the extracted metadata aligned with the schema.
How to execute the script:
- For single NeXus file:
python NexusMapping_cmdline.py <path_to_schema.json> <path_to_NeXus_file.nxs> <output_document.json>
- For zipped NeXus files:
python NexusMapping_cmdline.py <path_to_schema.json> <path_to_zipped_NeXus_files.zip> <output_document.zip>