XYZAtoms.mapatomattr(from_attr=None, to_attr=None, attrmap=None)[source]

Set/update atom attribute from another atom attribute with dict.

Changed in version 0.3.11: Made all arguments required keyword arguments and reversed the order of the former positional arguments from_attr and to_attr to be more natural and consistent with the key, value pairs in the attrmap dictionary.


from_attr, to_attr : str

attrmap : dict


Suppose you have an XAtoms instance named atoms that has XAtom instances of two atom types 1 and 2 and we want to set all XAtoms with type=1 to Nitrogen and all XAtoms with type=2 to Argon. In other words, we want to map the XAtom.type attribute to the XAtom.element attribute.

We’d call this method like so:

>>> atoms.mapatomattr('type', 'element', {1: 'N', 2: 'Ar'})