pyextal.gof

Goodness-of-Fit (GOF) Metrics Module.

This module provides a collection of classes for calculating goodness-of-fit metrics between simulated and experimental diffraction data. It is designed to be extensible, allowing for new GOF metrics to be added easily.

GOF Class Interface

All GOF classes in this module are expected to follow a common interface to ensure they can be used interchangeably throughout the refinement process. While not formally enforced by an Abstract Base Class, this interface includes:

  • `name` (str): A class attribute that provides a human-readable name for the metric (e.g., “Chi Square”, “Cross Correlation”).

  • `__call__(self, simulation, experiment, mask=None)`: The main method that calculates the GOF value. It takes the simulation and experiment as input and returns a single float value representing the goodness of fit.

  • `scaling(self, simulation, experiment, mask=None)`: An optional method that can be implemented by subclasses to scale the simulation intensity to the experimental intensity before the GOF calculation. If not implemented, no scaling is performed.

The BaseGOF class is provided as a simple parent class that new metrics can inherit from, but this is not a requirement.

Classes

BaseGOF()

Base class for Goodness-of-Fit (GOF) metrics.

Chi2()

Chi-squared goodness-of-fit with a single background and Poisson noise.

Chi2_LARBED(roi)

Chi-squared GOF for LARBED data with a single background.

Chi2_LARBED_multibackground(roi)

Chi-squared GOF for LARBED with per-disk backgrounds.

Chi2_const(dinfo)

Chi-squared GOF with a single background and DQE-based variance.

Chi2_multibackground(dinfo)

Chi-squared GOF with a separate background for each diffraction disk.

XCorrelation()

Calculates the cross-correlation between two datasets.