Box2DKernel¶
- class astropy.convolution.Box2DKernel(width, **kwargs)[source]¶
Bases:
Kernel2D
2D Box filter kernel.
The Box filter or running mean is a smoothing filter. It is not isotropic and can produce artifacts when applied repeatedly to the same data.
The generated kernel is normalized so that it integrates to 1.
By default the Box kernel uses the
linear_interp
discretization mode, which allows non-shifting, even-sized kernels. This is achieved by weighting the edge pixels with 1/2.- Parameters:
- widthnumber
Width of the filter kernel.
- mode{‘linear_interp’, ‘center’, ‘oversample’, ‘integrate’}, optional
- One of the following discretization modes:
- ‘linear_interp’ (default)
Discretize model by performing a bilinear interpolation between the values at the corners of the bin.
- ‘center’
Discretize model by taking the value at the center of the bin.
- ‘oversample’
Discretize model by taking the average on an oversampled grid.
- ‘integrate’
Discretize model by integrating the model over the bin.
- factornumber, optional
Factor of oversampling. Default factor = 10.
See also
Examples
Kernel response:
import matplotlib.pyplot as plt from astropy.convolution import Box2DKernel box_2D_kernel = Box2DKernel(9) plt.imshow(box_2D_kernel, interpolation='none', origin='lower', vmin=0.0, vmax=0.015) plt.xlim(-1, 9) plt.ylim(-1, 9) plt.xlabel('x [pixels]') plt.ylabel('y [pixels]') plt.colorbar() plt.show()