4.21. Aperture photometry

See Section 4.2 for general information on how to run image analysis tasks.

You can perform aperture photometry on an image using a circular target aperture. You can determine the appropriate sky values using either an annular or rectangular sky aperture. If there is no suitable area for determining the sky, you can also provide a fixed sky value.

You can use five algorithms to estimate the sky:

4.21.1. Centroiding

The aperture photometry tasks include an option for centroiding. Selecting this option will refine the input coordinates to those determined by a centroiding algorithm. This works as follows: a square region, with length 4 times the requested target radius, is fit with a 2D Gaussian plus a constant; the indicated target centre is the initial estimate of the source position and the indicated target radius is the initial guess at the width of the Gaussian; if the centroiding can find a fit, then the "Centroiding" keyword is set to "success" and the coordinates updated; if the algorithm finds no solution, then the new coordinates are set to those either of the brightest pixel in the square region or, where there are multiple bright pixels, the pixel closest to the initial guess, and "Centroiding" is set to "failed". If using the GUI form of the task, the circle indicating where the input position is located will move to the centroided position. The Meta datum "Centroid" is added to the output "result" of the task (this information is also displayed in the results table).

[Tip] Tip

If the centroiding was successful, note that this does not necessarily mean that a good centroid was found, but rather than the centroiding algorithm could complete. Experience shows that this centroiding does not always perform well, and if you are using the aperture photometry tasks in an automatic way (i.e. not checking the resulting coordinates on the image), it is recommended that this option is not selected. If it is necessary to refine the target coordinates (e.g. you only have an estimated position), the sourceFitting task is a good alternative for an automatic refining of point source coordinates, and the output of sourceFitting can be used as input to the photometry tasks (with the centroiding option then turned off). See Section 4.20 for an explanation of sourceFitting, see also Section 4.22 for examples.

4.21.2. Units and aperture photometry

To use an image as input of an aperture photometry task, make sure that the units are flux/pixel. The flux may be expressed in Jy or in ADU depending on the kind of image. This ensures that the end product of the photometry will be expressed in (flux/pixel)*pixel = flux units.

For example, if the image units are Jy/beam, then you need to convert first into MJy/sr, using the beamsize, then to Jy/pixel using the pixel area. Then you can perform the photometry, whose output will be in Jy.

The units of PACS maps are Jy/pixel, so no conversion is needed. For instructions on performing aperture photometry on SPIRE maps, see the SPIRE Data Reduction Guide .

4.21.3. Point sources

4.21.3.1. Annular sky aperture photometry (annularSkyAperturePhotometry)

The best place to compute the background is a circular annulus as close to the target as possible. This task determines the background in an annulus around the circular target aperture.

Via the GUI

To perform annular aperture photometry , run the annularSkyAperturePhotometry task. The image appears in a new tab within the Editor view. Below the image you can find the interface to enter the task options.

In the Target center pane, a drop-down menu gives you three ways to identify the target:

  • By mouse interaction. With this option selected, click once on the image to select the target.

  • By entering the X and Y pixel coordinates.

  • By entering sky coordinates, if the image has a valid WCS. Use the format "02:00:39.4" for Right Ascension and "-22:27:20.6" for Declination, including the quotation marks.

The target is identified by a circle.

In the Apertures panel you can enter the radii for the target and sky regions. In the Sky estimation panel you can specify the algorithm, and whether to use entire pixels or fractional pixels.

You can reset the parameters at any time by clicking Clear . Click Accept to execute the task. The circular radii are shown on the image (see Figure 4.21 ).

You can display the results by double clicking on the result variable shown in the Variables view (see Figure 4.22 ).

[Note] Note

The error given by the aperture photometry task is not correct in the case of flux-calibrated Herschel images. It is however correct in case of CCD images where the units are in ADU. Currently the best way to determine the photometric error is to place several apertures on the background around the source, and to measure the flux within these apertures. The standard deviation of the values gives the photometric error on the source.

Aperture photometry with an annular sky aperture as displayed in HIPE.

Figure 4.21. Aperture photometry with an annular sky aperture as displayed in HIPE.


Aperture photometry results plot and tables. Note that n.a. stands for "not applicable" and typically occurs when units are not assigned to the image.

Figure 4.22. Aperture photometry results plot and tables. Note that n.a. stands for "not applicable" and typically occurs when units are not assigned to the image.


