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. |
|
Model a polynomial with coefficients in ascending order. |
|
Model a Gaussian-broadened step between two linear backgrounds. |
|
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\).
The independent variable
x,center, andresolutionare in eV.tempis in K.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.
- Parameters:
degree (
int, default:2) – Degree of the polynomial that describes the Fermi-edge position as a function ofalpha.**kwargs – Additional keyword arguments passed to
lmfit.model.Model. The independent variables default to["eV", "alpha"].
Notes
eV, the polynomial edge position, andresolutionare in eV.alphais in degrees,tempis in K, andresolutionis the Gaussian FWHM. Polynomial coefficientc{i}has units of eV per degree raised toi.const_bkgandoffsethave intensity units, andlin_bkghas intensity per eV units.- 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]¶
Fit the two-dimensional Fermi-edge model.
- Parameters:
data – Intensity to fit. A
xarray.DataArraymust be two-dimensional with exactly the dimensionseVandalpha. It is transposed to that order and flattened before fitting. Array-like input is flattened in its existing order.*args – Additional arguments passed to
lmfit.model.Model.fit().**kwargs – Additional arguments passed to
lmfit.model.Model.fit().
- Returns:
lmfit.model.ModelResult– The fit result. The input array is not modified.- Return type:
- 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.
Notes
The independent variable
x,center, andresolutionare in eV.resolutionis the Gaussian FWHM, andtempis in K.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. Supported shapes are"lorentzian","gaussian", and"voigt", together with their documented aliases. If omitted, all peaks are Lorentzian.fd (
bool, default:True) – Whether to multiply the peaks and background by a Fermi-Dirac distribution. This addsefermiin the units ofx,tempin K, andoffsetin the units of the dependent data. When this option is enabled,xandefermimust be in eV.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) – Whether to convolve the complete model with a Gaussian kernel. IfTrue, the model includesresolution, the Gaussian FWHM in the units ofx.oversample (
int, default:3) – Factor by which to oversamplexduring convolution to reduce numerical artifacts.segmented (
bool, default:False) – Whether to convolve the model in contiguous uniformly spaced segments. UseTruewhenxcontains large gaps or discontinuities.**kwargs – Additional keyword arguments passed to the
lmfit.model.Modelconstructor.
Notes
Peak parameters use the prefix
p{i}_, whereistarts at zero. All peak positions and widths use the units ofx.Gaussian and Lorentzian peaks use
center,width, andheight.widthis the FWHM andheightis the intensity atcenter. The correspondingsigmaorgammaandamplitudeparameters are derived.Voigt peaks use
center,sigma,gamma, andamplitude.sigmais the Gaussian standard deviation,gammais the Lorentzian HWHM, andamplitudeis the integrated peak area.widthandheightare derived.
Background parameter units follow from the dependent data and
x. For example,const_bkghas intensity units andlin_bkghas intensity per unit ofx.-
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:
ModelModel a polynomial with coefficients in ascending order.
The model is
\[y(x) = \sum_{i=0}^{n} c_i x^i,\]where
degreeis \(n\).- Parameters:
degree (default:
9) – Highest power ofx. The model contains parametersc0throughc{degree}.**kwargs – Additional keyword arguments passed to
lmfit.model.Model.
-
func:
PolynomialFunction¶
- guess(data, x=None, **kwargs)[source]¶
Estimate polynomial coefficients.
- Parameters:
data – One-dimensional data to fit.
x (default:
None) – Independent-variable values. If omitted,c0is the mean ofdataand all higher coefficients are zero. If supplied, the estimate is a least-squares polynomial fit.**kwargs – Parameter values that replace the estimates in the returned parameters.
- Returns:
lmfit.Parameters– Estimated parameters namedc0throughc{degree}.
- class erlab.analysis.fit.models.StepEdgeModel(**kwargs)[source]¶
Bases:
ModelModel a Gaussian-broadened step between two linear backgrounds.
The lower-
xbranch isdos0 + dos1 * x. The higher-xbranch isback0 + back1 * x. A complementary error function joins the two branches.Notes
centerandsigmahave the same units as the independent variablex.sigmais the standard deviation of the Gaussian broadening, not its FWHM.- guess(data, x, **kwargs)[source]¶
Estimate the step position and the two linear backgrounds.
- Parameters:
data – One-dimensional data to fit.
x – Independent-variable values. The values must have the same length as
data.**kwargs – Parameter values that replace the estimates in the returned parameters.
- Returns:
lmfit.Parameters– Estimated model parameters. The estimate uses linear fits to both ends of the data and the minimum of a smoothed derivative forcenter.
- 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.