raman.fit_peaks¶
-
raman.
fit_peaks
(x, y, popt0, fit_func, bounds=None, estimate_bl=False, use_popt0=True, inc_blorder=1, max_blorder=-1, global_opt=True)¶ Try to fit Raman peaks with (automatic) baseline fitting.
Parameters: - x (array) – x-axis.
- y (array) – Data. If y is a list or 2d array of spectra, fit every spectrum.
- popt0 (array) – Initial parameters for fitting, for example obtained from
get_peak_estimate()
. - fit_func (function) – Fitting function to be used to fit the data. If estimate_bl is True, this function should only fit the peaks, not the baseline.
- bounds (array) – Array of tuples giving the minimum and maximum allowed value for each parameter in popt0. If not None, use
scipy.optimize.differential_evolution()
to fit the peaks. (default = None). - estimate_bl (bool) – If True, attempt an automatic baseline fitting using n-th order polynomials. This baseline is added to any basline contained in fit_func.
- use_popt0 (bool) – If fitting multiple spectra, control whether the initial parameters are always the ones provided in popt0 (True, default) or the ones from the last spectrum (False).
- inc_blorder (int) – When fitting the baseline, the order of the polynomial is increased by inc_blorder until no further improvement can be achieved (default = 1).
- max_blorder (int) – Maximum permitted order of the baseline polynomial. Set to -1 for no restriction (default).
- global_opt (bool) – If True, attempt a simultaneous fit of baseline AND peaks once a decent fit for each has been found.
Returns: The fitted spectrum, same shape as y, and the final peak fit parameters (popt0). If y is a list or 2d array of spectra, the returned array has the shape [[yfit], [popt]].