pybaselines.Baseline.poly
- Baseline.poly(data, poly_order=2, weights=None, return_coef=False)[source]
Computes a polynomial that fits the baseline of the data.
- Parameters:
- dataarray_like, shape (N,)
The y-values of the measured data, with N data points.
- poly_order
int
, optional The polynomial order for fitting the baseline. Default is 2.
- weightsarray_like, shape (N,), optional
The weighting array. If None (default), then will be an array with size equal to N and all values set to 1.
- return_coefbool, optional
If True, will convert the polynomial coefficients for the fit baseline to a form that fits the input x_data and return them in the params dictionary. Default is False, since the conversion takes time.
- 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.
- 'coef': numpy.ndarray, shape (poly_order,)
Only if return_coef is True. The array of polynomial parameters for the baseline, in increasing order. Can be used to create a polynomial using
numpy.polynomial.polynomial.Polynomial
.
- baseline
Notes
To only fit regions without peaks, supply a weight array with zero values at the indices where peaks are located.