The Lattice Handler Reference

Lattice parameter calculation from experimental Bragg edges.

class neutronbraggedge.lattice_handler.lattice.Lattice(material=None, crystal_structure=None, bragg_edge_array=None, bragg_edge_error_array=None, use_local_metadata_table=True)[source]

Calculate lattice parameters from experimental Bragg edge measurements.

Given experimental Bragg edge values and crystal structure, this class calculates the lattice parameter for each reflection and provides statistical analysis of the results.

Parameters:
material

Material name/symbol.

Type:

str or None

crystal_structure

Crystal structure type (“BCC” or “FCC”).

Type:

CrystalStructure

bragg_edge_array

Array of experimental Bragg edge values.

Type:

NDArray

bragg_edge_error_array

Array of errors for the Bragg edge values.

Type:

NDArray

hkl

Miller indices for each Bragg edge.

Type:

list[list[int]]

lattice_array

Calculated lattice parameters for each reflection.

Type:

list[float]

lattice_error

Errors in lattice parameters.

Type:

list[float]

lattice_statistics

Statistical summary (min, max, mean, median, std).

Type:

dict[str, Any]

Examples

>>> from neutronbraggedge.lattice_handler.lattice import Lattice
>>> bragg_edges = [4.05, 2.87, 2.34, 2.03]
>>> errors = [0.01, 0.01, 0.01, 0.01]
>>> lattice = Lattice(
...     material='Fe',
...     crystal_structure='BCC',
...     bragg_edge_array=bragg_edges,
...     bragg_edge_error_array=errors
... )
>>> print(lattice.lattice_statistics['mean'])
[2.866, 0.007]
space: int = 75
hkl_bragg_edge: list[tuple[list[int], float, float]]
lattice_array: list[float]
lattice_error: list[float]
lattice_statistics: dict[str, Any]
__init__(material=None, crystal_structure=None, bragg_edge_array=None, bragg_edge_error_array=None, use_local_metadata_table=True)[source]

Initialize Lattice calculator.

Parameters:
  • material (str, optional) – Material name/symbol for reference.

  • crystal_structure ({"BCC", "FCC"}) – Crystal structure type.

  • bragg_edge_array (array-like) – Experimental Bragg edge wavelengths in Angstroms.

  • bragg_edge_error_array (array-like, optional) – Errors for the Bragg edge values. If None, zeros are used.

  • use_local_metadata_table (bool, default True) – Whether to use local metadata table.

Raises:

ValueError – If crystal_structure is not “BCC” or “FCC”.

Return type:

None

material: str | None
use_local_metadata: bool
bragg_edge_array: ndarray[tuple[Any, ...], dtype[floating]]
bragg_edge_error_array: ndarray[tuple[Any, ...], dtype[floating]]
hkl: list[list[int]]
property crystal_structure: Literal['BCC', 'FCC']

Get the crystal structure type.

get_statistics()[source]

Get lattice statistics as a Pydantic model.

Returns:

Pydantic model containing statistical summary of lattice parameters.

Return type:

LatticeStatistics

Examples

>>> lattice = Lattice(material='Fe', crystal_structure='BCC',
...                   bragg_edge_array=[4.05, 2.87],
...                   bragg_edge_error_array=[0.01, 0.01])
>>> stats = lattice.get_statistics()
>>> print(stats.mean)
2.866
>>> print(stats.model_dump_json(indent=2))
display_hkl_bragg_edge()[source]

Display the hkl-Bragg edge table.

Returns:

Always returns True on successful display.

Return type:

bool

display_lattice_statistics()[source]

Display lattice statistics via logger.

Return type:

None

display_recap()[source]

Display a summary of inputs and calculation results.

Return type:

None