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 length of the semiaxis of the ellipse along the direction given by theta. This is the semimajor axis when rx >= ry.

ryfloat

The length of the semiaxis of the ellipse perpendicular to the direction given by theta.

thetafloat

The rotation angle of the rx axis in radians, measured counterclockwise from the positive x-axis.

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 subpixel 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 subpixel sampling method (use_exact=0). It must be at least 1 in that case. It is ignored when use_exact=1. Each pixel is resampled by this factor in each dimension, so each pixel is divided into subpixels ** 2 subpixels.

A subpixel is included only if its center lies strictly inside the ellipse. Subpixel centers lying exactly on the ellipse boundary are excluded (weight 0).

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.

Raises:
ValueError

If use_exact is not 0 or 1, or if subpixels is less than 1 when use_exact=0.