Indexing reflections

Error types

class crystals.IndexingError

Bases: RuntimeError

Indexing has failed.

New in version 1.3.0.

Single-crystal indexing with the DirAx algorithm

crystals.index_dirax(reflections, initial=None, length_bounds=(2, 20))

Find the lattice associated with a list of reflections using the DirAx algorithm.

New in version 1.3.0.

Parameters
  • reflections (iterable of 3-tuple or ndarray, shape (N, 3)) – Iterable of reflections with their three-dimensional reciprocal space coordinates, or ndarray where each row is a reflections. Coordinates are in inverse Angstroms.

  • initial (Lattice or Crystal, optional) – Initial guess for a lattice. The DirAx algorithm does not need an initial guess, but it can certainly help when many reflections are missing.

  • length_bounds (2-tuple of floats, optional) – Minimum and maximum lattice vector lengths to consider, in Angstrom.

Returns

  • indexed (Lattice) – Lattice that best indexes reflections.

  • indices (ndarray, shape (N, 3)) – Miller indices associated with each vector in reflections, in order.

Raises

IndexingError – The indexing has failed.

Notes

This indexing routine is based on the reference below. The algorithm is well-suited to situations where reflections might be missing, or situations where the list of reflections contains “alien” reflections not associated with the lattice.

Examples

We generate reflections from a crystal structure and re-index it for demonstration purposes.

>>> from crystals import index_dirax, Crystal
>>> import numpy as np
>>> graphite = Crystal.from_database('C')
>>> # The list of reflections `qs` might be experimental measurements from either
>>> # x-ray or electron diffraction.
>>> qs = [graphite.scattering_vector(r) for r in graphite.bounded_reflections(bound=3.5)]
>>> lattice, hkls = index_dirax(qs)
>>> lattice 
< Lattice object with parameters 2.464Å, 2.464Å, 6.711Å, 90.00°, 90.00°, 120.00° >

References

A. J. M. Duisenberg, Indexing in Single-Crystal Diffractometry with an Obstinate List of Reflections (1992), J. Appl. Cryst vol. 25 pp. 92 - 96