The results include two plots, useful to judge whether your choice of radii was sensible:

  • A curve of growth , showing the target flux, without the sky, as a function of the radius.

  • A sky intensity plot , showing the intensity per sky pixel as a function of the inner radius, the outer radius being constant.

Via the command line

To perform aperture photometry from the command line you must specify the following input parameters:

  • The image ( image ).

  • The position of the target centre, in pixels ( centerX and centerY ) or sky coordinates ( centerRa and centerDec ).

  • The radius of the target, in pixels ( radiusPixels ) or in arcseconds ( radiusArcsec ).

  • The inner and outer radii of the annular sky aperture, in pixels ( innerPixels and outerPixels ) or arcseconds ( innerArcsec and outerArcsec ).

  • Whether fractional pixels are to be used ( fractional ). It can be True (1) or False (0), True by default.

  • The sky estimation algorithm ( algorithm ). This is an integer with the following possible values: 0 for average, 1 for median, 2 for mean-median, 3 for synthetic mode and 4 for the algorithm used by Daophot.

The following examples show how to perform aperture photometry:

from herschel.calsdb.util import Coordinate
# Getting a point-source PACS observation
myObs = getObservation(obsid = 1342184579, useHsa = True)

# Extracting the map
pointSrcMap = myObs.refs["level2"].product.refs["HPPPMAPB"].product

# The target centre specified in pixel coordinates, the radii in pixels 
# and using fractional pixels
photPixels = annularSkyAperturePhotometry(image = pointSrcMap, centerX = 149.0, \
 centerY = 160.0, radiusPixels = 5.0, innerPixels = 20.0, outerPixels = 40.0, \
 fractional = 1, algorithm = 4)

# The task requires strings for the RA and the DEC, so they must be converted
sexagesimalRA = Coordinate.ra2String(232.85505321881504)
sexagesimalDEC = Coordinate.dec2String(77.34943290224619)

# The target center specified in sky coordinates, the radii in arcseconds 
# and using entire pixels
photSky = annularSkyAperturePhotometry(image = pointSrcMap, \
 centerRa = sexagesimalRA, centerDec = sexagesimalDEC, radiusArcsec = 5.04, \
 innerArcsec = 20.16, outerArcsec = 40.32, fractional = 0, algorithm = 4)

Example 4.107. Performing annular sky aperture photometry on a PACS map.


from herschel.calsdb.util import Coordinate
# Getting a point-source SPIRE observation
myObs = getObservation(obsid = 1342182472, useHsa = True)

# Extracting the map
pointSrcMap = myObs.refs["level2"].product.refs["psrcPSW"].product

# The target centre specified in pixel coordinates, the radii in pixels 
# and using fractional pixels
photPixels = annularSkyAperturePhotometry(image = pointSrcMap, centerX = 98.0, \
 centerY = 114.0, radiusPixels = 5.0, innerPixels = 20.0, outerPixels = 40.0, \
 fractional = 1, algorithm = 4)

# The task requires strings for the RA and the DEC, so they must be converted
sexagesimalRA = Coordinate.ra2String(65.81568453395388)
sexagesimalDEC = Coordinate.dec2String(-1.3421057265332947)

# The target center specified in sky coordinates, the radii in arcseconds 
# and using entire pixels
photSky = annularSkyAperturePhotometry(image = pointSrcMap, \
 centerRa = sexagesimalRA, centerDec = sexagesimalDEC, radiusArcsec = 5.04, \
 innerArcsec = 20.16, outerArcsec = 40.32, fractional = 0, algorithm = 4)

Example 4.108. Performing annular sky aperture photometry on a SPIRE map.


[Note] Note

You can specify distances in arcseconds (here radiusArcsec , innerArcsec and outerArcsec ) only if the pixel scaling is the same in both directions ( myImage.getCdelt1() = myImage.getCdelt2() ). Moreover, the image must have a valid WCS.

You must specify all distances in the same unit, pixels or arcseconds.

You can inspect the output product with the methods listed in the following table:

