pybaselines.Baseline2D.poly
- Baseline2D.poly(data, poly_order=2, weights=None, return_coef=False, max_cross=None)[source]
Computes a polynomial that fits the baseline of the data.
- Parameters:
- dataarray_like, shape (M, N)
The y-values of the measured data.
- poly_order
intor sequence[int,int], optional The polynomial orders for x and z. If a single value, will use that for both x and z. Default is 2.
- weightsarray_like, shape (M, N), optional
The weighting array. If None (default), then will be an array with shape equal to (M, 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 x and z values and return them in the params dictionary. Default is False, since the conversion takes time.
- max_cross
int, optional The maximum degree for the cross terms. For example, if max_cross is 1, then x z**2, x**2 z, and x**2 z**2 would all be set to 0. Default is None, which does not limit the cross terms.
- Returns:
- baseline
numpy.ndarray, shape (M, N) The calculated baseline.
- params
dict A dictionary with the following items:
- 'weights': numpy.ndarray, shape (M, N)
The weight array used for fitting the data.
- 'coef': numpy.ndarray, shape (
poly_order[0] + 1,poly_order[1] + 1) 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.polyval2d().
- 'coef': numpy.ndarray, shape (
- baseline
Notes
To only fit regions without peaks, supply a weight array with zero values at the indices where peaks are located.