pybaselines.Baseline2D.drpls
- Baseline2D.drpls(data, lam=100000.0, eta=0.5, max_iter=50, tol=0.001, weights=None, diff_order=2)[source]
Doubly reweighted penalized least squares (drPLS) baseline.
- Parameters:
- dataarray_like, shape (M, N)
The y-values of the measured data. Must not contain missing data (NaN) or Inf.
- lam
floator sequence[float,float], optional The smoothing parameter for the rows and columns, respectively. If a single value is given, both will use the same value. Larger values will create smoother baselines. Default is 1e5.
- eta
float A term for controlling the value of lam; should be between 0 and 1. Low values will produce smoother baselines, while higher values will more aggressively fit peaks. Default is 0.5.
- 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.
- diff_order
intor sequence[int,int], optional The order of the differential matrix for the rows and columns, respectively. If a single value is given, both will use the same value. Must be greater than 1. Default is 2 (second order differential matrix). Typical values are 2 or 3.
- Returns:
- baseline
numpy.ndarray, shape (M, N) The calculated baseline.
- params
dict A dictionary with the following items:
- 'weights': numpy.ndarray, shape (M, 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 eta is not between 0 and 1 or if diff_order is less than 2.
References
Xu, D. et al. Baseline correction method based on doubly reweighted penalized least squares, Applied Optics, 2019, 58, 3913-3920.