find_peaks

photutils.detection.find_peaks(data, threshold, box_size=3, footprint=None, mask=None, border_width=None, npeaks=inf, centroid_func=None, error=None, wcs=None)[source]

Find local peaks in an image that are above above a specified threshold value.

Peaks are the maxima above the threshold within a local region. The local regions are defined by either the box_size or footprint parameters. box_size defines the local region around each pixel as a square box. footprint is a boolean array where True values specify the region shape.

If multiple pixels within a local region have identical intensities, then the coordinates of all such pixels are returned. Otherwise, there will be only one peak pixel per local region. Thus, the defined region effectively imposes a minimum separation between peaks unless there are identical peaks within the region.

If centroid_func is input, then it will be used to calculate a centroid within the defined local region centered on each detected peak pixel. In this case, the centroid will also be returned in the output table.

Parameters:
dataarray_like

The 2D array of the image.

thresholdfloat or array_like

The data value or pixel-wise data values to be used for the detection threshold. A 2D threshold must have the same shape as data. See detect_threshold for one way to create a threshold image.

box_sizescalar or tuple, optional

The size of the local region to search for peaks at every point in data. If box_size is a scalar, then the region shape will be (box_size, box_size). Either box_size or footprint must be defined. If they are both defined, then footprint overrides box_size.

footprintndarray of bools, optional

A boolean array where True values describe the local footprint region within which to search for peaks at every point in data. box_size=(n, m) is equivalent to footprint=np.ones((n, m)). Either box_size or footprint must be defined. If they are both defined, then footprint overrides box_size.

maskarray_like, bool, optional

A boolean mask with the same shape as data, where a True value indicates the corresponding element of data is masked.

border_widthbool, optional

The width in pixels to exclude around the border of the data.

npeaksint, optional

The maximum number of peaks to return. When the number of detected peaks exceeds npeaks, the peaks with the highest peak intensities will be returned.

centroid_funccallable, optional

A callable object (e.g., function or class) that is used to calculate the centroid of a 2D array. The centroid_func must accept a 2D ndarray, have a mask keyword, and optionally an error keyword. The callable object must return a tuple of two 1D ndarray objects, representing the x and y centroids, respectively.

errorarray_like, optional

The 2D array of the 1-sigma errors of the input data. error is used only if centroid_func is input (the error array is passed directly to the centroid_func).

wcsNone or WCS object, optional

A world coordinate system (WCS) transformation that supports the astropy shared interface for WCS (e.g., astropy.wcs.WCS, gwcs.wcs.WCS). If None, then the sky coordinates will not be returned in the output Table.

Returns:
outputTable or None

A table containing the x and y pixel location of the peaks and their values. If centroid_func is input, then the table will also contain the centroid position. If no peaks are found then None is returned.

Notes

By default, the returned pixel coordinates are the integer indices of the maximum pixel value within the input box_size or footprint (i.e., only the peak pixel is identified). However, a centroiding function can be input via the centroid_func keyword to compute centroid coordinates with subpixel precision within the input box_size or footprint.