erlab.analysis.fit.models¶
Models for fitting data.
Classes
|
Interpolation formula for temperature dependent BCS-like gap magnitude. |
|
Dynes formula for superconducting density of states. |
|
Model that represents a Fermi-Dirac distribution convolved with a Gaussian. |
|
A 2D model for a polynomial Fermi edge with a linear density of states. |
|
Model for fitting a Fermi edge with a linear background. |
|
Multiple peaks with optional Fermi-Dirac distribution and background. |
|
|
|
|
|
Resolution-broadened superconducting spectral function. |
|
Resolution-broadened Tomonaga-Luttinger liquid (TLL) spectral function. |
- class erlab.analysis.fit.models.BCSGapModel(**kwargs)[source]¶
Bases:
ModelInterpolation 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:
ModelDynes formula for superconducting density of states.
The formula is given by [Dynes et al., 1978]:
\[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:
ModelModel 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
FermiEdgeModelA 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:
ModelA 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.
- class erlab.analysis.fit.models.FermiEdgeModel(**kwargs)[source]¶
Bases:
ModelModel 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
FermiDiracModelA 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, oversample=3, segmented=False, **kwargs)[source]¶
Bases:
ModelMultiple peaks with optional Fermi-Dirac distribution and background.
- Parameters:
npeaks (
int, default:1) – The number of peaks to fit.peak_shapes (
list[str] |str|None, default:None) – The shape(s) of the peaks in the model. If a list of strings is provided, each string represents the shape of a peak. If a single string is provided, it will be split by spaces to create a list of peak shapes. If not provided, the default peak shape will be used for all peaks.fd (
bool, default:True) – Flag indicating whether the model should be multiplied by the Fermi-Dirac distribution. This adds three parameters to the model:efermi,temp, andoffset, each corresponding to the Fermi level, temperature in K, and constant background.background (
Literal['none','constant','linear','polynomial','shirley'], default:"linear") –The type of background to include in the model. Possible values are:
Value
Additional parameters
’none’
None
’constant’
const_bkg’linear’
lin_bkg,const_bkg’polynomial’
c0,c1, … depending ondegree’shirley’
const_bkg,lin_bkg,k_slope, andk_step_iwith i from 0 tonpeaks- 1Note
The ‘shirley’ background is calculated by
erlab.analysis.fit.functions.general.active_shirley()See its documentation for details about the parameters.degree (
int, default:2) – The degree of the polynomial background. Only used ifbackgroundis'polynomial'. Default is 2.convolve (
bool, default:True) – Flag indicating whether the model should be convolved with a gaussian kernel. IfTrue, adds aresolutionparameter to the model, corresponding to the FWHM of the gaussian kernel.oversample (
int, default:3) – Factor by which to oversamplexduring convolution to reduce numerical artifacts.segmented (
bool, default:False) – Flag indicating whether to convolve the model in segments. IfTrue, the model will be convolved in segments of uniform spacing. This must be set toTruewhen fitting data with large gaps or discontinuities in the x-axis.**kwargs – Additional keyword arguments to be passed to the
lmfit.model.Modelconstructor.
-
func:
MultiPeakFunction¶
- 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]¶
Evaluate model components.
Changed in version 3.20.0: Background components are returned as separate entries (for example,
{prefix}_baseline,{prefix}_shirley,{prefix}_slopeor{prefix}_constant/{prefix}_linear/{prefix}_polynomial) instead of a single{prefix}_bkgentry that represented the sum of all background components.
- class erlab.analysis.fit.models.PolynomialModel(degree=9, **kwargs)[source]¶
Bases:
Model- Parameters:
independent_vars (
listofstr, 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_policysets what to do when a NaN or missing value is seen in the data. Should be one of:'raise': raise aValueError(default)'propagate': do nothing'omit': drop missing data
-
func:
PolynomialFunction¶
- 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 (
listofstr, 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_policysets what to do when a NaN or missing value is seen in the data. Should be one of:'raise': raise aValueError(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.
- class erlab.analysis.fit.models.SymmetrizedGapModel(**kwargs)[source]¶
Bases:
ModelResolution-broadened superconducting spectral function.
The superconducting spectral function with a linear background is calculated as:
\[I(x) = \left[ A \cdot A_{sc}(x, \Sigma) + \left(m \cdot |x| + b \right) \right] \otimes \text{g}(\sigma)\]where \(A_{sc}(x, \Sigma)\) is the superconducting spectral function calculated using the self-energy \(\Sigma(x)\) given by
sc_self_energy(). \(\text{g}(\sigma)\) is a Gaussian kernel with standard deviation \(\sigma\). Note that the resolution parameter is the FWHM of the Gaussian kernel, not the standard deviation.- Parameters:
x (
array-like) – The input array of energy in eV.amp – The overall scale factor \(A\).
gamma1 – \(\Gamma_1\), the single-particle scattering rate.
gamma0 – \(\Gamma_0\), the pair-breaking scattering rate.
delta – The energy gap \(\Delta\).
lin_bkg – The slope of the linear background \(m\).
const_bkg – The constant background \(b\).
resolution – The broadening in eV. Note that this is the FWHM of the Gaussian kernel, not the standard deviation.
- class erlab.analysis.fit.models.TLLModel(**kwargs)[source]¶
Bases:
ModelResolution-broadened Tomonaga-Luttinger liquid (TLL) spectral function.
The TLL spectral function is calculated as [Ohtsubo et al., 2015]:
\[I(x,T) = \left[A T^\alpha \cosh\left(\frac{\epsilon}{2}\right) \left|\Gamma\left(\frac{1 + \alpha}{2} + i \frac{\epsilon}{2\pi}\right)\right|^2 f(\epsilon,T)\right] \otimes \text{g}(\sigma) + B\]where \(\epsilon=(x - x_0)/k_B T\) is the temperature-normalized energy, \(\Gamma\) is the gamma function, \(f(\epsilon,T) = 1/(e^{\epsilon}+1)\) is the Fermi-Dirac distribution, \(\text{g}(\sigma)\) is a Gaussian kernel with standard deviation \(\sigma\), and \(B\) is a constant background.
Note that the resolution parameter is the FWHM of the Gaussian kernel, not the standard deviation.
- Parameters:
x – The energy values at which to calculate the TLL spectral function.
amp – The amplitude.
center – The center.
alpha – The power law exponent.
temp – The temperature in K.
resolution – The resolution of the Gaussian kernel in eV. Note that this is the FWHM of the Gaussian kernel, not the standard deviation.
const_bkg – A constant background to add to the broadened TLL function.