pybaselines.Baseline.mpls
- Baseline.mpls(data, half_window=None, lam=1000000.0, p=0.0, diff_order=2, tol=None, max_iter=None, weights=None, window_kwargs=None, **kwargs)[source]
The Morphological penalized least squares (MPLS) baseline algorithm.
- Parameters:
- dataarray_like, shape (N,)
The y-values of the measured data, with N data points.
- half_window
int, optional The half-window used for the morphology functions. If a value is input, then that value will be used. Default is None, which will optimize the half-window size using
optimize_window()and window_kwargs.- 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. Anchor points identified by the procedure in [1] are given a weight of 1 - p, and all other points have a weight of p. Default is 0.0.
- 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.
- tol
float, optional, deprecated Deprecated since version 1.2.0:
tolis deprecated since it was not used within mpls and will be removed in pybaselines version 1.4.0.- max_iter
int, optional, deprecated Deprecated since version 1.2.0:
max_iteris deprecated since it was not used within mpls and will be removed in pybaselines version 1.4.0.- weightsarray_like, shape (N,), optional
The weighting array. If None (default), then the weights will be calculated following the procedure in [1].
- window_kwargs
dict, optional A dictionary of keyword arguments to pass to
optimize_window()for estimating the half window if half_window is None. 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 window_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.
- 'half_window': int
The half window used for the morphological calculations.
- baseline
- Raises:
ValueErrorRaised if p is not between 0 and 1.
References