Procedure 4.7.  Available methods for the output of the annularSkyAperturePhotometry task.

  1. getTargetCenterPixelCoordinates()

    Returns the pixel coordinates of the target centre as a Double1d .

    # Java style
    print myPhot.getTargetCenterPixelCoordinates()
    # Jython style
    print myPhot.targetCenterPixelCoordinates

    Example 4.109. Getting the centre pixel coordinates for the target.


  2. getTargetCenterSkyCoordinates()

    Returns the sky coordinates of the target centre as a String1d .

    # Java style
    print myPhot.getTargetCenterSkyCoordinates()
    # Jython style
    print myPhot.targetCenterSkyCoordinates

    Example 4.110. Getting the centre sky coordinates for the target.


  3. getTargetRadiusPixels()

    Returns the radius of the target aperture in pixels.

    # Java style
    print myPhot.getTargetRadiusPixels()
    # Jython style
    print myPhot.targetRadiusPixels

    Example 4.111. Getting the target radius in pixels.


  4. getTargetRadiusArcsec()

    Returns the radius of the target aperture in arcseconds.

    # Java style
    print myPhot.getTargetRadiusArcsec()
    # Jython style
    print myPhot.targetRadiusArcsec

    Example 4.112. Getting the target radius in arcseconds.


  5. getInnerRadiusPixels()

    Returns the inner radius of the sky estimation annulus in pixels. The getOuterRadiusPixels() method to return the outer radius is also available.

    # Java style
    print myPhot.getInnerRadiusPixels()
    # Jython style
    print myPhot.innerRadiusPixels

    Example 4.113. Getting the outer target radius in pixels.


  6. getInnerRadiusArcsec()

    Returns the inner radius of the sky estimation annulus in arcseconds. The getOuterRadiusArcsec() method to return the outer radius is also available.

    # Java style
    print myPhot.getInnerRadiusArcsec()
    # Jython style
    print myPhot.innerRadiusArcsec

    Example 4.114. Getting the inner radius of the sky estimation annulus in arcseconds.


  7. getAlgorithm()

    Returns the name of the algorithm used by the task.

    # Java style
    print myPhot.getAlgorithm()
    # Jython style
    print myPhot.algorithm

    Example 4.115. Getting the name of the algorithm used by the aperture photometry task.


  8. getPixels()

    Returns the type of pixels, either entire or fractional , used by the task.

    # Java style
    print myPhot.getPixels()
    # Jython style
    print myPhot.pixels

    Example 4.116. Checking if the aperture photometry task considers fractional or entire pixels.


  9. getTable()

    Returns the results table as a table dataset.

    # Java style
    print myPhot.getTable()
    # Jython style
    print myPhot.table

    Example 4.117. Getting the results of the aperture photometry task as a table dataset.


  10. getDouble2dTable()

    Returns the results table as a Double2d .

    # Java style
    print myPhot.getDouble2dTable()
    # Jython style
    print myPhot.double2dTable

    Example 4.118. Getting the results of the aperture photometry task as a Double2d table.


  11. getTargetPlusSkyTotal()

    Returns the total flux of the target plus the sky. To get the same for the sky and for the target without the sky, replace TargetPlusSky with Sky or Target in the method name. To get the corresponding error, replace Total with Error in the method name.

    # Java style
    print myPhot.getTargetPlusSkyTotal()
    # Jython style
    print myPhot.targetPlusSkyTotal

    Example 4.119. Getting the total flux (target+sky).


  12. getNbOfTargetPlusSkyPixels()

    Returns the number of pixels in the target and sky areas. To get the same for the sky and for the target areas only, replace TargetPlusSky with Sky or Target in the method name.

    # Java style
    print myPhot.getNbOfTargetPlusSkyPixels()
    # Jython style
    print myPhot.nbOfTargetPlusSkyPixels

    Example 4.120. Getting the total number of pixels (target+sky).


  13. getIntensityPerTargetPlusSkyPixel()

    Returns the intensity per pixel for the target plus the sky. To get the same for the sky and for the target without the sky, replace TargetPlusSky with Sky or Target in the method name.

    # Java style
    print myPhot.getIntensityPerTargetPlusSkyPixel()
    # Jython style
    print myPhot.intensityPerTargetPlusSkyPixel

    Example 4.121. Getting the flux intensity averaged by the total pixels (target+sky).


  14. getCurveOfGrowth()

    Returns the curve of growth as a table dataset. The table dataset has two columns: Growth radius and Growth flux .

    # Java style
    myTable =  myPhot.getCurveOfGrowth()
    # Jython style
    myTable = myPhot.curveOfGrowth

    Example 4.122. Getting the curve of growth for the results of aperture photometry task.


  15. getGrowthRadius()

    Returns a Double1d with the values in the Growth radius column of the curve of growth table dataset returned by the getCurveOfGrowth() method.

    # Java style
    print myPhot.getGrowthRadius()
    # Jython style
    print myPhot.growthRadius

    Example 4.123. Getting the growth radius for the results of the aperture photometry task.


  16. getGrowthFlux()

    Returns a Double1d with the values in the Growth flux column of the curve of growth table dataset returned by the getCurveOfGrowth() method.

    # Java style
    print myPhot.getGrowthFlux()
    # Jython style
    print myPhot.growthFlux

    Example 4.124. Getting the growth flux column of the results of the aperture photometry task.


  17. getSkyIntensityPlot()

    Returns the curve in the sky intensity plot as a table dataset. The table dataset has two columns: Sky radius and Sky intensity .

    # Java style
    myTable = myPhot.getSkyIntensityPlot()
    # Jython style
    myTable = myPhot.skyIntensityPlot

    Example 4.125. Getting the intensity plot as a table dataset.


  18. getSkyIntensityRadius()

    Returns a Double1d with the values in the Sky radius column of the sky intensity table dataset returned by the getSkyIntensityPlot() method.

    # Java style
    print myPhot.getSkyIntensityRadius()
    # Jython style
    print myPhot.skyIntensityRadius

    Example 4.126. Getting the sky intensity radius of the intensity plot.


  19. getSkyIntensity()

    Returns a Double1d with the values in the Sky intensity column of the sky intensity table dataset returned by the getSkyIntensityPlot() method.

    # Java style
    print myPhot.getSkyIntensity()
    # Jython style
    print myPhot.skyIntensity

    Example 4.127. Getting the sky intensity values from the intensity plot as a Double1d.


