A new set of map and cube classes is being developed in gammapy.maps and long-term will replace the existing gammapy.image.SkyImage and gammapy.cube.SkyCube classes. Please consider trying out gammapy.maps and changing your scripts to use those new classes. See Structures for images / cubes (maps).

2D image analysis (image)


gammapy.image contains data classes and methods for image based analysis of gamma-ray data.

Getting Started

The central data structure in gammapy.image is the SkyImage class, which combines the raw data with WCS information, FITS I/O functionality and many other methods, that allow easy handling, processing and plotting of image based data. Here is a first example:

from gammapy.image import SkyImage
filename = '$GAMMAPY_EXTRA/datasets/fermi_2fhl/fermi_2fhl_vela.fits.gz'
image =, hdu=2)

(png, hires.png, pdf)


This loads a prepared Fermi 2FHL FITS image of the Vela region, creates a SkyImage and shows it on the the screen by calling

To explore further the SkyImage class try tab completion on the image object in an interactive python environment or see the Sky image page.

Using gammapy.image

Many of the Tutorial notebooks show examples using gammapy.image:

Documentation pages with more detailed information:


gammapy.image Package

Sky images (2-dimensional: lon, lat).


colormap_hess([transition, width]) Colormap often used in H.E.S.S.
colormap_milagro([transition, width, huestart]) Colormap often used in Milagro collaboration publications.
fits_to_png(infile, outfile, draw[, dpi]) Plot FITS image in PNG format.
fitsfigure_add_psf_inset(ff, psf, box[, …]) Add PSF inset to FITSFigure instance.
grayify_colormap(cmap[, mode]) Return a grayscale version a the colormap.
illustrate_colormap(cmap, **kwargs) Illustrate color distribution and perceived luminance of a colormap.
image_groupby(images, labels) Group pixel by labels.
lon_lat_circle_mask(lons, lats, center_lon, …) Produces a circular boolean mask array.
lon_lat_rectangle_mask(lons, lats[, …]) Produces a rectangular boolean mask array based on lat and lon limits.
make_header([nxpix, nypix, binsz, xref, …]) Generate a FITS header from scratch.
measure_containment(image, position, radius) Measure containment in a given circle around the source position.
measure_containment_fraction(image, radius, …) Measure containment fraction.
measure_containment_radius(image, position) Measure containment radius of a source.
measure_curve_of_growth(image, position[, …]) Measure the curve of growth for a given source position.
measure_image_moments(image) Compute 0th, 1st and 2nd moments of an image.
measure_labeled_regions(data, labels[, tag, …]) Measure source properties in image.
process_image_pixels(images, kernel, out, …) Process images for a given kernel and per-pixel function.
radial_profile(image, center, radius) Image radial profile.
radial_profile_label_image(image, center, radius) Image radial profile label image.


ASmooth([kernel, method, threshold, scales]) Adaptively smooth counts image.
BasicImageEstimator BasicImageEstimator base class.
FermiLATBasicImageEstimator(reference, emin, …) Estimate basic sky images for Fermi-LAT data.
GalacticPlaneSurveyPanelPlot([npanels, …]) Plot Galactic plane survey images in multiple panels.
IACTBasicImageEstimator(reference, emin, emax) Estimate the basic sky images for a set of IACT observations.
ImageProfile(table) Image profile class.
ImageProfileEstimator([x_edges, method, axis]) Estimate profile from image.
SkyImage([name, data, wcs, unit, meta]) Sky image.
SkyImageList([images, meta]) List of SkyImage objects.

gammapy.image.models Package

Morphology models.


SkyDiffuseConstant([value]) Spatially constant (isotropic) spatial model.
SkyDiffuseMap(map[, norm, meta]) Spatial sky map template model.
SkyDisk(lon_0, lat_0, r_0) Constant radial disk model.
SkyGaussian(lon_0, lat_0, sigma) Two-dimensional symmetric Gaussian model.
SkyPointSource(lon_0, lat_0) Point Source.
SkyShell(lon_0, lat_0, radius, width) Shell model
SkySpatialModel SkySpatial model base class.