pybaselines.utils.pad_edges

pybaselines.utils.pad_edges(data, pad_length, mode='extrapolate', extrapolate_window=None, **pad_kwargs)[source]

Adds left and right edges to the data.

Parameters:
dataarray_like

The array of the data.

pad_lengthint

The number of points to add to the left and right edges.

modestr or callable, optional

The method for padding. Default is 'extrapolate'. Any method other than 'extrapolate' will use numpy.pad().

extrapolate_windowint, optional

The number of values to use for linear fitting on the left and right edges. Default is None, which will set the extrapolate window size equal to pad_length.

**pad_kwargs

Any keyword arguments to pass to numpy.pad(), which will be used if mode is not 'extrapolate'.

Returns:
padded_datanumpy.ndarray, shape (N + 2 * half_window,)

The data with padding on the left and right edges.

Notes

If mode is 'extrapolate', then the left and right edges will be fit with a first order polynomial and then extrapolated. Otherwise, uses numpy.pad().