gammapy.image.radial_profile(image, center, radius)[source]

Image radial profile.

TODO: show example and explain handling of “overflow” and “underflow” bins (see radial_profile_label_image docstring).

Calls numpy.digitize to compute a label image and then scipy.ndimage.sum to do measurements.


image : SkyImage


center : SkyCoord

Center position

radius : Angle

Offset bin edge array.


table : Table

Table with the following fields that define the binning:

  • RADIUS_BIN_ID : Integer bin ID (starts at 1).
  • RADIUS_MEAN : Radial bin center
  • RADIUS_MIN : Radial bin minimum edge
  • RADIUS_MAX : Radial bin maximum edge

And the following measurements from the pixels in each bin:

  • N_PIX : Number of pixels
  • SUM : Sum of pixel values
  • MEAN : Mean of pixel values, computed as SUM / N_PIX


Make some example data:

from astropy.coordinates import Angle
from gammapy.image import SkyImage
image = SkyImage.empty()
center = image.center
radius = Angle([0.1, 0.2, 0.4, 0.5, 1.0], 'deg')

Compute and print a radial profile:

from gammapy.image import radial_profile
table = radial_profile(image, center, radius)

If your measurement represents counts, you could e.g. use this method to compute errors:

import numpy as np
table['SUM_ERR'] = np.sqrt(table['SUM'])
table['MEAN_ERR'] = table['SUM_ERR'] / table['N_PIX']

If you need to do special measurements or error computation in each bin with access to the pixel values, you could get the label image and then do the measurements yourself:

labels = radial_profile_label_image(image, center, radius)