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:
- 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
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]
- __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
- 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))