erlab.analysis.fit.models

Models for fitting data.

Classes

BCSGapModel(**kwargs)

Interpolation formula for temperature dependent BCS-like gap magnitude.

DynesModel(**kwargs)

Dynes formula for superconducting density of states.

FermiDiracModel(**kwargs)

Model that represents a Fermi-Dirac distribution convolved with a Gaussian.

FermiEdge2dModel([degree])

A 2D model for a polynomial Fermi edge with a linear density of states.

FermiEdgeModel(**kwargs)

Model for fitting a Fermi edge with a linear background.

MultiPeakModel([npeaks, peak_shapes, fd, ...])

Model for fitting multiple Gaussian or Lorentzian peaks.

PolynomialModel([degree])

StepEdgeModel(**kwargs)

class erlab.analysis.fit.models.BCSGapModel(**kwargs)[source]

Bases: Model

Interpolation formula for temperature dependent BCS-like gap magnitude.

\[\Delta(T) \simeq a \cdot k_B T_c \cdot \tanh\left(b \sqrt{\frac{T_c}{T} - 1}\right)\]
Parameters:
  • x (array-like) – The temperature values in kelvins at which to calculate the BCS gap.

  • a – Proportionality constant. Default is 1.76.

  • b – Proportionality constant. Default is 1.74.

  • tc – The critical temperature in Kelvins. Default is 100.0.

class erlab.analysis.fit.models.DynesModel(**kwargs)[source]

Bases: Model

Dynes formula for superconducting density of states.

The formula is given by [4]:

\[N_0 \text{Re}\left[\frac{|x| + i \Gamma}{\sqrt{(|x| + i \Gamma)^2 - \Delta^2}}\right]\]

where \(x\) is the binding energy, \(N_0\) is the normal-state density of states at the Fermi level, \(\Gamma\) is the broadening term, and \(\Delta\) is the superconducting energy gap.

Parameters:
  • x (array-like) – The input array of energy in eV.

  • n0\(N_0\), by default 1.0.

  • gamma\(\Gamma\), by default 0.003.

  • delta – The superconducting energy gap \(\Delta\), by default 0.01.

class erlab.analysis.fit.models.FermiDiracModel(**kwargs)[source]

Bases: Model

Model that represents a Fermi-Dirac distribution convolved with a Gaussian.

The model function is given by

\[I(\omega) = \left\{\frac{1}{1 + e^{(\omega-\omega_0)/k_B T}}\right\} \otimes g(\sigma)\]

where \(\omega\) is the binding energy, \(\omega_0\) is the center, \(k_B\) is the Boltzmann constant, \(T\) is the temperature, and \(g(\sigma)\) is a Gaussian kernel with standard deviation \(\sigma\). Note that the resolution parameter is not the standard deviation of the Gaussian, but rather the full width at half maximum (FWHM) of the Gaussian. The relationship is given by \(\text{FWHM} = 2\sqrt{2\ln(2)}\sigma\).

See also

FermiEdgeModel

A model that includes a linear background.

guess(data, x, **kwargs)[source]

Guess starting values for the parameters of a model.

Parameters:
  • data (array_like) – Array of data (i.e., y-values) to use to guess parameter values.

  • x (array_like) – Array of values for the independent variable (i.e., x-values).

  • **kws (optional) – Additional keyword arguments, passed to model function.

Returns:

params (Parameters) – Initial, guessed values for the parameters of a Model.

class erlab.analysis.fit.models.FermiEdge2dModel(degree=2, **kwargs)[source]

Bases: Model

A 2D model for a polynomial Fermi edge with a linear density of states.

The model function can be written as

\[I = \left\{(a\omega + b)\left[1 + \exp\left(\frac{\omega - \sum_{i = 0}^{n} c_i \alpha^i}{k_B T}\right)\right]^{-1} + c\right\}\otimes g(\sigma)\]

for a \(n\) th degree polynomial edge with coefficients \(c_i\) with a linear density of states described by \(a\omega+b\) with a constant background \(c\) convolved with a gaussian, where \(\omega\) is the binding energy and \(\alpha\) is the detector angle.

guess(data, eV, alpha, **kwargs)[source]

Guess starting values for the parameters of a model.

