pymatgen.io.abinit.netcdf module¶
Wrapper for netCDF readers.
-
as_ncreader(file)[source]¶ Convert file into a NetcdfReader instance. Returns reader, closeit where closeit is set to True if we have to close the file before leaving the procedure.
-
class
NetcdfReader(path)[source]¶ Bases:
objectWraps and extends netCDF4.Dataset. Read only mode. Supports with statements.
- Additional documentation available at:
http://netcdf4-python.googlecode.com/svn/trunk/docs/netCDF4-module.html
Open the Netcdf file specified by path (read mode).
-
Error¶ alias of
NetcdfReaderError
-
read_dimvalue(dimname, path='/', default=<class 'pymatgen.io.abinit.netcdf.NO_DEFAULT'>)[source]¶ Returns the value of a dimension.
- Parameters
dimname – Name of the variable
path – path to the group.
default – return default if dimname is not present and default is not NO_DEFAULT else raise self.Error.
-
read_keys(keys, dict_cls=<class 'monty.collections.AttrDict'>, path='/')[source]¶ Read a list of variables/dimensions from file. If a key is not present the corresponding entry in the output dictionary is set to None.
-
read_value(varname, path='/', cmode=None, default=<class 'pymatgen.io.abinit.netcdf.NO_DEFAULT'>)[source]¶ Returns the values of variable with name varname in the group specified by path.
- Parameters
varname – Name of the variable
path – path to the group.
cmode – if cmode==”c”, a complex ndarrays is constructed and returned (netcdf does not provide native support from complex datatype).
default – returns default if varname is not present. self.Error is raised if default is default is NO_DEFAULT
- Returns
numpy array if varname represents an array, scalar otherwise.
-
class
ETSF_Reader(path)[source]¶ Bases:
pymatgen.io.abinit.netcdf.NetcdfReaderThis object reads data from a file written according to the ETSF-IO specifications.
We assume that the netcdf file contains at least the crystallographic section.
Open the Netcdf file specified by path (read mode).
-
structure_from_ncdata(ncdata, site_properties=None, cls=<class 'pymatgen.core.structure.Structure'>)[source]¶ Reads and returns a pymatgen structure from a NetCDF file containing crystallographic data in the ETSF-IO format.
- Parameters
ncdata – filename or NetcdfReader instance.
site_properties – Dictionary with site properties.
cls – The Structure class to instanciate.