poisson_criterion#
- cbclib.bin.poisson_criterion(x: numpy.ndarray, ij: numpy.ndarray, shape: Tuple[int, int], I0: numpy.ndarray, bgd: numpy.ndarray, xtal_bi: numpy.ndarray, prof: numpy.ndarray, fidxs: numpy.ndarray, idxs: numpy.ndarray, hkl_idxs: numpy.ndarray, oidxs: Optional[numpy.ndarray] = None, num_threads: int = 1)[source]#
Calculate the Poisson negative log likelihood that the measured intensities
I0are explained by the current estimate of crystal structure factorsxand sample projection mapsxtal_bi.- Parameters
x (numpy.ndarray) – Current estimate of crystal structure factors and intercept values.
ij (numpy.ndarray) – Detector coordinates.
I0 (numpy.ndarray) – Measured diffracted signal.
bgd (numpy.ndarray) – Background level.
xtal_bi (numpy.ndarray) – Sample’s projection maps.
prof (numpy.ndarray) – Standard profiles.
fidxs (numpy.ndarray) – Frame indices.
idxs (numpy.ndarray) – Streak indices.
hkl_idxs (numpy.ndarray) – Set of indices that numerate different Bragg reflections.
oidxs (Optional[numpy.ndarray]) – Output criterion indices.
num_threads (int) – Number of threads used in the calculations.
Notes
The intensity profile \(I_{hkl}(\mathbf{x})\) of a particular Bragg reflection captured on the detector is given by:
\[I_{hkl}(\mathbf{x}) = |q_{hkl}|^2 \chi(\mathbf{u}(\mathbf{x})) f^2_{hkl}(\mathbf{x})\]where \(q_{hkl}\) are the structure factors and \(\chi(\mathbf{u}(\mathbf{x}))\) are the projection maps of the sample, and \(f_{hkl}(\mathbf{x})\) are the standard reflection profiles.
The Poisson negative log likelihood crietion is given by:
\[\epsilon^{NLL} = \sum_{ni} \log \mathrm{P}(I_n(\mathbf{x}_i), I_{hkl}(\mathbf{x}_i) + I_{bgd}(\mathbf{x}_i)),\]where the likelihood \(\mathrm{P}\) follows the Poisson distribution \(\log \mathrm{P}(I, \lambda) = I \log \lambda - I\).
- Returns
Negative log likelihood and gradient arrays.
- Return type
Tuple[numpy.ndarray, numpy.ndarray]