pybaselines.utils.pad_edges2d

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

Adds left, right, top, and bottom edges to the data.

Parameters:
dataarray_like, shape (M, N)

The 2D array of the data.

pad_lengthint or sequence[int, int]

The number of points to add to the top, bottom, left, and right edges. If a single value is given, all edges have the same padding. If a sequence of two values is given, the first value will be the padding on the top and bottom (rows), and the second value will pad the left and right (columns).

modestr or callable, optional

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

extrapolate_windowint or sequence[int, int] or sequence[int, int, int, int], optional

The number of values to use for linear fitting on the top, bottom, 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

The data with padding on the top, bottom, left, and right edges.

Notes

If mode is 'extrapolate', then each edge will be extended by linear fits along each row and column, and the corners are calculated by averaging the linear sections.