abiopen.py

AbiPy provides python objects associated to several Abinit output files. These objects implement methods to analyze and plot the results. The examples in our AbiPy Gallery use this API to plot data with matplotlib.

The abiopen.py script provides a handy interface to the AbiPy objects. It can be used to open Abinit files directly in the ipython shell or inside a jupyter notebook and interact with the associated object (called abifile in the ipython terminal). The syntax of the script is:

abiopen.py FILE [options]

where FILE is one of the files supported by AbiPy (usually in netcdf format but other files are supported as well e.g. Abinit input and output files in text format). By default abiopen starts an ipython session and the user can interact with the abifile and invoke its methods.

Alternatively, it is possible to generate automatically a jupyter notebook with the -nb option e.g.:

abiopen.py out_FATBANDS.nc -nb

will produce a notebook to visualize the electronic fatbands inside your default web browser.

Use the -p option if you just want to get information on the file without opening it, e.g.:

abiopen.py out_GSR.nc -p

or the -e (--expose) to generate matplotlib plots automatically:

abiopen.py out_GSR.nc -e -sns=talk

seaborn plot style and settings can be changed from the command line interface with the -sns option

The script uses the file extension to decide what to do with the file and the type of python object that should be instantiated. The list of supported file extensions is obtained with:

$ abiopen.py --help
usage: abiopen.py [-h] [--loglevel LOGLEVEL] [-V] [-v] [-nb] [--foreground]
                  [-p] [-e] [-s] [-t SLIDE_TIMEOUT] [-sns [SEABORN]]
                  [-mpl MPL_BACKEND]
                  filepath

positional arguments:
  filepath              File to open. See table below for the list of
                        supported extensions.

optional arguments:
  -h, --help            show this help message and exit
  --loglevel LOGLEVEL   Set the loglevel. Possible values: CRITICAL, ERROR
                        (default), WARNING, INFO, DEBUG
  -V, --version         show program's version number and exit
  -v, --verbose         verbose, can be supplied multiple times to increase
                        verbosity
  -nb, --notebook       Open file in jupyter notebook
  --foreground          Run jupyter notebook in the foreground.
  -p, --print           Print python object and return.
  -e, --expose          Open file and generate matplotlib figures
                        automatically by calling expose method.
  -s, --slide-mode      Iterate over figures. Expose all figures at once if
                        not given on the CLI.
  -t SLIDE_TIMEOUT, --slide-timeout SLIDE_TIMEOUT
                        Close figure after slide-timeout seconds (only if
                        slide-mode). Block if not specified.
  -sns [SEABORN], --seaborn [SEABORN]
                        Use seaborn settings. Accept value defining context in
                        ("paper", "notebook", "talk", "poster"). Default:
                        paper
  -mpl MPL_BACKEND, --mpl-backend MPL_BACKEND
                        Set matplotlib interactive backend. Possible values:
                        GTKAgg, GTK3Agg, GTK, GTKCairo, GTK3Cairo, WXAgg, WX,
                        TkAgg, Qt4Agg, Qt5Agg, macosx.See also:
                        https://matplotlib.org/faq/usage_faq.html#what-is-a-
                        backend.

Usage example:

    abiopen.py FILE        => Open file in ipython shell.
    abiopen.py FILE -nb    => Generate jupyter notebook.
    abiopen.py FILE -p     => Print info on object to terminal.
    abiopen.py FILE -e     => Generate matplotlib figures automatically.
                              Use -sns to activate seaborn settings.

`FILE` is any file supported by abipy/pymatgen e.g Netcdf files, Abinit input, POSCAR, xsf ...
Use `-v` to increase verbosity level (can be supplied multiple times e.g -vv).

