Note

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).

3D cube analysis (cube)

Introduction

The cube module bundles functionality for combined spatial and spectral analysis (cube style analysis) of gamma-ray sources.

Some information on cube style analysis in gamma-ray astronomy can be found here:

Getting Started

Use SkyCube to read a Fermi-LAT diffuse model cube:

>>> from gammapy.cube import SkyCube
>>> filename = '$GAMMAPY_EXTRA/test_datasets/unbundled/fermi/gll_iem_v02_cutout.fits'
>>> cube = SkyCube.read(filename, format='fermi-background')
>>> print(cube)
Sky cube flux with shape=(30, 21, 61) and unit=1 / (cm2 MeV s sr):
 n_lon:       61  type_lon:    GLON-CAR         unit_lon:    deg
 n_lat:       21  type_lat:    GLAT-CAR         unit_lat:    deg
 n_energy:    30  unit_energy: MeV

Use the cube methods to do computations:

import astropy.units as u
emin, emax = [1, 10] * u.GeV
image = cube.sky_image_integral(emin=emin, emax=emax)
image.show('ds9')

Using gammapy.cube

Gammapy tutorial notebooks that show examples using gammapy.cube:

Reference/API

gammapy.cube Package

Sky cubes (3-dimensional: energy, lon, lat).

Functions

compute_npred_cube(flux_cube, exposure_cube, …) Compute predicted counts cube.
fill_map_counts(count_map, event_list) Fill events into a counts map.
make_background_cube(pointing, obstime, bkg, …) Calculate background predicted counts cube.
make_cutout(ndmap, position, size[, margin]) Create a cutout of a WcsNDMap around a given direction.
make_exposure_cube(pointing, livetime, aeff, …) Calculate exposure cube.
make_map_counts(events, ref_geom, pointing, …) Build a WcsNDMap (space - energy) with events from an EventList.
make_map_exposure_true_energy(pointing, …) Compute exposure WcsNDMap in true energy (i.e.
make_map_fov_background(acceptance_map, …) Build Normalized background map from a given acceptance map and count map.
make_map_hadron_acceptance(pointing, …) Compute hadron acceptance cube i.e.
make_separation_map(geom, position) Compute distance of pixels to a given position for the input reference WCSGeom.

Classes

MapMaker(ref_geom, offset_max) Make all basic maps for a single observation.
SingleObsCubeMaker(obs, empty_cube_images, …) Compute SkyCube images for one observation.
SkyCube([name, data, wcs, energy_axis, meta]) Sky cube with dimensions lon, lat and energy.
SkyCubeImages([name, images, wcs, energy, meta]) Class to represent connection between SkyImage and SkyCube.
SkyModel(spatial_model, spectral_model) Sky model component.
SkyModelMapEvaluator([sky_model, exposure, psf]) Sky model evaluation on maps.
StackedObsCubeMaker(empty_cube_images[, …]) Compute stacked cubes for many observations.