sknano.core.atoms.VelocityAtoms.filtered¶
-
VelocityAtoms.
filtered
(condition, invert=False)[source]¶ Return new list of
Atoms
filtered by condition.New in version 0.3.11.
Parameters: condition : array_like, bool
Boolean index array having same shape as the initial dimensions of the list of
Atoms
being indexed.invert : bool, optional
If True, the boolean array condition is inverted element-wise.
Returns: filtered_atoms :
Atoms
If invert is False, return the elements where condition is True.
If invert is True, return the elements where condition (i.e., numpy.invert(condition)) is True.
Examples
An example using the structure data of a 10 nm (10, 0) SWCNT:
>>> from sknano.generators import SWNTGenerator >>> swnt = SWNTGenerator(10, 0, Lz=10, fix_Lz=True).atoms >>> # select 'left', 'middle', 'right' atoms >>> latoms = swnt.filtered(swnt.z <= 25) >>> matoms = swnt.filtered((swnt.z < 75) & (swnt.z > 25)) >>> ratoms = swnt.filtered(swnt.z >= 75) >>> from pprint import pprint >>> pprint([getattr(atoms, 'bounds') for atoms in ... (latoms, matoms, ratoms)]) [Cuboid(pmin=Point([-3.914435, -3.914435, 0.0]), pmax=Point([3.914435, 3.914435, 24.85])), Cuboid(pmin=Point([-3.914435, -3.914435, 25.56]), pmax=Point([3.914435, 3.914435, 74.55])), Cuboid(pmin=Point([-3.914435, -3.914435, 75.97]), pmax=Point([3.914435, 3.914435, 100.11]))] >>> latoms.Natoms + matoms.Natoms + ratoms.Natoms == swnt.Natoms True