convolve¶
-
astropy.convolution.convolve(array, kernel, boundary=u'fill', fill_value=0.0, normalize_kernel=False)[source] [edit on github]¶ Convolve an array with a kernel.
This routine differs from
scipy.ndimage.filters.convolvebecause it includes a special treatment forNaNvalues. Rather than includingNaN``s in the convolution calculation, which causes large ``NaNholes in the convolved image,NaNvalues are replaced with interpolated values using the kernel as an interpolation function.Parameters: array :
numpy.ndarrayThe array to convolve. This should be a 1, 2, or 3-dimensional array or a list or a set of nested lists representing a 1, 2, or 3-dimensional array.
kernel :
numpy.ndarrayorKernelThe convolution kernel. The number of dimensions should match those for the array, and the dimensions should be odd in all directions.
boundary : str, optional
- A flag indicating how to handle boundaries:
NoneSet the
resultvalues to zero where the kernel extends beyond the edge of the array (default).
- ‘fill’
Set values outside the array boundary to
fill_value.
- ‘wrap’
Periodic boundary that wrap to the other side of
array.
- ‘extend’
Set values outside the array to the nearest
arrayvalue.
fill_value : float, optional
The value to use outside the array when using boundary=’fill’
normalize_kernel : bool, optional
Whether to normalize the kernel prior to convolving
Returns: result :
numpy.ndarrayAn array with the same dimensions and as the input array, convolved with kernel. The data type depends on the input array type. If array is a floating point type, then the return array keeps the same data type, otherwise the type is
numpy.float.Notes
Masked arrays are not supported at this time. The convolution is always done at
numpy.floatprecision.