Fitting
- EVA.core.fitting.fit_data.fit_gaussian_lmfit(x_data, y_data, peak_params, bg_params)
Fit a model containing N Gaussians using the least-squared method.
- Parameters:
x_data (
ndarray
) – x-values to fit fory_data (
ndarray
) – y-values to fit forpeak_params (
dict
) – dictionary containing each peak to fit for and fit settings for each peakbg_params (
dict
) – dictionary containing the background parameters and settings.
- Return type:
ModelResult
- Returns:
lmfit model result object.
- EVA.core.fitting.fit_data.fit_model_lmfit(x_data, y_data, peak_params, bg_params, model_params, constrain_scale=None)
Fit a sum of previously defined fixed-shape N-Gaussian spectra with scale factors and shift parameters for each spectrum using the least-squares method.
For example, if a spectrum containing multiple Gaussians has previously been fitted, this function can be used to fit the shape of that spectrum to another dataset, holding the mean and standard deviations of the previously fitted model fixed, only varying the scale factor and offset of the model.
- Parameters:
x_data (
ndarray
) – x-values to fit fory_data (
ndarray
) – y-values to fit forpeak_params (
dict
) – parameter dictionary for the gaussian peaks within each modelbg_params (
dict
) – background parametersmodel_params (
dict
) – parameter dictionary for each model containing scale and offset parametersconstrain_scale (
float
|None
) – if not None, all scale parameters will obey the constraint A + B … + Z = constrain_scale
- Return type:
ModelResult
- Returns:
lmfit model result object.
- EVA.core.fitting.fit_data.scaled_shifted_gaussians(x, scale, x0, params)
Spectrum of multiple Gaussians, one for each set of peak parameters in ‘params’, with a vertical shift parameter x0 and an overall scale factor ‘scale’
- Parameters:
x (
ndarray
) – input array to calculate forscale (
float
) – intensity scale factorx0 (
float
) – vertical offset parameterparams (
dict
) – Gaussian peak parameter dict
- Return type:
ndarray
- Returns:
Array containing total spectrum from sum of all Gaussians.