[Note] Note

The aperture photometry task offers a recentering option, but the results are not always accurate. If you do not know the exact coordinates of your source, use the sourceFitter task before running the photometry task.

4.21.3.2. Rectangular sky aperture photometry (rectangularSkyAperturePhotometry)

The immediate neighbourhood of the target is not always the best location to estimate the sky. In these cases you can take a rectangular region further away from the target. This is known as rectangular sky aperture photometry . You can do it in HIPE with the rectangularSkyAperturePhotometry task.

Via the GUI

In the same way as with annular sky aperture photometry, you can select the object with one click or give the coordinates explicitly. Click and drag your mouse pointer on the image to select a rectangular aperture. Following the calculation for the first position, you can use the same rectangular box for the sky and choose a new object with a further single click on the image.

The result product has the same structure as the annular photometry result product, except that the sky intensity plot is missing.

Via the command line

To perform aperture photometry from the command line you must specify the following input parameters:

  • The image ( image ).

  • The position of the target centre, in pixels ( centerX and centerY ) or sky coordinates ( centerRa and centerDec ).

  • The radius of the target, in pixels ( radiusPixels ) or in arcseconds ( radiusArcsec ).

  • The position of the corner of the background area with the smallest coordinate values, in pixels ( minX and minY ) or sky coordinates ( minRa and minDec ).

  • The width and height of the background area in pixels ( widthPixels and heightPixels ) or arcseconds ( widthArcsec and heightArcsec ).

  • Whether fractional pixels are to be used ( fractional ). It can be True (1) or False (0), True by default.

  • The sky estimation algorithm ( algorithm ). This is an integer with the following possible values: 0 for average, 1 for median, 2 for mean-median, 3 for synthetic mode and 4 for the algorithm used by Daophot.

The following example shows how to perform rectangular sky aperture photometry:

# The target centre is specified in pixel coordinates, the target radius in pixels
photPixel = rectangularSkyAperturePhotometry(image = myImage, centerX = 501.0,\
 centerY = 266.0, radiusPixels = 5.0, minX = 553.0, minY = 132.0, \
 widthPixels = 120.0, heightPixels = 47.0, algorithm = 4)

# The target centre is specified in sky coordinates, the target radius in arcseconds
photSky = rectangularSkyAperturePhotometry(image = myImage, \
 centerRa = "02:00:34.388", centerDec = "-22:25:59.87", radiusArcsec = 5.04, \
 minRa = "02:00:38.179", minDec = "-22:28:14.89", widthArcsec = 120.96, \
 heightArcsec = 47.376)

Example 4.128. Performing rectangular sky aperture photometry.


[Note] Note

The target centre and the corner of the rectangle with smallest coordinate values must be specified in the same coordinates, either pixel or sky.

You can choose the kind of pixels and the sky estimation algorithm in the same way as for the annularSkyAperturePhotometry task.

To inspect the output product via the command line, you can use the same methods described in Procedure 4.7 for the annularSkyAperturePhotometry task, except for those referring to the annular sky aperture. Further methods exclusive to the output of rectangularSkyAperturePhotometry are shown in the following table:

