erlab.analysis.gold¶
Fermi edge fitting.
Functions
|
Corrects the given data array |
|
Fit a Fermi edge to the given gold data. |
|
|
|
|
|
Perform a Fermi edge fit on an EDC. |
|
Fit a Fermi edge to the given data and plot the results. |
|
Fit a Fermi edge and obtain the resolution from the corrected data. |
|
Fit a Fermi edge to the data and obtain the resolution. |
|
- erlab.analysis.gold.correct_with_edge(darr, modelresult, *, along='alpha', shift_coords=True, plot=False, plot_kw=None, **shift_kwargs)[source]¶
Corrects the given data array
darrwith the given values or fit result.- Parameters:
darr (
DataArray) – The input data array to be corrected.modelresult (
ModelResult|Dataset|ndarray[tuple[Any,...],dtype[floating]] |Callable|tuple[float,...]) – The model result that contains the Fermi edge information. It can be an instance oflmfit.model.ModelResult, a numpy array containing the edge position at each angle, a fit result dataset that contains polynomial coefficients, a callable function that takes an array of angles and returns the corresponding energy value, or a tuple of coefficients for a polynomial (lowest order first).along (
str, default:"alpha") – The angular dimension name in the data. IfNone, it is assumed to be"alpha".shift_coords (
bool, default:True) – IfTrue, the coordinates of the output data will be changed so that the output contains all the values of the original data. IfFalse, the coordinates and shape of the original data will be retained, and only the data will be shifted. Defaults toFalse.plot (
bool, default:False) – Whether to plot the original and corrected data arrays. Defaults toFalse.plot_kw (
dict|None, default:None) – Additional keyword arguments for the plot. Defaults toNone.**shift_kwargs – Additional keyword arguments to
erlab.analysis.transform.shift().
- Returns:
corrected (
xarray.DataArray) – The edge corrected data.
- erlab.analysis.gold.edge(gold, *, along='alpha', angle_range, eV_range, bin_size=(1, 1), temp=None, vary_temp=False, bkg_slope=True, resolution=0.02, fast=False, method='least_squares', scale_covar=True, normalize=True, fixed_center=None, progress=True, parallel_kw=None, parallel_obj=None, return_full=False, drop_nans=False, **kwargs)[source]¶
Fit a Fermi edge to the given gold data.
Only successful fits with valid error estimates are returned.
- Parameters:
gold (
DataArray) – The gold data to fit the edge model to.along (
str, default:"alpha") –The dimension along which to parallelize the fitting. By default
"alpha". It is better to choose the dimension with the largest number of points.If
goldis chunked, this parameter is only used to specify the dimension along which to applyangle_range.angle_range (
tuple[float,float]) – The range of values along thealongdimension to consider.eV_range (
tuple[float,float]) – The range of eV values to consider.bin_size (
tuple[int,int], default:(1, 1)) – The bin size for coarsening the gold data, by default (1, 1).temp (
float|None, default:None) – The temperature in Kelvins. IfNone, the temperature is inferred from the attributes, by defaultNonevary_temp (
bool, default:False) – Whether to fit the temperature value during fitting, by defaultFalse.bkg_slope (
bool, default:True) – Whether to include a linear background above the Fermi level. IfFalse, the background above the Fermi level is fit with a constant. Defaults toTrue.resolution (
float, default:0.02) – The initial resolution value to use for fitting, by default0.02.fast (
bool, default:False) – Whether to use the Gaussian-broadeded step function to fit the edge, by defaultFalse.method (
str, default:"least_squares") – The fitting method to use, by default"least_squares".scale_covar (
bool, default:True) – Whether to scale the covariance matrix, by defaultTrue.fixed_center (
float|None, default:None) – The fixed center value. If provided, the Fermi level will be fixed at the given value, by defaultNone.normalize (
bool, default:True) – Whether to normalize the energy coordinates, by defaultTrue.progress (
bool, default:True) – Whether to display the fitting progress, by defaultTrue.parallel_kw (
dict|None, default:None) – Additional keyword arguments for parallel fitting, by defaultNone.parallel_obj (
Parallel|None, default:None) – Thejoblib.Parallelobject to use for fitting, by defaultNone. If provided,parallel_kwwill be ignored.return_full (
bool, default:False) – Whether to return the full fit results, by defaultFalse.drop_nans (
bool, default:False) – Whether to drop fits that resulted in NaN values, by defaultFalse. IfTrue, the function will always return the computed data even for chunked inputs, because dropping NaNs requires computing all fit results. Ifreturn_fullisTrue, this option is ignored.**kwargs – Additional keyword arguments to fitting.
- Returns:
- Return type:
- erlab.analysis.gold.poly(gold, *, along='alpha', angle_range, eV_range, bin_size=(1, 1), temp=None, vary_temp=False, bkg_slope=True, resolution=0.02, fast=False, method='least_squares', normalize=True, degree=4, correct=False, crop_correct=False, parallel_kw=None, plot=True, fig=None, scale_covar=True, scale_covar_edge=True)[source]¶
- erlab.analysis.gold.poly_from_edge(center, weights=None, degree=4, method='least_squares', scale_covar=True, along='alpha')[source]¶
- erlab.analysis.gold.quick_fit(darr, *, eV_range=None, method='leastsq', temp=None, resolution=None, center=None, fix_temp=True, fix_center=False, fix_resolution=False, bkg_slope=True, plot=False, ax=None, plot_fit_kwargs=None, plot_data_kwargs=None, plot_line_kwargs=None, plot_span_kwargs=None, **kwargs)[source]¶
Perform a Fermi edge fit on an EDC.
This function is a convenient wrapper around
DataArray.xlm.modelfit()that fits a Fermi edge to the given data.If data with 2 or more dimensions is provided, the data is averaged over all dimensions except the energy prior to fitting.
- Parameters:
darr (
DataArray) – The input data to be fitted.eV_range (
tuple[float,float] |None, default:None) – The energy range to consider for fitting. IfNone, the entire energy range is used. Defaults toNone.method (
str, default:"leastsq") – The fitting method to use that is compatible withlmfit. Defaults to “leastsq”.temp (
float|None, default:None) – The temperature value to use for fitting. IfNone, the temperature is inferred from the data attributes.resolution (
float|None, default:None) – The initial resolution value to use for fitting. IfNone, the resolution is set to 0.02, or to the'TotalResolution'attribute if present.center (
float|None, default:None) – The initial center value to use for fitting. IfNone, the center is automatically guessed iffix_centerisFalse. Otherwise, the center is fixed to 0.fix_temp (
bool, default:True) – Whether to fix the temperature value during fitting. Defaults toTrue.fix_center (
bool, default:False) – Whether to fix the Fermi level during fitting. IfTrue, the Fermi level is fixed to 0. Defaults toFalse.fix_resolution (
bool, default:False) – Whether to fix the resolution value during fitting. Defaults toFalse.bkg_slope (
bool, default:True) – Whether to include a linear background above the Fermi level. IfFalse, the background above the Fermi level is fit with a constant. Defaults toTrue.plot (
bool, default:False) – Whether to plot the result of the fit. Defaults toFalse.ax (
Axes|None, default:None) – The axes to plot the result on ifplotisTrue. IfNone, the current axes are used.plot_fit_kwargs (
dict[str,Any] |None, default:None) – Additional keyword arguments for the fit plot, passed tomatplotlib.axes.Axes.plot(). Defaults toNone.plot_data_kwargs (
dict[str,Any] |None, default:None) – Additional keyword arguments for the data plot, passed tomatplotlib.axes.Axes.plot(). Defaults toNone.plot_line_kwargs (
dict[str,Any] |None, default:None) – Additional keyword arguments for the plot line that indicates the fitted center, passed tomatplotlib.axes.Axes.axvline(). Defaults toNone.plot_span_kwargs (
dict[str,Any] |None, default:None) – Additional keyword arguments for the plot span that indicates the fitted FWHM, passed tomatplotlib.axes.Axes.axvspan(). Defaults toNone.**kwargs – Additional keyword arguments to
DataArray.xlm.modelfit().
- Returns:
result (
xarray.Dataset) – The result of the fit.- Return type:
- erlab.analysis.gold.quick_resolution(darr, ax=None, **kwargs)[source]¶
Fit a Fermi edge to the given data and plot the results.
Deprecated since version 3.5.1: Use
quick_fit()withplot=Trueinstead.
- erlab.analysis.gold.resolution(gold, angle_range, eV_range_edge, eV_range_fit=None, bin_size=(1, 1), degree=4, fast=False, method='leastsq', plot=True, parallel_kw=None, scale_covar=True)[source]¶
Fit a Fermi edge and obtain the resolution from the corrected data.
Deprecated since version 3.5.1: Use
poly()andquick_fit()instead.
- erlab.analysis.gold.resolution_roi(gold_roi, eV_range, fix_temperature=True, method='leastsq', plot=True, scale_covar=True)[source]¶
Fit a Fermi edge to the data and obtain the resolution.
Deprecated since version 3.5.1: Use
quick_fit()instead.