calamari.fitting.models#

Built-in magnetometry fit functions and the model registry.

Each model is a plain callable f(x, *params) -> ndarray paired with a ModelDefinition carrying its parameter names, generic starting values, a provenance-bearing description, and (optionally) a data-driven guess seed. Models live in the name-keyed MODELS registry and are looked up by name from calamari.fitting.engine.fit().

Design follows the asymmetry toolkit’s fitting core: a registry of plain callables plus metadata, so a model function stays independently testable and re-usable (you can call curie_weiss() directly) while the registry gives the fit engine a uniform, name-addressable surface. Physics symbol names (C, J, T_K, M_s) are kept against PEP8 deliberately – the lint waiver is quarantined to this file in pyproject.toml.

All magnetometry here is CGS-Gaussian (moments in emu, fields in Oe), matching Quantum Design instruments; the constants used by brillouin() come from calamari.constants and nowhere else.

Module attributes

MODELS

Name-keyed registry of every known model.

MIN_POINTS_PER_SEGMENT

The fewest points a segment of segmented_linear() may keep on each side of the corner.

BENT_CABLE_GAMMA_START_SPACINGS

Where the bent_cable() guess starts gamma, in median sample spacings of x.

BENT_CABLE_GAMMA_FLOOR_SPACINGS

The smallest gamma fit_breakpoint() allows, in median sample spacings of x.

Functions

bent_cable

Two straight lines joined by a parabolic bend of half-width gamma (a "bent cable").

brillouin

Brillouin-function magnetisation \(M(H)=M_{\mathrm{s}}B_J(y)\).

curie_weiss

Curie-Weiss susceptibility \(\chi(T)=C/(T-\theta)+\chi_0\).

inverse_curie_weiss

Inverse Curie-Weiss law 1/chi(T) = (T - theta) / C.

linear

Straight line y = slope * x + intercept.

register_model

Insert defn into MODELS, rejecting a duplicate name.

segmented_linear

Two straight lines joined at a sharp corner (a continuous "broken stick").

Classes

ModelDefinition

Descriptor for a built-in (or user-registered) fit function.