Package: castep-outputs
Parser for CASTEP output filescastep_outputsparses the output files ofcastepinto a standard form and is able to subsequently
dump the processed data into a standard format.InstallTo installcastep_outputssimply run:pip install castep_outputsTo check it is installed run:python -m castep_outputs -hDependenciescastep_outputsis designed to have no external dependencies beyond the
standard library, however, it is possible to use eitherPyYAMLorruamel.yamlto dump in the YAML format.Command-lineWhen run as a commandline tool, it attempts to find all files for the given
seedname, filtered byincargs (default: all). Explicit files can be passed
using longname arguments. castep_outputs can parse most human-readable castep
outputs including:.castep,.param,.cell,.geom,.md,.bands,.hug,.phonon_dos,.efield,.xrd_sf,.elf_fmt,.chdiff_fmt,.pot_fmt,.den_fmt,.elastic,.ts,.magres.to run in basic mode:python -m castep_outputs seednameWhich will attempt to detect all found files and dump a.jsonto
stdout, ready for piping.python -m castep_outputs --inc-castep --inc-param seednameWill parse only theseedname.castepandseedname.paramfiles if
found.python -m castep_outputs seedname.castepWill parse the single named file and again dump a.jsonto stdout.python -m castep_outputs --castep seedname.paramWill attempt to parse the fileseedname.paramas though it were a.castepfile. While not ordinarily useful it can help with manually renamed
files.python -m castep_outputs -o my_file.yaml -f yaml seedname.castepWill parseseedname.castep, dump it tomy_file.yamlinyamlformat
using thePyYAMLengine.As a moduleimportingcastep_outputsdirectly puts all of the parsers directly
into your local namespace.The simplest method to usecastep_outputsin a tool is to use theparse_singlemethod which attempts to determine the parser from the file
extension.import castep_outputs

my_dict = parse_single('my_file.castep')If you need a specific parser rather than by extension it is possible to pass
them as the second argument, or call them directly.import castep_outputs

my_dict = parse_single('my_file', parse_castep_file)

with open('my_file', 'r', encoding='utf-8') as inp:
    my_dict = parse_castep_file(inp)It is recommended that you useparse_singleas it uses special file-handling
to give better diagnostics if it fails. It is possible to enable more detailed
logging via theloggingmodule:import castep_outputs
import logging

