pybaselines.Baseline.airpls
- Baseline.airpls(data, lam=1000000.0, diff_order=2, max_iter=50, tol=0.001, weights=None, normalize_weights=False)[source]
Adaptive iteratively reweighted penalized least squares (airPLS) baseline.
- 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.
- 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.
- normalize_weightsbool, optional
If True, will normalize the computed weights between 0 and 1 to potentially improve the numerical stabilty. Set to False (default) to use the original implementation, which sets weights for all negative residuals to be greater than 1.
- 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
References
Zhang, Z.M., et al. Baseline correction using adaptive iteratively reweighted penalized least squares. Analyst, 2010, 135(5), 1138-1146.