Parameters:
  • data (array_like) – Array of data (i.e., y-values) to use to guess parameter values.

  • eV (array_like) – Array of values for the independent variable (i.e., x-values).

  • alpha (array_like) – Array of values for the independent variable (i.e., x-values).

  • **kws (optional) – Additional keyword arguments, passed to model function.

Returns:

params (Parameters) – Initial, guessed values for the parameters of a Model.

fit(data, *args, **kwargs)[source]
class erlab.analysis.fit.models.FermiEdgeModel(**kwargs)[source]

Bases: Model

Model for fitting a Fermi edge with a linear background.

The model function is a Fermi-dirac function with linear background above and below the fermi level, convolved with a gaussian kernel.

See also

FermiDiracModel

A model that does not include a linear background.

guess(data, x, **kwargs)[source]

Guess starting values for the parameters of a model.

Parameters:
  • data (array_like) – Array of data (i.e., y-values) to use to guess parameter values.

  • x (array_like) – Array of values for the independent variable (i.e., x-values).

  • **kws (optional) – Additional keyword arguments, passed to model function.

Returns:

params (Parameters) – Initial, guessed values for the parameters of a Model.

class erlab.analysis.fit.models.MultiPeakModel(npeaks=1, peak_shapes=None, *, fd=True, background='linear', degree=2, convolve=True, segmented=False, **kwargs)[source]

Bases: Model

Model for fitting multiple Gaussian or Lorentzian peaks.

Most input parameters are passed to the MultiPeakFunction constructor.

guess(data, x=None, **kwargs)[source]

Guess starting values for the parameters of a model.

Parameters:
  • data (array_like) – Array of data (i.e., y-values) to use to guess parameter values.

  • x (array_like) – Array of values for the independent variable (i.e., x-values).

  • **kws (optional) – Additional keyword arguments, passed to model function.

Returns:

params (Parameters) – Initial, guessed values for the parameters of a Model.

eval_components(params=None, **kwargs)[source]
class erlab.analysis.fit.models.PolynomialModel(degree=9, **kwargs)[source]

Bases: Model

Parameters:
  • independent_vars (list of str, optional) – Arguments to the model function that are independent variables default is [‘x’]).

  • prefix (str, optional) – String to prepend to parameter names, needed to add two Models that have parameter names in common.

  • nan_policy ({'raise', 'propagate', 'omit'}, optional) – How to handle NaN and missing values in data. See Notes below.

  • **kwargs (optional) – Keyword arguments to pass to Model.

Notes

1. nan_policy sets what to do when a NaN or missing value is seen in the data. Should be one of:

  • 'raise' : raise a ValueError (default)

  • 'propagate' : do nothing

  • 'omit' : drop missing data

guess(data, x=None, **kwargs)[source]

Guess starting values for the parameters of a model.

Parameters:
  • data (array_like) – Array of data (i.e., y-values) to use to guess parameter values.

  • x (array_like) – Array of values for the independent variable (i.e., x-values).

  • **kws (optional) – Additional keyword arguments, passed to model function.

Returns:

params (Parameters) – Initial, guessed values for the parameters of a Model.

class erlab.analysis.fit.models.StepEdgeModel(**kwargs)[source]

Bases: Model

Parameters:
  • independent_vars (list of str, optional) – Arguments to the model function that are independent variables default is [‘x’]).

  • prefix (str, optional) – String to prepend to parameter names, needed to add two Models that have parameter names in common.

  • nan_policy ({'raise', 'propagate', 'omit'}, optional) – How to handle NaN and missing values in data. See Notes below.

  • **kwargs (optional) – Keyword arguments to pass to Model.

Notes

1. nan_policy sets what to do when a NaN or missing value is seen in the data. Should be one of:

  • 'raise' : raise a ValueError (default)

  • 'propagate' : do nothing

  • 'omit' : drop missing data

guess(data, x, **kwargs)[source]

Guess starting values for the parameters of a model.

Parameters:
  • data (array_like) – Array of data (i.e., y-values) to use to guess parameter values.

  • x (array_like) – Array of values for the independent variable (i.e., x-values).

  • **kws (optional) – Additional keyword arguments, passed to model function.

Returns:

params (Parameters) – Initial, guessed values for the parameters of a Model.