qspec logo qspec logo

A physics toolbox for laser spectroscopy.

Static Badge Static Badge Static Badge

Static Badge Static Badge

© 2026 Patrick Müller. All rights reserved.

qspec.analyze. King  (  a ,  m ,  x_abs=None ,  subtract_electrons=0.0 ,  n_samples=100000 ,  element_label=None  )[source]

A class for $n$-dimensional King plots, encapsulating the linear regression algorithms of the qspec.analyze module. Call King.fit or King.fit_nd for $2$- or $n$-dimensional fitting.

Parameters:
aarray_like

An iterable of the mass numbers $A$ of the considered isotopes with shape (k, ), where k is the number of isotopes.

marray_like

The masses and their uncertainties of the isotopes a (u). m must have shape (k, 2).

x_absarray_like | None

The absolute values of the data vectors and their standard deviations corresponding to the mass numbers a. If given, the x and y parameters can be omitted in King.fit and King.fit_nd, and are determined automatically as the shift between the mass numbers a and a_ref. Must have shape (k, n, 2) where n is the number of dimensions of the King plot.

subtract_electronsscalar

The number of electron masses that should be subtracted from the specified isotope masses. subtract_electrons can be a float if the ionization energy shall be considered.

n_samplesint

The number of generated samples for the Monte-Carlo routines.

element_labelstr | None

The label of the element to enhance the printed and plotted information.

Attributes:
FIT_NOT_DONE_ERROR"No fit was performed yet. Use one of the fitting options {'King.fit', 'King.fit_nd'}."

The error message if a method requires a fit that was not performed yet.

NOT_ENOUGH_DATA_POINTS_ERROR'Cannot perform a linear fit with less than 3 data points. Only {} isotopes and {} reference isotopes were specified.'

The error message if less than 3 data points are given.

NO_X_ABS_ERROR'To fit, either specify `{}` or `King.x_abs`. Both are `None`.'

The error message if neither the data nor King.x_abs are given.

andarray[integer]

The mass numbers of the considered isotopes.

a_fitndarray[integer] | None

The mass numbers of the isotopes of the last fit.

a_refndarray[integer] | None

The mass numbers of the reference isotopes of the last fit.

alphafloat | None

The $x$-axis offset $\alpha$ of the last fit.

axisint

The vector component used for the parameterization in the last $n$-dimensional fit.

corrndarray[floating] | None

The correlation coefficients of the modified $x$ and $y$ data of the last 2-dimensional fit.

covndarray[floating] | None

The covariance matrices of the modified data vectors of the last $n$-dimensional fit.

element_labelstr

The label of the element.

mndarray[floating]

The masses and their uncertainties of the isotopes (u).

m_modndarray[floating]

The mass factors and their uncertainties of all isotope pairs, see qspec.physics.mass_factor.

m_subndarray[floating]

The masses and their uncertainties of the isotopes after subtracting King.subtract_electrons electrons (u).

nint

The number of dimensions of the King plot.

n_samplesint

The number of generated samples for the Monte-Carlo routines.

ndbool

Whether the last fit was performed with King.fit_nd.

pcovndarray[floating] | None

The covariance matrix of the optimized parameters of the last fit.

poptndarray[floating] | None

The optimized parameters of the last fit.

subtract_electronsfloat

The number of electron masses subtracted from the isotope masses.

xndarray[floating] | None

The data vectors and their standard deviations of the last fit.

x_absndarray[floating] | None

The absolute values of the data vectors and their standard deviations.

x_modndarray[floating] | None

The modified data vectors and their standard deviations of the last fit.

Raises:
ValueError

If the mass numbers a are not unique.