scipy.ndimage.convolve1d

scipy.ndimage.convolve1d(input, weights, axis=-1, output=None, mode='reflect', cval=0.0, origin=0)[source]

Calculate a one-dimensional convolution along the given axis.

The lines of the array along the given axis are convolved with the given weights.

Parameters:

input : array_like

Input array to filter.

weights : ndarray

One-dimensional sequence of numbers.

axis : int, optional

The axis of input along which to calculate. Default is -1.

output : array, optional

The output parameter passes an array in which to store the filter output. Output array should have different name as compared to input array to avoid aliasing errors.

mode : {‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}, optional

The mode parameter determines how the array borders are handled, where cval is the value when mode is equal to ‘constant’. Default is ‘reflect’

cval : scalar, optional

Value to fill past edges of input if mode is ‘constant’. Default is 0.0

origin : scalar, optional

The origin parameter controls the placement of the filter. Default 0.0.

Returns:

convolve1d : ndarray

Convolved array with same shape as input

Examples

>>> from scipy.ndimage import convolve1d
>>> convolve1d([2, 8, 0, 4, 1, 9, 9, 0], weights=[1, 3])
array([14, 24,  4, 13, 12, 36, 27,  0])