SampleRefiner#
- class cbclib.SampleRefiner(parent, bounds, rmats, smp_ds, basis, fidxs, frames, hkl, width, alpha=0.0)[source]#
Sample refinement class. It employs
cbclib.CBDModelCBD pattern prediction to find how well the current estimate of sample positions and alignments fits with the experimentally measured patterns. The class provides a method to calculate the fitness criterion, which is based on cross-entropy between the experimentally measured and predicted patterns.- Parameters
parent (
ReferenceType[CBCTable]) – Reference to the parent CBC table.bounds (
InitVar) – Bounds for sample refinement variables. A set of(min, max)pairs of the shape(N, 2), whereNis the number of variables. Each of the terms is diregarded in the refinement process, if the corresponding bounds are equal to 0.basis (
Basis) – Basis vectors of lattice unit cell.fidxs (
ndarray) – Array of first indices pertaining to different patterns.frames (
ndarray) – Frame indices of the measured patterns.hkl (
ndarray) – Set of reciprocal lattice points used in the prediction.rmats (
ndarray) – A set of sample’s rotation matrices.smp_ds (
ndarray) – A set of focus-to-sample distances [m].width (
float) – Diffraction streak width in pixels. The value is used to generate a predicted CBC pattern.alpha (
float) – Regularisation term in the loss function.
- filter_hkl(x)#
Update a set of reciprocal lattice points used in the prediction. The points are taken from inside the sphere of radius
q_abs, that fall into the Bragg condition.- Parameters
x (
ndarray) – Refinement solution.
- fitness(x, num_threads=1)#
Calculate the marginal log-likelihood, that the experimentally measured pattern corresponds to the predicted CBD pattern.
- classmethod generate_bounds(z_tol, tilt_tol, frames, x0=None)[source]#
Return a set of bounds for sample refinement variables based on the given set of tolerances.
- Parameters
- Return type
- Returns
A set of
(min, max)pairs for sample refinement variables.
- generate_models(x)#
Return a CBD pattern prediction model, that provides an interface to generate a CBD pattern in different formats.
- generate_samples(x)[source]#
Return a sample position and alignment.
- Parameters
x (
ndarray) – Refinement solution.- Return type
- Returns
A new sample object.
- generate_streaks(x)#
Generate a CBD pattern and return a set of predicted diffraction streaks.
- get_bounds()#
Return lower and upper sample refinement bounds.
- patterns_dataframe(x)#
Generate a CBD pattern in
pandas.DataFrametable format.