Crystals#

Crystal descriptions are immutable and may be loaded from XML or assembled from unit-cell and atom-site values.

Load a Crystal#

lauelab.indexing.load_crystal(path)[source]#

Load a Laue crystal XML file.

Parameters:

path (str | Path) – Path to a crystal XML file containing a cell and space-group number.

Returns:

Crystal – Immutable crystal description with source set to path.

Raises:
Return type:

Crystal

Notes

Atom sites without fractional coordinates are ignored. Missing occupancy defaults to one, and a missing chemical name defaults to the file stem.

Crystal Model#

class lauelab.indexing.Cell(a, b, c, alpha=90.0, beta=90.0, gamma=90.0, unit='nm')[source]#

Crystallographic unit-cell parameters.

Parameters:
  • a (float) – Positive unit-cell lengths in unit.

  • b (float) – Positive unit-cell lengths in unit.

  • c (float) – Positive unit-cell lengths in unit.

  • alpha (float) – Unit-cell angles in degrees. Each angle must be strictly between zero and 180 degrees.

  • beta (float) – Unit-cell angles in degrees. Each angle must be strictly between zero and 180 degrees.

  • gamma (float) – Unit-cell angles in degrees. Each angle must be strictly between zero and 180 degrees.

  • unit (str) – Length unit for a, b, and c. Supported values are "angstrom", "A", "nm", and "micron".

Raises:

ValueError – If a length or angle is invalid, or the unit is unsupported.

Notes

Instances are immutable. Use dataclasses.replace() to derive a cell with changed parameters.

property in_angstrom: Cell#

Copy the cell with lengths converted to angstroms.

Returns:

Cell – A new cell with unit="angstrom". Angles are unchanged.

class lauelab.indexing.Atom(symbol, position, occupancy=1.0, label=None)[source]#

Atom site in a crystal description.

Parameters:
  • symbol (str) – Chemical element symbol passed to the native crystal model.

  • position (tuple[float, float, float]) – Three fractional coordinates within the unit cell.

  • occupancy (float) – Site occupancy from zero through one, inclusive.

  • label (str | None) – Optional site label. If omitted, XML output uses symbol.

Raises:

ValueError – If position does not contain three coordinates or occupancy is outside the supported range.

Notes

Instances are immutable. Use dataclasses.replace() to derive a site with changed values.

class lauelab.indexing.Crystal(name, space_group, cell, atoms=(), source=None, setting=None)[source]#

Immutable crystal description used for orientation indexing.

Parameters:
  • name (str) – Human-readable crystal or material name.

  • space_group (int) – International Tables space-group number from 1 through 230.

  • cell (lauelab.indexing.crystal.Cell) – Crystallographic unit cell.

  • atoms (tuple[lauelab.indexing.crystal.Atom, ...]) – Atom sites. Any iterable supplied at construction is stored as a tuple.

  • source (str | None) – Optional source XML path retained as provenance.

  • setting (str | None) – Optional space-group setting retained as provenance, such as "R" or "H" for trigonal crystals. The native model infers its axes from the cell angles rather than this value.

Raises:

ValueError – If space_group is outside the range 1 through 230.

Notes

Instances are immutable. Use dataclasses.replace() to derive a modified crystal description.

property crystal_system: str#

Crystal system inferred from the space-group number.

Returns:

str – One of "triclinic", "monoclinic", "orthorhombic", "tetragonal", "trigonal", "hexagonal", or "cubic".