class astropy.convolution.MexicanHat1DKernel(width, **kwargs)[source] [edit on github]

Bases: astropy.convolution.Kernel1D

1D Mexican hat filter kernel.

The Mexican Hat, or inverted Gaussian-Laplace filter, is a bandpass filter. It smoothes the data and removes slowly varying or constant structures (e.g. Background). It is useful for peak or multi-scale detection.

This kernel is derived from a normalized Gaussian function, by computing the second derivative. This results in an amplitude at the kernels center of 1. / (sqrt(2 * pi) * width ** 3). The normalization is the same as for scipy.ndimage.gaussian_laplace, except for a minus sign.


width : number

Width of the filter kernel, defined as the standard deviation of the Gaussian function from which it is derived.

x_size : odd int, optional

Size in x direction of the kernel array. Default = 8 * width.

mode : str, optional

One of the following discretization modes:
  • ‘center’ (default)
    Discretize model by taking the value at the center of the bin.
  • ‘linear_interp’
    Discretize model by linearly interpolating between the values at the corners of the bin.
  • ‘oversample’
    Discretize model by taking the average on an oversampled grid.
  • ‘integrate’
    Discretize model by integrating the model over the bin.

factor : number, optional

Factor of oversampling. Default factor = 10.


Kernel response:

import matplotlib.pyplot as plt
from astropy.convolution import MexicanHat1DKernel
mexicanhat_1D_kernel = MexicanHat1DKernel(10)
plt.plot(mexicanhat_1D_kernel, drawstyle='steps')
plt.xlabel('x [pixels]')

(png, svg, pdf)