iotools Package

iotools Package

class abipy.iotools.ETSF_Reader(path)[source]

Bases: EtsfReader

Provides high-level API to read data from netcdf files written following the ETSF-IO specifications described in [Caliste2008]

read_structure()[source]

Overrides the read_structure method so that we always return an instance of AbiPy abipy.core.structure.Structure object

typeidx_from_symbol(symbol: str) int[source]

Returns the type index from the chemical symbol. Note python convention.

chemical_symbols()[source]

Chemical symbols char [number of atom species][symbol length].

read_string(varname: str)[source]
Parameters:

varname – Name of the variable

none_if_masked_array(arr)[source]

Return None if arr is a MaskedArray else None.

read_amu_symbol() dict[source]

Read atomic masses and return dictionary element_symbol –> amu.

Note

Only netcdf files with phonon-related quantities contain this variable.

read_ngfft3() array[source]

Return the number of FFT divisions.

visualizer Module

Classes used to execute a visualizer within the Python interpreter.

class abipy.iotools.visualizer.Visualizer(filepath: str)[source]

Bases: object

Handle the visualization of data.

is_macosx_app = False
Error

alias of VisualizerError

property cmdarg

Arguments that must be used to visualize the file.

binpath()[source]

Absolute path of the binary. None if app is not found

property is_available: bool

True is the visualizer is available on the local machine.

classmethod get_available(ext=None) list[source]

List of visualizers available on the local host. If ext is not None, only the visualizers supporting this extension are returned.

classmethod support_ext(ext) bool[source]

True if visualizer supports the extension ext.

classmethod from_file(filepath: str)[source]

Initialize a subclass of Visualizer from filepath, the application is chosen automatically depending on the file extension.

Raises:

VisualizerError

classmethod supported_extensions() list[source]

List of file extensions supported by the visualizer.

classmethod from_name(appname)[source]

Return the visualizer class from the name of the application.

classmethod all_visunames()[source]

List with the names of the visualizers supported.

xsf Module

Tools for writing Xcrysden files.

abipy.iotools.xsf.xsf_write_structure_and_data_to_path(filepath, structure, datar, **kwargs) None[source]

Simplified interface to write structure and data to filepath in XSF format.

abipy.iotools.xsf.xsf_write_structure(file, structures: list) None[source]

Write the crystalline structure in the Xcrysden format (XSF)

Parameters:
  • file – file-like object.

  • structuresStructure or list of Structure objects.

abipy.iotools.xsf.xsf_write_data(file, structure, data, add_replicas=True, cplx_mode=None, idname='data', tag='_UNKNOWN') None[source]

Write data in the Xcrysden format (XSF)

Parameters:
  • file – file-like object.

  • structureStructure object.

  • data – array-like object in C-order, i.e data[nx, ny, nz] or data[ngrids, nx, ny, nz]

  • add_replicas – If True, data is padded with redundant data points. in order to have a periodic 3D array of shape: (nx+1, ny+1, nz+1).

  • cplx_mode

    string defining the data to print when data is a complex array. Possible choices are (case-insensitive):

    • ”re” for real part.

    • ”im” for imaginary part.

    • ”abs” for the absolute value

abipy.iotools.xsf.bxsf_write(file, structure, nsppol, nband, ngkpt, ucdata_sbk, fermie, unit='eV') None[source]

Write band structure data in the Xcrysden format (XSF)

Parameters:
  • file – file-like object.

  • structureStructure object.

  • nsppol – Number of spins.

  • nband – Number of bands.

  • ngkpt – Number of divisions of the full k-mesh.

  • ucdata_sbk – Array [nsppol, nband, ngkpt[0], ngkpt[1], ngkpt[2]] with energies in the unit cell mesh in unit unit.

  • fermie – Fermi energy.

  • writing. (unit=Unit of input ucdata_sbk and fermie. Energies will be converted to Hartree before)

Note

  1. The k-points must span the reciprocal unit cell, not the Brillouin zone.

  2. The mesh must be closed and centered on Gamma.

  3. Energies are written in row-major (i.e. C) order.

# Energies are in Hartree.

See also http://www.xcrysden.org/doc/XSF.html