aperture_photometry#
- photutils.aperture.aperture_photometry(data, apertures, error=None, mask=None, method='exact', subpixels=5, wcs=None)[source]#
Perform aperture photometry on the input data by summing the flux within the given aperture(s).
Note
This is a legacy function. It is not deprecated, but new features are no longer added to it. The
AperturePhotometryclass is the recommended tool for aperture photometry. It provides additional outputs (e.g., aperture areas, quality flags) and options (e.g., segmentation-based neighbor masking).This function returns the sum of the (weighted) input
datavalues within the aperture. It does not convert data in surface brightness units to flux or counts. Conversion from surface-brightness units should be performed before using this function.- Parameters:
- dataarray_like,
Quantity,NDData The 2D array on which to perform photometry.
datashould be background-subtracted. Ifdatais aQuantityarray, thenerror(if input) must also be aQuantityarray with the same units. Nonfinitedatavalues (NaN and inf) are not masked automatically. An aperture that contains one has a nonfinite sum. See the Notes section below for more information aboutNDDatainput.- apertures
Aperture, supportedregions.Region, list ofApertureorregions.Region The aperture(s) to use for the photometry. If
aperturesis a list ofApertureorregions.Region, then they all must have the same position(s). A tuple orndarrayof them is also accepted. Ifaperturescontains aSkyApertureorSkyRegionobject, then a WCS must be input using thewcskeyword. Region objects are converted to aperture objects.- errorarray_like or
Quantity, optional The pixel-wise Gaussian 1-sigma errors of the input
data.erroris assumed to include all sources of error, including the Poisson error of the sources (seecalc_total_error).errormust have the same shape as the inputdata. If aQuantityarray, thendatamust also be aQuantityarray with the same units.- maskarray_like (bool), optional
A boolean mask with the same shape as
datawhere aTruevalue indicates the corresponding element ofdatais masked. Masked data are excluded from all calculations.- method{‘exact’, ‘center’, ‘subpixel’}, optional
The method used to determine the pixel weights (the fraction of the pixel area covered by the aperture):
'exact'(default): Calculates the exact geometric overlap area. Weights are continuous in the range [0, 1].'center': Binary weighting based on the pixel center. Weights are either 0 or 1. A pixel is included only if its center lies strictly inside the aperture. Pixel centers lying exactly on the outer aperture boundary are excluded (weight 0). For an annulus, pixel centers lying exactly on the inner boundary are included (weight 1).'subpixel': Approximates the overlap by averaging binary samples on a subgrid. The number of samples is set by thesubpixelsparameter. Weights are discrete in the range [0, 1]. A subpixel is included only if its center lies strictly inside the aperture. Subpixel centers lying exactly on the outer aperture boundary are excluded (weight 0). For an annulus, subpixel centers lying exactly on the inner boundary are included.
- subpixelsint, optional
The subsampling factor per axis used with the
'subpixel'method. Each pixel is divided into a grid ofsubpixels**2subpixels to approximate the overlap. This parameter is ignored for other methods.- wcsWCS 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 provided, the output table will include a'sky_center'column with the sky coordinates of the input aperture center(s). This keyword is required if the inputaperturescontains aSkyApertureorSkyRegion.
- dataarray_like,
- Returns:
- table
QTable A table of the photometry with the following columns:
'id': The source ID.'x_center','y_center': Thexandypixel coordinates of the input aperture center(s).Deprecated since version 3.0: The
'xcenter'and'ycenter'column names are deprecated aliases of'x_center'and'y_center'. They emit a deprecation warning when used and will be removed in version 4.0.'sky_center': The sky coordinates of the input aperture center(s). Returned if awcsis input.'aperture_sum': The sum of the values within the aperture(s). The values are always float64, regardless of the inputdatadtype (aQuantitywith float64 values ifdatahas units).'aperture_sum_err': The corresponding uncertainty in the'aperture_sum'values (always float64). Returned only if the inputerroris notNone.
If a list of apertures is input (even a list with one aperture), the
'aperture_sum'and'aperture_sum_err'columns will have a'_i'suffix (e.g.,'aperture_sum_0'), whereiis the index of the aperture in the input list.The table metadata includes the date, the version numbers of Python, Photutils, and its dependencies, the
methodandsubpixelscalling arguments, and the class name and shape parameters of each input aperture.
- table
- Raises:
- ValueError
If
aperturescontains aSkyApertureorSkyRegionand no WCS is input, or if the input apertures do not all have identical positions.
Notes
Regionobjects are converted toApertureobjects using theregion_to_aperture()function.If the input
datais aNDDataobject, then itsmask,wcs, unit, and uncertainty are used. Theerror,mask, andwcskeywords are then ignored, and anAstropyUserWarningis issued for each one that is input. The uncertainty is used aserroronly if it is aStdDevUncertainty. Any other uncertainty type is ignored.