my_dict = parse_single('my_file', loglevel=logging.INFO)The available parsing functions are:parse_castep_fileparse_cell_param_fileparse_param_fileparse_cell_fileparse_md_geom_fileparse_md_fileparse_geom_fileparse_bands_fileparse_hug_fileparse_phonon_dos_fileparse_efield_fileparse_xrd_sf_fileparse_elf_fmt_fileparse_chdiff_fmt_fileparse_pot_fmt_fileparse_den_fmt_fileparse_elastic_fileparse_ts_fileparse_tddft_fileparse_magres_fileWhich return processedlists ofdicts of data ready for use
in other applications.Full usageusage: castep_outputs [-h] [-V] [-L {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-o OUTPUT]
                      [-f {json,ruamel,yaml,pprint,print}] [-t] [-A] [--inc-castep] [--inc-cell] [--inc-param]
                      [--inc-geom] [--inc-md] [--inc-bands] [--inc-hug] [--inc-phonon_dos] [--inc-efield]
                      [--inc-xrd_sf] [--inc-elf_fmt] [--inc-chdiff_fmt] [--inc-pot_fmt] [--inc-den_fmt]
                      [--inc-elastic] [--inc-ts] [--inc-magres] [--inc-tddft] [--castep [CASTEP ...]]
                      [--cell [CELL ...]] [--param [PARAM ...]] [--geom [GEOM ...]] [--md [MD ...]]
                      [--bands [BANDS ...]] [--hug [HUG ...]] [--phonon_dos [PHONON_DOS ...]]
                      [--efield [EFIELD ...]] [--xrd_sf [XRD_SF ...]] [--elf_fmt [ELF_FMT ...]]
                      [--chdiff_fmt [CHDIFF_FMT ...]] [--pot_fmt [POT_FMT ...]] [--den_fmt [DEN_FMT ...]]
                      [--elastic [ELASTIC ...]] [--ts [TS ...]] [--magres [MAGRES ...]] [--tddft [TDDFT ...]]
                      ...

Attempts to find all files for seedname, filtered by `inc` args (default: all). Explicit files can be passed
using longname arguments. castep_outputs can parse most human-readable castep outputs including: .castep, .cell,
.param, .geom, .md, .bands, .hug, .phonon_dos, .efield, .xrd_sf, .elf_fmt, .chdiff_fmt, .pot_fmt, .den_fmt,
.elastic, .ts, .magres, .tddft

positional arguments:
  seedname              Seed name for data

options:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  -L {DEBUG,INFO,WARNING,ERROR,CRITICAL}, --log {DEBUG,INFO,WARNING,ERROR,CRITICAL}
                        Verbose output
  -o OUTPUT, --output OUTPUT
                        File to write output, default: screen
  -f {json,ruamel,yaml,pprint,print}, --out-format {json,ruamel,yaml,pprint,print}
                        Output format
  -t, --testing         Set testing mode to produce flat outputs
  -A, --inc-all         Extract all available information
  --inc-castep          Extract .castep information
  --inc-cell            Extract .cell information
  --inc-param           Extract .param information
  --inc-geom            Extract .geom information
  --inc-md              Extract .md information
  --inc-bands           Extract .bands information
  --inc-hug             Extract .hug information
  --inc-phonon_dos      Extract .phonon_dos information
  --inc-efield          Extract .efield information
  --inc-xrd_sf          Extract .xrd_sf information
  --inc-elf_fmt         Extract .elf_fmt information
  --inc-chdiff_fmt      Extract .chdiff_fmt information
  --inc-pot_fmt         Extract .pot_fmt information
  --inc-den_fmt         Extract .den_fmt information
  --inc-elastic         Extract .elastic information
  --inc-ts              Extract .ts information
  --inc-magres          Extract .magres information
  --inc-tddft           Extract .tddft information
  --castep [CASTEP ...]
                        Extract from CASTEP as .castep type
  --cell [CELL ...]     Extract from CELL as .cell type
  --param [PARAM ...]   Extract from PARAM as .param type
  --geom [GEOM ...]     Extract from GEOM as .geom type
  --md [MD ...]         Extract from MD as .md type
  --bands [BANDS ...]   Extract from BANDS as .bands type
  --hug [HUG ...]       Extract from HUG as .hug type
  --phonon_dos [PHONON_DOS ...]
                        Extract from PHONON_DOS as .phonon_dos type
  --efield [EFIELD ...]
                        Extract from EFIELD as .efield type
  --xrd_sf [XRD_SF ...]
                        Extract from XRD_SF as .xrd_sf type
  --elf_fmt [ELF_FMT ...]
                        Extract from ELF_FMT as .elf_fmt type
  --chdiff_fmt [CHDIFF_FMT ...]
                        Extract from CHDIFF_FMT as .chdiff_fmt type
  --pot_fmt [POT_FMT ...]
                        Extract from POT_FMT as .pot_fmt type
  --den_fmt [DEN_FMT ...]
                        Extract from DEN_FMT as .den_fmt type
  --elastic [ELASTIC ...]
                        Extract from ELASTIC as .elastic type
  --ts [TS ...]         Extract from TS as .ts type
  --magres [MAGRES ...]
                        Extract from MAGRES as .magres type
  --tddft [TDDFT ...]   Extract from TDDFT as .tddft typeCurrent Parsers:.castep.cell.param.geom.md.bands.hug.phonon_dos.efield.xrd_sf.elf_fmt.chdiff_fmt.pot_fmt.den_fmt.elastic.ts.magres.tddftCurrent dumpers:jsonruamel.yamlpyyamlprintpprint