pybaselines.utils.whittaker_smooth
- pybaselines.utils.whittaker_smooth(data, lam=1000000.0, diff_order=2, weights=None, check_finite=True)[source]
Smooths the input data using Whittaker smoothing.
The input is smoothed by solving the equation
(W + lam * D.T @ D) y_smooth = W @ y, where W is a matrix with weights on the diagonals and D is the finite difference matrix.- Parameters:
- dataarray_like, shape (N,)
The y-values of the measured data, with N data points.
- lam
float, optional The smoothing parameter. Larger values will create smoother baselines. Default is 1e6.
- diff_order
int, optional The order of the finite difference matrix. Must be greater than or equal to 0. Default is 2 (second order differential matrix). Typical values are 2 or 1.
- weightsarray_like, shape (N,), optional
The weighting array, used to override the function's baseline identification to designate peak points. Only elements with 0 or False values will have an effect; all non-zero values are considered baseline points. If None (default), then will be an array with size equal to N and all values set to 1.
- check_finitebool, optional
If True, will raise an error if any values if data or weights are not finite. Default is False, which skips the check.
- Returns:
- y_smooth
numpy.ndarray, shape (N,) The smoothed data.
- y_smooth
References
Eilers, P. A Perfect Smoother. Analytical Chemistry, 2003, 75(14), 3631-3636.