elliptical_overlap_grid#

photutils.geometry.elliptical_overlap_grid(xmin, xmax, ymin, ymax, nx, ny, rx, ry, theta, use_exact, subpixels)#

Calculate the fractional overlap between an ellipse and a pixel grid.

The ellipse 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.

rxfloat

The semimajor axis of the ellipse.

ryfloat

The semiminor axis of the ellipse.

thetafloat

The position angle of the semimajor axis in radians (counterclockwise).

use_exact0 or 1

Set to 1 to use an exact method to calculate the overlap between the ellipse 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 ellipse 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 ellipse, 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.