circular_overlap_grid#

photutils.geometry.circular_overlap_grid(xmin, xmax, ymin, ymax, nx, ny, r, use_exact, subpixels)#

Calculate the fractional overlap between a circle and a pixel grid.

The circle is centered on the origin.

Parameters:
xmin, xmax, ymin, ymaxfloat

The extent of the grid in the x and y direction. The grid is defined by the rectangle with corners (xmin, ymin) and (xmax, ymax).

nx, nyint

The grid dimensions in the x and y direction. The grid is defined by the rectangle with corners (xmin, ymin) and (xmax, ymax) and is divided into nx and ny pixels in the x and y direction, respectively.

rfloat

The radius of the circle.

use_exact0 or 1

Set to 1 to use an exact method to calculate the overlap between the circle and each pixel. Set to 0 to use a sub-pixel sampling method to calculate the overlap, where each pixel is divided into subpixels ** 2 subpixels and the fraction of subpixels that are within the circle is used to estimate the overlap.

subpixelsint

The number of subpixels to use in each dimension when using the sub-pixel sampling method. Each pixel is resampled by this factor in each dimension; thus, each pixel is divided into subpixels ** 2 subpixels.

Returns:
resultndarray (float)

A 2D array of shape (ny, nx) giving the fraction of each pixel’s area that overlaps with the circle, ranging from 0 to 1. The element at index (j, i) corresponds to the pixel with corners at (xmin + i * dx, ymin + j * dy) and (xmin + (i + 1) * dx, ymin + (j + 1) * dy), where dx and dy are the width of each pixel in the x and y direction, respectively.