File extensions supported:
Extension          Class
-----------------  -----------------------------------------------------
.abi               <class 'abipy.abio.abivars.AbinitInputFile'>
.in                <class 'abipy.abio.abivars.AbinitInputFile'>
.abo               <class 'abipy.abio.outputs.AbinitOutputFile'>
.out               <class 'abipy.abio.outputs.AbinitOutputFile'>
.log               <class 'abipy.abio.outputs.AbinitLogFile'>
.cif               <class 'abipy.core.structure.Structure'>
POSCAR             <class 'abipy.core.structure.Structure'>
.cssr              <class 'abipy.core.structure.Structure'>
.cube              <class 'abipy.core.mixins.CubeFile'>
anaddb.nc          <class 'abipy.dfpt.anaddbnc.AnaddbNcFile'>
DEN                <class 'abipy.electrons.denpot.DensityFortranFile'>
.psp8              <class 'pymatgen.io.abinit.pseudos.Pseudo'>
.pspnc             <class 'pymatgen.io.abinit.pseudos.Pseudo'>
.fhi               <class 'pymatgen.io.abinit.pseudos.Pseudo'>
JTH.xml            <class 'pymatgen.io.abinit.pseudos.Pseudo'>
.wout              <class 'abipy.wannier90.wout.WoutFile'>
COHPCAR.lobster    <class 'abipy.electrons.lobster.CoxpFile'>
COOPCAR.lobster    <class 'abipy.electrons.lobster.CoxpFile'>
ICOHPLIST.lobster  <class 'abipy.electrons.lobster.ICoxpFile'>
DOSCAR.lobster     <class 'abipy.electrons.lobster.LobsterDoscarFile'>
GSR.nc             <class 'abipy.electrons.gsr.GsrFile'>
DEN.nc             <class 'abipy.electrons.denpot.DensityNcFile'>
OUT.nc             <class 'abipy.abio.outputs.OutNcFile'>
DDK.nc             <class 'abipy.electrons.ddk.DdkFile'>
VHA.nc             <class 'abipy.electrons.denpot.VhartreeNcFile'>
VXC.nc             <class 'abipy.electrons.denpot.VxcNcFile'>
VHXC.nc            <class 'abipy.electrons.denpot.VhxcNcFile'>
POT.nc             <class 'abipy.electrons.denpot.PotNcFile'>
WFK.nc             <class 'abipy.waves.wfkfile.WfkFile'>
HIST.nc            <class 'abipy.dynamics.hist.HistFile'>
PSPS.nc            <class 'abipy.electrons.psps.PspsFile'>
DDB                <class 'abipy.dfpt.ddb.DdbFile'>
PHBST.nc           <class 'abipy.dfpt.phonons.PhbstFile'>
PHDOS.nc           <class 'abipy.dfpt.phonons.PhdosFile'>
SCR.nc             <class 'abipy.electrons.scr.ScrFile'>
SIGRES.nc          <class 'abipy.electrons.gw.SigresFile'>
GRUNS.nc           <class 'abipy.dfpt.gruneisen.GrunsNcFile'>
MDF.nc             <class 'abipy.electrons.bse.MdfFile'>
FATBANDS.nc        <class 'abipy.electrons.fatbands.FatBandsFile'>
FOLD2BLOCH.nc      <class 'abipy.electrons.fold2bloch.Fold2BlochNcfile'>
CUT3DDENPOT.nc     <class 'abipy.electrons.denpot.Cut3dDenPotNcFile'>
OPTIC.nc           <class 'abipy.electrons.optic.OpticNcFile'>
A2F.nc             <class 'abipy.eph.a2f.A2fFile'>
SIGEPH.nc          <class 'abipy.eph.sigeph.SigEPhFile'>
ABIWAN.nc          <class 'abipy.wannier90.abiwan.AbiwanFile'>

Warning

AbiPy uses the .abi extension for Abinit input files, .abo for output files and .log for log files. Please follow this convention to facilitate the integration with AbiPy.

Complete command line reference

usage: abiopen.py [-h] [--loglevel LOGLEVEL] [-V] [-v] [-nb] [--foreground]
                  [-p] [-e] [-s] [-t SLIDE_TIMEOUT] [-sns [SEABORN]]
                  [-mpl MPL_BACKEND]
                  filepath

Positional Arguments

filepath File to open. See table below for the list of supported extensions.

Named Arguments

--loglevel

Set the loglevel. Possible values: CRITICAL, ERROR (default), WARNING, INFO, DEBUG

Default: “ERROR”

-V, --version show program’s version number and exit
-v, --verbose

verbose, can be supplied multiple times to increase verbosity

Default: 0

-nb, --notebook
 

Open file in jupyter notebook

Default: False

--foreground

Run jupyter notebook in the foreground.

Default: False

-p, --print

Print python object and return.

Default: False

-e, --expose

Open file and generate matplotlib figures automatically by calling expose method.

Default: False

-s, --slide-mode
 

Iterate over figures. Expose all figures at once if not given on the CLI.

Default: False

-t, --slide-timeout
 Close figure after slide-timeout seconds (only if slide-mode). Block if not specified.
-sns, --seaborn
 Use seaborn settings. Accept value defining context in (“paper”, “notebook”, “talk”, “poster”). Default: paper
-mpl, --mpl-backend
 Set matplotlib interactive backend. Possible values: GTKAgg, GTK3Agg, GTK, GTKCairo, GTK3Cairo, WXAgg, WX, TkAgg, Qt4Agg, Qt5Agg, macosx.See also: https://matplotlib.org/faq/usage_faq.html#what-is-a-backend.