Logo

A physics toolbox for laser spectroscopy.

Static Badge Static Badge Static Badge

Static Badge Static Badge

© 2025 Patrick Müller. All rights reserved.

qspec.analyze. King.fit  (  a a_ref x = None y = None xy = None func = 'york_fit' alpha = 0 find_alpha = False show = True ** kwargs  )[source]

Perform $2$-dimensional linear regression to create a King plot. Choose between {'york_fit' (default), 'linear_fit', 'linear_monte_carlo'} for the fit routine. Use a parameter alpha to optimize the correlation coefficient between the $y$-intercept and the slope.

Parameters:
andarray | Iterable

An Iterable of the mass numbers $A$ of the used isotopes.

a_refndarray | Iterable

An Iterable of the mass numbers $A_\mathrm{ref}$ of the used reference isotopes.

xndarray | Iterable

The $x$ data and their standard deviations as shape (len(a), 2) arrays. If plotted with mode == 'radii', the differences of mean-square nuclear charge radii $\delta\langle r^2\rangle^{A,A_\mathrm{ref}}$ or $\Lambda^{A,A_\mathrm{ref}}$ are expected, else isotope shifts $\delta\nu_x^{A,A_\mathrm{ref}}$ are expected. Expected units: (fm$^2$) or (MHz). If x is None, y is tried to be inherited from King.x_abs.

yndarray | Iterable

The isotope shifts $\delta\nu_y^{A,A_\mathrm{ref}}$ and their standard deviations as shape (len(a), 2) arrays. Expected units: (MHz). If None, y is tried to be inherited from King.x_abs.

xyIterable[int]

A 2-tuple of indices (ix, iy), used to select the two plot axes from King.x_abs. Only used if x or y is not specified. The default value is (0, 1), fitting the second against the first axis.

funcstr | Callable

The fitting routine. Must be one of {'york_fit' (default), 'linear_fit', 'linear_monte_carlo'}.

alphascalar

An $x$-axis offset $\alpha$ to reduce the correlation coefficient between the $y$-intercept and the slope. Expected unit: (u fm$^2$) or (u MHz).

find_alphabool

Whether to search for the best alpha. Uses the given alpha as a starting point. May not give the desired result if alpha was initialized too far from its optimal value.

showbool

Whether to plot the fit result.

kwargsNone

Additional keyword arguments are passed to King.plot.

Returns:
(popt, pcov)(ndarray, ndarray)

The best y-intercept and slope and their covariance matrix. The final alpha can be accessed through King.alpha.

API navigation