How to run a parser¶
You can find a list of all parsers and supported files in the reference.
First you need to have the nomad-lab
pypi package installed. You find more detailed
instructions here:
From the command line¶
You can run NOMAD parsers from the command line interface (CLI). The parse command will automatically match the right parser to your file and run the parser. There are two output formats:
--show-metadata
a json representation of the basic metadata--show-archive
a json representation of the full parse results--preview-plots
: Optionally previews the generated plots.--save-plot-dir <directory>
: Specifies a directory to save the plot images.
Note
If you run into missing dependency errors, you might want to install additional
dependencies via pip install nomad-lab[parsing]
. Only a few parsers require
extra dependencies. Please refer to the parser projects for more details.
To skip the parser matching, i.e. the process that determined which parser fits to
the given file, and state the parser directly, you can use the --parser
argument
to provide a parser name.
To skip the potentially error-prone and depending on your use-case unnecessary
normalization, you can use the --skip-normalizers
argument:
From a python program¶
You can also use the NOMAD parsers within Python, as shown below. This will give you the parse results as metainfo objects to conveniently analyze the results in Python. See metainfo for more details on how to use the metainfo in Python.
# requires: nomad-lab
import sys
from nomad.client import parse, normalize_all
# match and run the parser
archives = parse('path/to/you/file')
# run all normalizers
for archive in archives:
normalize_all(archive)
# get the 'main section' section_run as a metainfo object
section_run = archive.run[0]
# get the same data as JSON serializable Python dict
python_dict = section_run.m_to_dict()