abtem.atoms#
Module for modifying ASE Atoms objects for use in abTEM.
Module Contents#
Functions#
Convert crystallographic B-factor to displacement standard deviation. |
|
Crop atoms outside the cell. |
|
Find the closest orthogonal cell for a given cell given a maximum number of repetitions in all directions. |
|
Fit the given atoms into a given cell by cropping atoms that are outside the cell, ignoring periodicity. If the given atoms do not originally fill the cell, they are first repeated until they do. |
|
Decompose an affine transform into rotation, scale and shear. |
|
|
|
Convert sequence of Euler angles to Cartesian rotation matrix. |
|
Inverts the positions of atoms along a given axis. |
|
Check whether the cell of given atoms is hexagonal. |
|
Check whether atoms have an orthogonal cell. |
|
Check whether the cell of given atoms can be converted to a structure usable by abTEM. |
|
Merge atoms that are closer in distance to each other than the given tolerance. |
|
Make the cell of the given atoms orthogonal. This is accomplished by repeating the cell until lattice vectors are close to the three principal Cartesian directions. If the structure is not exactly orthogonal after the structure is repeated by a given maximum number, the remaining difference is made up by applying strain. |
|
Repeat the atoms in the x and y directions, retaining only the repeated atoms within the margin distance from the cell boundary. |
|
Convert string representation of Cartesian axes to numerical. |
|
Print a decomposed transformation in an easy-to-read manner. |
|
Rotate the positions and cell vectors of atoms using Euler angles. |
|
Rotate atoms so that their xy plane is rotated into a given plane. |
|
Give the rotation matrix corresponding to a rotation from a given plane to the xy plane. |
|
Convert a Cartesian rotation matrix to Euler angles. |
|
Find and return the smallest non-repeating cell for the given atoms. |
|
Convert displacement standard deviation to crystallographic B-factor. |
|
Standardize the cell of given atoms. The atoms are rotated so that one of the lattice vectors in the xy-plane is aligned with the x-axis, and then all the lattice vectors are made positive. |
|
Validate and normalise a per-atom scalar or vector property. |
|
Validate displacement standard deviations and detect anisotropy. |
|
Wrap atoms that are closer to cell boundaries than the given tolerance. |
Data#
API#
- abtem.atoms.AtomProperties#
None
- abtem.atoms.B_to_sigma(...) float | ndarray[source]#
Convert crystallographic B-factor to displacement standard deviation.
The r.m.s. displacement sigma is related to the B-factor by σ = sqrt(B / (8π²)).
- abtem.atoms.axis_mapping#
None
- abtem.atoms.best_orthogonal_cell(...) ndarray[source]#
Find the closest orthogonal cell for a given cell given a maximum number of repetitions in all directions.
- abtem.atoms.cut_cell(...) ase.Atoms[source]#
Fit the given atoms into a given cell by cropping atoms that are outside the cell, ignoring periodicity. If the given atoms do not originally fill the cell, they are first repeated until they do.
- Parameters:
atoms (ase.Atoms) – Atoms to be fit.
cell (tuple of floats) – Cell to be fit into.
plane (str or tuple of tuples) – Plane to be rotated into given as either a string or two tuples (by default xy which results in no rotation for a standardized cell).
origin (tuple of floats) – Offset of the origin for the given cell with respect to the original cell.
margin (float or tuple of three floats) – Atoms that are outside the cell by this margin are not cropped (by default no margin).
- Returns:
cut – Atoms fit into the cell.
- Return type:
ase.Atoms
- abtem.atoms.decompose_affine_transform(...) tuple[ndarray, ndarray, ndarray][source]#
Decompose an affine transform into rotation, scale and shear.
- Parameters:
affine_transform (ndarray) – Matrix representation of an affine transformation of dimension 3x3.
- Returns:
decomposition – Decomposition of the affine transformation into a tuple of length 3 whose items are arrays of dimension 3 representing rotation, scale and shear.
- Return type:
{(3,), (3,), (3,)} tuple
- abtem.atoms.euler_sequence(...) tuple[int, int, int, int][source]#
- Parameters:
axes (str) – Specifies the order of rotation axes. It should be a string representing a valid combination of the letters ‘x’, ‘y’, and ‘z’ in any order. For example, ‘xyz’ represents a sequence of rotations about the x-axis, y-axis, and z-axis in that order.
convention (str) – Specifies the convention used for the Euler angles. It should be either ‘intrinsic’ or ‘static’ for rotations applied to a fixed frame or ‘extrinsic’ or ‘rotating’ for rotations applied to a rotating frame.
- Returns:
A tuple of four angles (theta1, theta2, theta3, phi) representing the Euler sequence specified by the given axes and convention.
- Return type:
- Raises:
ValueError – If the given convention is not one of the valid options (‘intrinsic’, ‘static’, ‘extrinsic’, ‘rotating’).
- abtem.atoms.euler_to_rotation(...) ndarray[source]#
Convert sequence of Euler angles to Cartesian rotation matrix.
- Parameters:
- Returns:
R – 3x3 rotation matrix
- Return type:
ndarray
- abtem.atoms.flip_atoms(...) ase.Atoms[source]#
Inverts the positions of atoms along a given axis.
- Parameters:
atoms (ase.Atoms) – Atoms to be inverted.
axis (int) – Integer representing the Cartesian axis (0 is x, 1 is y, and the default 2 is z).
- Returns:
atoms – Inverted atoms.
- Return type:
ase.Atoms
- abtem.atoms.is_cell_hexagonal(...) bool[source]#
Check whether the cell of given atoms is hexagonal.
- Parameters:
atoms (ase.Atoms) – The atoms that should be checked.
- Returns:
hexagonal – True if cell is hexagonal.
- Return type:
- abtem.atoms.is_cell_valid(...) bool[source]#
Check whether the cell of given atoms can be converted to a structure usable by abTEM.
- abtem.atoms.merge_close_atoms(...) ase.Atoms[source]#
Merge atoms that are closer in distance to each other than the given tolerance.
- Parameters:
atoms (ase.Atoms) – Atoms to merge.
tol (float) – Atoms closer to each other than this value are merged if they have identical atomic numbers.
- Returns:
merged_atoms – Merged atoms.
- Return type:
ase.Atoms
- abtem.atoms.orthogonalize_cell(...)[source]#
Make the cell of the given atoms orthogonal. This is accomplished by repeating the cell until lattice vectors are close to the three principal Cartesian directions. If the structure is not exactly orthogonal after the structure is repeated by a given maximum number, the remaining difference is made up by applying strain.
- Parameters:
atoms (ase.Atoms) – The non-orthogonal atoms.
max_repetitions (int) – The maximum number of repetitions allowed. Increase this to allow more repetitions and hence less strain.
return_transform (bool) – If true, return the transformations that were applied to make the atoms orthogonal.
allow_transform (bool) – If false no transformation is applied to make the cell orthogonal, hence a non-orthogonal cell may be returned.
plane (str or two tuples of three float, optional) – The plane relative to the provided atoms mapped to xy plane of the potential, i.e. provided plane is perpendicular to the propagation direction. If given as a string, it must be a concatenation of two of x, y and z; the default value ‘xy’ indicates that potential slices are cuts along the xy-plane of the atoms. The plane may also be specified with two arbitrary 3D vectors, which are mapped to the x and y directions of the potential, respectively. The length of the vectors has no influence. If the vectors are not perpendicular, the second vector is rotated in the plane to become perpendicular to the first. Providing a value of ((1., 0., 0.), (0., 1., 0.)) is equivalent to providing ‘xy’.
plane – The plane relative to the provided atoms mapped to xy plane of the potential, i.e. provided plane is perpendicular to the propagation direction. If given as a string, it must be a concatenation of two of x, y and z; the default value ‘xy’ indicates that potential slices are cuts along the xy-plane of the atoms. The plane may also be specified with two arbitrary 3D vectors, which are mapped to the x and y directions of the potential, respectively. The length of the vectors has no influence. If the vectors are not perpendicular, the second vector is rotated in the plane to become perpendicular to the first. Providing a value of ((1., 0., 0.), (0., 1., 0.)) is equivalent to providing ‘xy’.
origin (three float, optional) – The origin relative to the provided atoms mapped to the origin of the potential. This is equivalent to translating the atoms. The default is (0., 0., 0.).
box (three float, optional) – The extent of the potential in x, y and z. If not given this is determined from the atoms’ cell. If the box size does not match an integer number of the atoms’ supercell, an affine transformation may be necessary to preserve periodicity, determined by the periodic keyword.
tolerance (float) – Determines what is defined as a plane. All atoms within a distance equal to tolerance [Å] from a given plane will be considered to belong to that plane.
- Returns:
atoms (ase.Atoms) – The orthogonal atoms.
transform (tuple of arrays, optional) – The applied transform given as Euler angles (by default not returned).
- abtem.atoms.pad_atoms(...) ase.Atoms[source]#
Repeat the atoms in the x and y directions, retaining only the repeated atoms within the margin distance from the cell boundary.
- Parameters:
atoms (ase.Atoms) – The atoms that should be padded.
margins (one or tuple of three floats) – The padding margin. Can be specified either as a single value for all directions, or three separate values.
directions (str) – The directions to pad the atoms as a concatenation of one or more of x, y and z for each of the principal directions.
- Returns:
padded – Padded atoms.
- Return type:
ase.Atoms
- abtem.atoms.plane_to_axes(...) tuple[int, ...][source]#
Convert string representation of Cartesian axes to numerical.
- abtem.atoms.pretty_print_transform(...)[source]#
Print a decomposed transformation in an easy-to-read manner.
- abtem.atoms.rotate_atoms(...) ase.Atoms[source]#
Rotate the positions and cell vectors of atoms using Euler angles.
- Parameters:
atoms (Atoms) – The atoms object to rotate.
axes (str, optional) – The sequence of axes for rotation. Default is “zxz”.
angles (tuple[float, float, float], optional) – The Euler angles in radians. Default is (0.0, 0.0, 0.0).
convention (str, optional) – The convention for Euler angles. Default is “intrinsic”.
- Returns:
The rotated atoms object.
- Return type:
Atoms
- abtem.atoms.rotate_atoms_to_plane(...) ase.Atoms[source]#
Rotate atoms so that their xy plane is rotated into a given plane.
- abtem.atoms.rotation_matrix_from_plane(...) ndarray[source]#
Give the rotation matrix corresponding to a rotation from a given plane to the xy plane.
- abtem.atoms.rotation_matrix_to_euler(...) tuple[float, float, float][source]#
Convert a Cartesian rotation matrix to Euler angles.
- Parameters:
- Returns:
angles – Euler angles corresponding to the given rotation matrix.
- Return type:
- abtem.atoms.shrink_cell(...) ase.Atoms[source]#
Find and return the smallest non-repeating cell for the given atoms.
- Parameters:
- Returns:
atoms – Smallest non-repeating cell for the given atoms.
- Return type:
ase.Atoms
- abtem.atoms.sigma_to_B(...) float | ndarray[source]#
Convert displacement standard deviation to crystallographic B-factor.
The B-factor (also called the Debye-Waller factor or temperature factor) is related to the r.m.s. displacement sigma by B = 8π²σ².
- abtem.atoms.standardize_cell(...) ase.Atoms[source]#
Standardize the cell of given atoms. The atoms are rotated so that one of the lattice vectors in the xy-plane is aligned with the x-axis, and then all the lattice vectors are made positive.
- Parameters:
atoms (ase.Atoms) – The atoms that should be standardized.
tol (float) – Components of the lattice vectors whose magnitude is below this value are considered to be zero.
- Returns:
atoms – The standardized atoms.
- Return type:
ase.Atoms
- abtem.atoms.validate_per_atom_property(...) ndarray | dict[str, ndarray][source]#
Validate and normalise a per-atom scalar or vector property.
- abtem.atoms.validate_sigmas(...) tuple[ndarray | dict[str, ndarray], bool][source]#
Validate displacement standard deviations and detect anisotropy.
- Parameters:
atoms (Atoms)
sigmas (AtomProperties) – Isotropic: a single float, per-element dict of floats, or length-N array. Anisotropic: a 3-tuple of floats (identical for all atoms), a per-element dict of 3-tuples/arrays, or an (N, 3) array.
return_array (bool) – If True, always return a flat ndarray rather than a dict.
- Returns:
validated_sigmas (ndarray or dict)
anisotropic (bool)