asaplib.io package¶
Submodules¶
asaplib.io.cscope module¶
Adaptors for generating ChemiScope compatible inputs
-
asaplib.io.cscope.
write_chemiscope_input
(filename, frames, meta=None, extra=None, cutoff=None)[source]¶ Write the json file expected by the default chemiscope visualizer at
filename
. :param str filename: name of the file to use to save the json data. If itends with ‘.gz’, a gzip compressed file will be written
- Parameters
frames (list) – list of ase.Atoms objects containing all the structures
meta (dict) – optional metadata of the dataset, see below
extra (dict) – optional dictionary of additional properties, see below
cutoff (float) – optional. If present, will be used to generate atom-centered environments
The dataset metadata should be given in the
meta
dictionary, the possible keys are: .. code-block:: python- meta = {
‘name’: ‘…’, # str, dataset name ‘description’: ‘…’, # str, dataset description ‘authors’: [ # list of str, dataset authors, OPTIONAL
‘…’,
], ‘references’: [ # list of str, references for this dataset,
‘…’, # OPTIONAL
],
}
The written JSON file will contain all the properties defined on the ase.Atoms objects. Values in
ase.Atoms.arrays
are mapped totarget = "atom"
properties; while values inase.Atoms.info
are mapped totarget = "structure"
properties. The only exception isase.Atoms.arrays["numbers"]
, which is always ignored. If you want to have the atomic numbers as a property, you should add it toextra
manually. Additional properties can be added with theextra
parameter. This parameter should be a dictionary containing one entry for each property. Each entry contains atarget
attribute ('atom'
or'structure'
) and a set of values.values
can be a Python list of float or string; a 1D numpy array of numeric values; or a 2D numpy array of numeric values. In the later case, multiple properties will be generated along the second axis. For example, passing .. code-block:: python- extra = {
- ‘cheese’: {
‘target’: ‘atom’, ‘values’: np.zeros((300, 4))
}
}
will generate four properties named
cheese[1]
,cheese[2]
,cheese[3]
, andcheese[4]
, each containing 300 values. .. ase.Atoms: https://wiki.fysik.dtu.dk/ase/ase/atoms.html
asaplib.io.io_cell module¶
Functions for converting between different simulation cell formats
-
asaplib.io.io_cell.
abc2h
(a, b, c, alpha, beta, gamma)[source]¶ Returns a lattice vector matrix given a description in terms of the lattice vector lengths and the angles in between.
- Parameters
a – First cell vector length.
b – Second cell vector length.
c – Third cell vector length.
alpha – Angle between sides b and c in radians.
beta – Angle between sides a and c in radians.
gamma – Angle between sides b and a in radians.
- Returns
An array giving the lattice vector matrix in upper triangular form.
-
asaplib.io.io_cell.
genh2abc
(h)[source]¶ - Returns a description of the cell in terms of the length of the
lattice vectors and the angles between them in radians.
Takes the representation of the system box in terms of a full matrix of row vectors, and returns the representation in terms of the lattice vector lengths and the angles between them in radians.
- Parameters
h – Cell matrix in upper triangular column vector form.
- Returns
A list containing the lattice vector lengths and the angles between them.
-
asaplib.io.io_cell.
h2abc
(h)[source]¶ - Returns a description of the cell in terms of the length of the
lattice vectors and the angles between them in radians.
Takes the representation of the system box in terms of an upper triangular matrix of column vectors, and returns the representation in terms of the lattice vector lengths and the angles between them in radians.
- Parameters
h – Cell matrix in upper triangular column vector form.
- Returns
A list containing the lattice vector lengths and the angles between them.
-
asaplib.io.io_cell.
h2abc_deg
(h)[source]¶ - Returns a description of the cell in terms of the length of the
lattice vectors and the angles between them in degrees.
Takes the representation of the system box in terms of an upper triangular matrix of column vectors, and returns the representation in terms of the lattice vector lengths and the angles between them in degrees.
- Parameters
h – Cell matrix in upper triangular column vector form.
- Returns
A list containing the lattice vector lengths and the angles between them in degrees.
asaplib.io.io_parse module¶
Functions for IO and type conversions
-
class
asaplib.io.io_parse.
ConvertStrToList
(param_decls=None, show_default=False, prompt=False, confirmation_prompt=False, hide_input=False, is_flag=None, flag_value=None, multiple=False, count=False, allow_from_autoenv=True, type=None, help=None, hidden=False, show_choices=True, show_envvar=False, **attrs)[source]¶ Bases:
click.core.Option
-
class
asaplib.io.io_parse.
NpDecoder
(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)[source]¶ Bases:
json.decoder.JSONDecoder
-
class
asaplib.io.io_parse.
NpEncoder
(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶ Bases:
json.encoder.JSONEncoder
-
default
(obj)[source]¶ Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
-
-
class
asaplib.io.io_parse.
PythonLiteralOption
(param_decls=None, show_default=False, prompt=False, confirmation_prompt=False, hide_input=False, is_flag=None, flag_value=None, multiple=False, count=False, allow_from_autoenv=True, type=None, help=None, hidden=False, show_choices=True, show_envvar=False, **attrs)[source]¶ Bases:
click.core.Option