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]
[--classic-notebook] [--no-browser] [--foreground] [-p]
[-pn] [-pnt PANEL_TEMPLATE] [--port PORT] [-e] [-s]
[-t SLIDE_TIMEOUT] [-sns [SEABORN]] [-mpl MPL_BACKEND] [-ew]
[-ply]
filepath
positional arguments:
filepath File to open. See table below for the list of
supported extensions.
options:
-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
--classic-notebook, -cnb
Use classic jupyter notebook instead of jupyterlab.
--no-browser Start the jupyter server to serve the notebook but
don't open the notebook in the browser. Use this
option to connect remotely from localhost to the
machine running the kernel
--foreground Run jupyter notebook in the foreground.
-p, --print Print python object and return.
-pn, --panel Open Dashboard in web browser, requires panel package.
-pnt PANEL_TEMPLATE, --panel-template PANEL_TEMPLATE
Specify template for panel dasboard.Possible values
are: FastList, FastGrid, Golden, Bootstrap, Material,
React, Vanilla.Default: FastList
--port PORT Allows specifying a specific port when serving panel
app.
-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.
-ew, --expose-web Generate matplotlib plots in $BROWSER instead of
X-server. WARNING: Not all the features are supported.
-ply, --plotly Generate plotly plots in $BROWSER instead of
matplotlib. WARNING: Not all the features are
supported.
======================================================================================================
Usage example:
abiopen.py FILE => Open file in ipython shell.
abiopen.py FILE -p => Print info on object to terminal.
abiopen.py FILE -e => Generate matplotlib figures automatically.
Use -sns to activate seaborn settings.
abiopen.py FILE -eweb => Generate matplotlib figures, show them in the $BROWSER.
abiopen.py FILE -ply => Generate plotly figures automatically. Show them in the $BROWSER.
Note that not all FILEs support plotly.
abiopen.py FILE -pn => Generate GUI in web BROWSER to interact with FILE. Requires panel package.
abiopen.py FILE -nb => Generate jupyter-lab notebook.
abiopen.py FILE -cnb => Generate classic jupyter notebook.
where `FILE` is any file supported by abipy/pymatgen e.g. Netcdf files, Abinit input, POSCAR, xsf.
File extensions supported (including zipped files with extension in ".bz2", ".gz", ".z"):
Use `-v` to increase verbosity level (can be supplied multiple times e.g -vv).
JSON file are supported as well. In this case, abiopen.py tries to reconstruct python objects
assuming JSON document in MSONable format and then invokes ipython with the `data` object.
Use `-e` or `--notebook` or `--panel` to print the JSON dictionary without reconstructing python objects.
======================================================================================================
Table mapping file extension to AbiPy object:
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'>
.abivars <class 'abipy.core.structure.Structure'>
.ucell <class 'abipy.core.structure.Structure'>
.cssr <class 'abipy.core.structure.Structure'>
.json <class 'abipy.core.mixins.JsonFile'>
.py <class 'abipy.core.mixins.TextFile'>
.sh <class 'abipy.core.mixins.TextFile'>
.stdin <class 'abipy.core.mixins.TextFile'>
.stderr <class 'abipy.core.mixins.TextFile'>
.err <class 'abipy.core.mixins.TextFile'>
.files <class 'abipy.core.mixins.TextFile'>
.stdout <class 'abipy.core.mixins.TextFile'>
.cube <class 'abipy.core.mixins.CubeFile'>
anaddb.nc <class 'abipy.dfpt.anaddbnc.AnaddbNcFile'>
DEN <class 'abipy.electrons.denpot.DensityFortranFile'>
.wout <class 'abipy.wannier90.wout.WoutFile'>
EDOS <class 'abipy.electrons.ebands.EdosFile'>
.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'>
.upf <class 'pymatgen.io.abinit.pseudos.Pseudo'>
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'>
POSCAR <class 'abipy.core.structure.Structure'>
.vasp <class 'abipy.core.structure.Structure'>
.xyz <class 'abipy.core.structure.Structure'>
.evp <class 'abipy.dynamics.cpx.EvpFile'>
GSR.nc <class 'abipy.electrons.gsr.GsrFile'>
ESKW.nc <class 'abipy.electrons.eskw.EskwFile'>
DEN.nc <class 'abipy.electrons.denpot.DensityNcFile'>
OUT.nc <class 'abipy.abio.outputs.OutNcFile'>
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'>
GWR.nc <class 'abipy.electrons.gwr.GwrFile'>
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'>
GSTORE.nc <class 'abipy.eph.gstore.GstoreFile'>
GPATH.nc <class 'abipy.eph.gpath.GpathFile'>
TRANSPORT.nc <class 'abipy.eph.transportfile.TransportFile'>
RTA.nc <class 'abipy.eph.rta.RtaFile'>
V1SYM.nc <class 'abipy.eph.v1sym.V1symFile'>
GKQ.nc <class 'abipy.eph.gkq.GkqFile'>
V1QNU.nc <class 'abipy.eph.v1qnu.V1qnuFile'>
V1QAVG.nc <class 'abipy.eph.v1qavg.V1qAvgFile'>
ABIWAN.nc <class 'abipy.wannier90.abiwan.AbiwanFile'>
EPH_CUMULANT.nc <class 'abipy.eph.cumulant.CumulantEPhFile'>
VARPEQ.nc <class 'abipy.eph.varpeq.VarpeqFile'>
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]
[--classic-notebook] [--no-browser] [--foreground] [-p]
[-pn] [-pnt PANEL_TEMPLATE] [--port PORT] [-e] [-s]
[-t SLIDE_TIMEOUT] [-sns [SEABORN]] [-mpl MPL_BACKEND] [-ew]
[-ply]
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
- --classic-notebook, -cnb
Use classic jupyter notebook instead of jupyterlab.
Default:
False
- --no-browser
Start the jupyter server to serve the notebook but don’t open the notebook in the browser. Use this option to connect remotely from localhost to the machine running the kernel
Default:
False
- --foreground
Run jupyter notebook in the foreground.
Default:
False
- -p, --print
Print python object and return.
Default:
False
- -pn, --panel
Open Dashboard in web browser, requires panel package.
Default:
False
- -pnt, --panel-template
Specify template for panel dasboard.Possible values are: FastList, FastGrid, Golden, Bootstrap, Material, React, Vanilla.Default: FastList
Default:
'FastList'
- --port
Allows specifying a specific port when serving panel app.
Default:
0
- -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.
- -ew, --expose-web
Generate matplotlib plots in $BROWSER instead of X-server. WARNING: Not all the features are supported.
Default:
False
- -ply, --plotly
Generate plotly plots in $BROWSER instead of matplotlib. WARNING: Not all the features are supported.
Default:
False