hexrd.phase_transition.texture.evaluation module
ODF Evaluation Functions
Provides common evaluation functionality for orientation distribution functions. This module serves as a foundation for more complex ODF implementations.
- hexrd.phase_transition.texture.evaluation.eval_odf_batch(odf, orientations, chunk_size=10000)[source]
Evaluate ODF on large batches of orientations with memory management.
For very large orientation datasets, this function processes orientations in chunks to avoid memory issues while maintaining vectorization benefits.
Parameters
- odfODF object
ODF object with eval() method
- orientationsarray_like
Large array of orientation matrices, shape (N, 3, 3). A single (3, 3) matrix is also accepted.
- chunk_sizeint, optional
Number of orientations to process per chunk, default 10000
Returns
- numpy.ndarray or float
ODF values, shape (N,) for an (N, 3, 3) input, or a scalar float for a single (3, 3) orientation.
Examples
>>> odf = UniformODF('oh', 'triclinic') >>> # Large batch of orientations >>> Rs = np.random.normal(size=(50000, 3, 3)) # Not actual rotations! >>> # In practice, use proper rotation matrices >>> values = eval_odf_batch(odf, Rs, chunk_size=5000)
- hexrd.phase_transition.texture.evaluation.eval_random_orientations(odf, n_orientations=1000, seed=None)[source]
Evaluate ODF at random orientations for statistical analysis.
Generates random rotation matrices and evaluates the ODF at these orientations. Useful for normalization checks and Monte Carlo integration.
Parameters
- odfODF object
ODF to evaluate
- n_orientationsint, optional
Number of random orientations to generate, default 1000
- seedint, optional
Random seed for reproducibility
Returns
- tuple of (numpy.ndarray, numpy.ndarray)
orientations : Random rotation matrices, shape (n_orientations, 3, 3) values : ODF values at these orientations, shape (n_orientations,)
Examples
>>> odf = UniformODF('oh', 'triclinic') >>> orientations, values = eval_random_orientations(odf, n_orientations=100) >>> print(f"Mean ODF value: {np.mean(values)}") # Should be ~1.0 (MRD)