pybaselines.Baseline2D.rolling_ball
- Baseline2D.rolling_ball(data, half_window=None, smooth_half_window=None, pad_kwargs=None, window_kwargs=None, **kwargs)[source]
The rolling ball baseline algorithm.
Applies a minimum and then maximum moving window, and subsequently smooths the result, giving a baseline that resembles rolling a ball across the data.
- Parameters:
- dataarray_like, shape (M, N)
The y-values of the measured data.
- half_window
int
or sequence[int
,int
], optional The half-window used for the rows and columns, respectively, for the morphology functions. If a single value is given, rows and columns will use the same value. Default is None, which will optimize the half-window size using
optimize_window()
and window_kwargs.- smooth_half_window
int
, optional The half-window to use for smoothing the data after performing the morphological operation. Default is None, which will use the same value as used for the morphological operation.
- 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 the moving average.- 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 (M, N) The calculated baseline.
dict
A dictionary with the following items:
- 'half_window': np.ndarray[int, int]
The half windows used for the morphological calculations.
- baseline
References
Kneen, M.A., et al. Algorithm for fitting XRF, SEM and PIXE X-ray spectra backgrounds. Nuclear Instruments and Methods in Physics Research B, 1996, 109, 209-213.
Liland, K., et al. Optimal Choice of Baseline Correction for Multivariate Calibration of Spectra. Applied Spectroscopy, 2010, 64(9), 1007-1016.