pycroxe.fitfunctions#

Fit function templates#

Every fit function stored in CroXe fit_templates table has a corresponding Python callable registered in this module under its function_name key. All registered functions share the same signature:

fn(
    energies    : ArrayLike,          # projectile energy in eV
    coefficients: ArrayLike,          # fit coefficients from DB
    **ctx,                            # template-specific context
) -> NDArray[np.float64]              # cross-section in m²

This allows for the evaluation layers of the various pycroxe sub-modules (such as pycroxe.beam) to dispatch calls without needing to know which template is being used.

Protocol classes#

FitFunction(*args, **kwargs)

Protocol class describing the uniform signature for every registered fit function.

Constants#

REGISTRY

Dictionary mapping CroXe.fit_templates.function_name values to their Python implementation.

Functions#

get_fit_function(function_name)

For a given template name from CroXe.fit_templates.function_name, return its API implementation.

Usage#

pycroxe.fitfunctions provides a simple interface to interact with the fit functions stored in it: by providing to pycroxe.fitfunctions.get_fit_function() a string corresponding to any of the values in the column function_name of table fit_templates in CroXe, you will retrieve the implementation in this API of that very function.

If you wish to implement a new function without directly modifying pycroxe, you can add it to pycroxe.fitfunctions.REGISTRY:

REGISTRY["NEWTAG"] = new_function

just remember that your new_function must follow the pycroxe.fitfunctions.FitFunction protocol, which you can directly use in your code for type hinting.

Notes#

CroXe and this API store and accept energies in eV and cross-section in m². In the case of authors using different units of measurments (usually cm² for cross-sections, and eV/amu [1] or keV [2] for energies), the conversion is handled internally by each fit function.

Tabata’s functions in this module are registered with a leading triad of numbers assigned in such a way that the first number indicates in which volume of the “Atomic and Molecular Collision Cross Sections” the function appears, the second number corresponds to the n-th paper within the volume, and the last one is the label assigned by Tabata himself to the function, within the paper. Following this convention, function tab2_1_4 is, hence, function 4 in the first paper of “Atomic and Molecular Collision Cross Sections (2)[2].

Checking whether some energy value falls within the domain of some registered function or not, is responsibility of the evaluation layer of each pycroxe sub-module

Currently implemented functions:

  • REGISTRY["CHEB"]: a Chebyshev polynomial-based fit described by C. F. Barnett in [1]

  • REGISTRY["TAB2_1_*"]: the 14 analytic expressions described by T. Tabata in the first paper of [2]

References#