pybaselines.Baseline.derpsalsa
- Baseline.derpsalsa(data, lam=1000000.0, p=0.01, k=None, diff_order=2, max_iter=50, tol=0.001, weights=None, smooth_half_window=None, num_smooths=16, pad_kwargs=None, **kwargs)[source]
Derivative Peak-Screening Asymmetric Least Squares Algorithm (derpsalsa).
- Parameters:
- dataarray_like, shape (N,)
The y-values of the measured data, with N data points. Must not contain missing data (NaN) or Inf.
- lam
float, optional The smoothing parameter. Larger values will create smoother baselines. Default is 1e6.
- p
float, optional The penalizing weighting factor. Must be between 0 and 1. Values greater than the baseline will be given p weight, and values less than the baseline will be given 1 - p weight. Default is 1e-2.
- k
float, optional A factor that controls the exponential decay of the weights for baseline values greater than the data. Should be approximately the height at which a value could be considered a peak. Default is None, which sets k to one-tenth of the standard deviation of the input data. A large k value will produce similar results to
asls().- diff_order
int, optional The order of the differential matrix. Must be greater than 0. Default is 2 (second order differential matrix). Typical values are 2 or 1.
- max_iter
int, optional The max number of fit iterations. Default is 50.
- tol
float, optional The exit criteria. Default is 1e-3.
- weightsarray_like, shape (N,), optional
The weighting array. If None (default), then the initial weights will be an array with size equal to N and all values set to 1.
- smooth_half_window
int, optional The half-window to use for smoothing the data before computing the first and second derivatives. Default is None, which will use
len(data) / 200.- num_smooths
int, optional The number of times to smooth the data before computing the first and second derivatives. Default is 16.
- pad_kwargs
dict, optional A dictionary of keyword arguments to pass to
pad_edges()for padding the edges of the data to prevent edge effects from smoothing. Default is None.- **kwargs
Deprecated since version 1.2.0: Passing additional keyword arguments is deprecated and will be removed in version 1.4.0. Pass keyword arguments using pad_kwargs.
- Returns:
- baseline
numpy.ndarray, shape (N,) The calculated baseline.
- params
dict A dictionary with the following items:
- 'weights': numpy.ndarray, shape (N,)
The weight array used for fitting the data.
- 'tol_history': numpy.ndarray
An array containing the calculated tolerance values for each iteration. The length of the array is the number of iterations completed. If the last value in the array is greater than the input tol value, then the function did not converge.
- baseline
- Raises:
ValueErrorRaised if p is not between 0 and 1. Also raised if k is not greater than 0.
References
Korepanov, V. Asymmetric least-squares baseline algorithm with peak screening for automatic processing of the Raman spectra. Journal of Raman Spectroscopy. 2020, 51(10), 2061-2065.