sknano.core.atoms.ImageAtoms.mapatomattr¶
-
ImageAtoms.
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.
Parameters: from_attr, to_attr :
str
attrmap :
dict
Examples
Suppose you have an
XAtoms
instance namedatoms
that hasXAtom
instances of two atom types 1 and 2 and we want to set allXAtom
s with type=1 to Nitrogen and allXAtom
s with type=2 to Argon. In other words, we want to map theXAtom.type
attribute to theXAtom.element
attribute.We’d call this method like so:
>>> atoms.mapatomattr('type', 'element', {1: 'N', 2: 'Ar'})