Procedure 4.8.  Available methods for the output of the rectangularSkyAperturePhotometry task.

  1. getWidthPixels()

    Returns the width of the rectangle in pixels. The getHeightPixels() method to get the height of the rectangle is also available.

    # Java style
    print myPhot.getWidthPixels()
    # Jython style
    print myPhot.widthPixels

    Example 4.129. Getting the width in pixels of the rectangular aperture.


  2. getWidthArcsec()

    Returns the width of the rectangle in arcseconds. The getHeightArcsec() method to get the height of the rectangle is also available.

    # Java style
    print myPhot.getWidthArcsec()
    # Jython style
    print myPhot.widthArcsec

    Example 4.130. Getting the width in arcseconds of the rectangular aperture.


  3. getUpperLeftCornerPixelCoordinates()

    Returns the pixel coordinates of the upper left corner of the rectangle as a Double1d . The upper left corner is the corner with lowest pixel coordinates.

    # Java style
    print myPhot.getUpperLeftCornerPixelCoordinates()
    # Jython style
    print myPhot.upperLeftCornerPixelCoordinates

    Example 4.131. Getting the upper left corner of the rectangular aperture in pixel coordinates.


  4. getUpperLeftCornerSkyCoordinates()

    Returns the sky coordinates of the upper left corner of the rectangle as a String1d . The upper left corner is the corner with lowest pixel coordinates.

    # Java style
    print myPhot.getUpperLeftCornerSkyCoordinates()
    # Jython style
    print myPhot.upperLeftCornerSkyCoordinates

    Example 4.132. Getting the upper left corner of the rectangular aperture in sky coordinates.


4.21.3.3. Fixed sky aperture photometry (fixedSkyAperturePhotometry)

If both the annular and rectangular sky aperture methods fail to provide a meaningful estimate of the background, you can provide a fixed background value.

Via the GUI

Use fixedSkyAperturePhotometry to provide a fixed sky value . Executing the task and inspecting the results is done in the same way as for the other types of photometry.

Via the command line

To perform aperture photometry from the command line you must specify the following input parameters:

  • The image ( image ).

  • The position of the target centre, in pixels ( centerX and centerY ) or sky coordinates ( centerRa and centerDec ).

  • The radius of the target, in pixels ( radiusPixels ) or in arcseconds ( radiusArcsec ).

  • The sky intensity value ( sky ).

  • Whether fractional pixels are to be used ( fractional ). It can be True (1) or False (0), True by default.

The following example shows how to perform fixed sky aperture photometry:

# The target centre for PACS observation 1342184579 is specified in pixel coordinates, the target 
# radius in pixels
photPixels = fixedSkyAperturePhotometry(image = myImage, centerX = 159.0, \
 centerY = 150.0, radiusPixels = 5.0, sky = 48.0)
# The target centre for PACS observation 1342184579 is specified in sky coordinates, the target radius in arcsec
photSky = fixedSkyAperturePhotometry(image = myImage, centerRa = "15:31:24.91",\
 centerDec = "77:20:57.97"", radiusArcsec = 5.04, sky = 48.0)

Example 4.133. Performing fixed sky aperture photometry.


[Note] Note

The target radius can only be specified if the image has a valid WCS and the pixel scaling is the same in both directions.

4.21.3.4. Aperture correction

Aperture photometry measures the flux within a finite, relatively small aperture. The total flux however is distributed in a much larger area well outside the aperture. To account for this missing flux you need to apply a correction factor to the flux values. Such correction factors are determined through careful signal-to-noise measurements of bright celestial standards and are available as calibration files in HIPE.

For PACS. Run the aperture correction task as in the following example:

result_apcor = photApertureCorrectionPointSource(apphot=myResult, band="blue", \
calTree=calTree, responsivityVersion=6)

Example 4.134. Running the aperture photometry correction task for point sources.


The myResult variable is the output of the aperture photometry task. The band parameter determines the filter. Because the aperture correction changes when there is an update in responsivity calibration, you must specify which responsivity calibration was used when your image was processed.

You can examine the task output in the same way as the output of the aperture photometry tasks.

For more information on the photApertureCorrectionPointSource task, see the corresponding entry in the User's Reference Manual .

For SPIRE.  Aperture correction is mentioned in the SPIRE Data Reduction Guide , Section 5.7 . Search for aperture correction in that section.