erlab.analysis.fit.models

Models for fitting data.

Functions

fit_edges_linear(x, data, len_fit)

Fit \(y = mx + n\) to each edge of the data.

fit_poly_jit(x, y, deg)

numba-accelerated polynomial fitting.

Classes

BCSGapModel(**kwargs)

Interpolation formula for a temperature dependent BCS-like gap.

DynesModel(**kwargs)

Dynes formula for superconducting density of states.

FermiEdge2dModel([degree, independent_vars])

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])

param independent_vars:

Arguments to the model function that are independent variables

StepEdgeModel([independent_vars, prefix, ...])

param independent_vars:

Arguments to the model function that are independent variables

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

Bases: Model

Interpolation formula for a temperature dependent BCS-like gap.

\[\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]:

\[f(x) = 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.FermiEdge2dModel(degree=2, independent_vars=('eV', 'alpha'), **kwargs)[source]

Bases: Model

fit(data, *args, **kwargs)[source]
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 – Initial, guessed values for the parameters of a Model.

Return type:

Parameters

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.

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

static LinearBroadFermiDirac(x, center=0.0, temp=30.0, resolution=0.02, back0=0.0, back1=0.0, dos0=1.0, dos1=0.0)[source]
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 – Initial, guessed values for the parameters of a Model.

Return type:

Parameters

class erlab.analysis.fit.models.MultiPeakModel(npeaks=1, peak_shapes=None, fd=True, convolve=True, **kwargs)[source]

Bases: Model

Model for fitting multiple Gaussian or Lorentzian peaks.

Most input parameters are passed to the MultiPeakFunction constructor.

eval_components(params=None, **kwargs)[source]
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 – Initial, guessed values for the parameters of a Model.

Return type:

Parameters

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 – Initial, guessed values for the parameters of a Model.

Return type:

Parameters

class erlab.analysis.fit.models.StepEdgeModel(independent_vars=('x',), prefix='', missing='raise', **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 – Initial, guessed values for the parameters of a Model.

Return type:

Parameters