PhaseList#

class orix.crystal_map.PhaseList(phases: Phase | List[Phase] | Dict[Phase] | None = None, names: str | List[str] | None = None, space_groups: int | SpaceGroup | List[int | SpaceGroup] | None = None, point_groups: str | int | Symmetry | List[str | int | Symmetry] | None = None, colors: str | List[str] | None = None, ids: int | List[int] | np.ndarray | None = None, structures: Structure | List[Structure] | None = None)[source]#

Bases: object

A list of phases in a crystallographic map.

Each phase in the list must have a unique phase id and name.

Parameters:
phases

A list or dict of phases or a single phase. The other arguments are ignored if this is passed.

names

Phase names. Overwrites the names in the structure objects.

space_groups

Space groups.

point_groups

Point groups.

colors

Phase colors.

ids

Phase IDs.

structures

Unit cells with atoms and a lattice of each phase. If not given, a default diffpy.structure.Structure is created for each phase.

Examples

>>> from diffpy.structure import Atom, Lattice, Structure
>>> from orix.crystal_map import Phase, PhaseList
>>> pl = PhaseList(
...     names=["al", "cu"],
...     space_groups=[225] * 2,
...     structures=[
...         Structure(
...             atoms=[Atom("al", [0] * 3)],
...             lattice=Lattice(0.405, 0.405, 0.405, 90, 90, 90)
...         ),
...         Structure(
...             atoms=[Atom("cu", [0] * 3)],
...             lattice=Lattice(0.361, 0.361, 0.361, 90, 90, 90)
...         ),
...     ]
... )
>>> pl
Id  Name  Space group  Point group  Proper point group       Color
 0    al        Fm-3m         m-3m                 432    tab:blue
 1    cu        Fm-3m         m-3m                 432  tab:orange
>>> pl["al"].structure
[al   0.000000 0.000000 0.000000 1.0000]

A phase list can be indexed in multiple ways:

Return a phase if only one phase matches the key

>>> pl[0]  # Index with a single phase id
<name: al. space group: Fm-3m. point group: m-3m. proper point group: 432. color: tab:blue>
>>> pl["cu"]  # Index with a phase name
<name: cu. space group: Fm-3m. point group: m-3m. proper point group: 432. color: tab:orange>
>>> pl[:1]
<name: al. space group: Fm-3m. point group: m-3m. proper point group: 432. color: tab:blue>

Return a phase list

>>> pl[0:]  # Index with slices
Id  Name  Space group  Point group  Proper point group       Color
 0    al        Fm-3m         m-3m                 432    tab:blue
 1    cu        Fm-3m         m-3m                 432  tab:orange
>>> pl["al", "cu"]  # Index with a tuple of phase names
Id  Name  Space group  Point group  Proper point group       Color
 0    al        Fm-3m         m-3m                 432    tab:blue
 1    cu        Fm-3m         m-3m                 432  tab:orange
>>> pl[0, 1]  # Index with a tuple of phase phase_ids
Id  Name  Space group  Point group  Proper point group       Color
 0    al        Fm-3m         m-3m                 432    tab:blue
 1    cu        Fm-3m         m-3m                 432  tab:orange
>>> pl[[0, 1]]  # Index with a list of phase_ids
Id  Name  Space group  Point group  Proper point group       Color
 0    al        Fm-3m         m-3m                 432    tab:blue
 1    cu        Fm-3m         m-3m                 432  tab:orange

Attributes

PhaseList.colors

Return the phases' colors.

PhaseList.colors_rgb

Return the phases' RGB color values.

PhaseList.ids

Return the unique phase IDs in the list of phases.

PhaseList.names

Return the phases' names.

PhaseList.point_groups

Return the phases' point groups.

PhaseList.size

Return the number of phases in the list.

PhaseList.space_groups

Return the phases' space groups.

PhaseList.structures

Return the phases' structures.

Methods

PhaseList.add(value)

Add phases to the end of a phase list in-place, incrementing the phase IDs.

PhaseList.add_not_indexed()

Add a dummy phase to assign to not indexed data points.

PhaseList.deepcopy()

Return a deep copy using copy.deepcopy() function.

PhaseList.id_from_name(name)

Return the phase ID from a phase name or raise an error if the phase is not in the list.

PhaseList.sort_by_id()

Sort the list according to phase ID in-place.