box
- mdtools.check.box(box, with_angles=None, orthorhombic=False, allow_negative=False, allow_zero=False, dim=None, dtype=None)[source]
Check if the input array satisfies the conditions for a simulation box array in length-angle representation.
Arrays that contain the dimensions of simulation boxes in the length-angle representation must meet the following requirements:
Must be of an array_like type, i.e. a type that can be converted to a
numpy.ndarray.Must have a data type equal to the supplied dtype.
If the array does not contain the box angles:
Must be of shape
(3,)or(k, 3), wherekis the number of frames.
If the array contains the box angles:
Must be of shape
(6,)or(k, 6).The angles must be greater than 0 and less than 180°.
- Parameters:
box (
array_like) – The array to check.with_angles (
Noneorbool, optional) – IfNone(default), whether the box contains angles or not is inferred from the shape of the last dimension of box. If the last dimension has shape(3,), box is considered to not contain angles, if it has shape(6,), box is considered to contain angles. If with_angles isTrueorFalsethe box must or must not contain angles, otherwise an exception is raised.orthorhombic (
bool, optional) – IfTrueand with_angles evaluates toTrue, all angles of box must be 90°. Is ignored if with_angles isFalseor if box does not contain angle information.allow_negative (
bool, optional) – IfTrue, allow negative box lengths (but not zero).allow_zero (
bool, optional) – IfTrue, allow box lengths to be zero.dim (
{None, 1, 2}, optional) – The dimension expected for box. Default isNone, which means that the dimension of box must be either 1 or 2. If box should contain the box parameters for only one frame, set dim to 1. If box should contain the box parameters for multiple frames, set dim to 2.dtype (
type, optional) – The data type expected for box. Default isNone, which means that the data type of box is not checked.
- Returns:
box (
numpy.ndarray) – The input array asnumpy.ndarray.- Raises:
ValueError – If box has an incorrect shape; incorrect dimensionality; an invalid angle; an invalid box length. Or if dim is not
Noneand neither one or two. Seemdtools.check.array()for further potentially raised exceptions.
See also
mdtools.check.box_mat()Check if the input array satisfies the conditions for a simulation box matrix.
mdtools.check.array()Check if an array meets given requirements
mdtools.check.pos_array()Check if an array is a suitable position array