compute_pixel_areas#
- photutils.utils.compute_pixel_areas(wcs, x, y)[source]#
Compute the on-sky area of the pixels at the given positions.
The area of a pixel is the area of the parallelogram spanned by its two edge vectors on the sky, which is the absolute determinant of the local forward WCS Jacobian
d(sky_arcsec)/d(pixel). The Jacobian is evaluated by central finite differences half a pixel either side of each position, so the area is exact for a locally quadratic distortion in the small-angle limit. The finite pixel size adds a relative error of orderh**2for a pixel that subtends an anglehin radians. The size of the error depends on the projection. It is below 1e-6 at 0.1 deg per pixel and negligible for imaging data. The area is well defined at the celestial poles and across the longitude wraparound.- Parameters:
- wcsWCS object
A world coordinate system (WCS) transformation that supports the astropy shared interface for WCS (e.g.,
astropy.wcs.WCS,gwcs.wcs.WCS).- x, yfloat or array_like
The pixel coordinates. Both must have the same shape.
- Returns:
- areasfloat or
ndarray The pixel areas in arcsec2, with the same shape as
xandy. A float is returned for scalar input. The area is NaN for a nonfinite position or a position where the WCS is undefined (e.g., outside the valid region of the projection).
- areasfloat or
See also
Notes
The pixel area of a distorted image typically varies by a few percent across the field. Multiplying a surface brightness image (e.g., in MJy/sr) by a single nominal pixel area therefore leaves a position-dependent error in the resulting fluxes. This function gives the area of each pixel from the WCS instead.
Examples
>>> import numpy as np >>> from photutils.datasets import make_wcs >>> from photutils.utils import compute_pixel_areas >>> wcs = make_wcs((100, 100)) >>> areas = compute_pixel_areas(wcs, [10.0, 50.0], [20.0, 50.0]) >>> print(np.round(areas, 6)) # arcsec**2 [0.01 0.01]