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'
>>> 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¶

 fill_map_counts(count_map, event_list) Fill events into a counts map. make_map_background_fov(acceptance_map, …) Build Normalized background map from a given acceptance map and count map. make_map_background_irf(pointing, livetime, …) Compute background map from background IRFs. 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_separation(geom, position) Compute distance of pixels to a given position for the input reference WCSGeom. make_psf_map(psf, pointing, ref_geom, max_offset) Make a psf map for a single observation

#### Classes¶

 CompoundSkyModel(model1, model2, operator) Represents the algebraic combination of two SkyModel MapEvaluator([sky_model, exposure, …]) Sky model evaluation on maps. MapFit(model, counts, exposure[, …]) Perform sky model likelihood fit on maps. MapMaker(ref_geom, offset_max[, cutout_mode]) Make all basic maps for a single observation. PSFKernel(psf_kernel_map) PSF kernel for Map. PSFMap(psf_map) Class containing the Map of PSFs and allowing to interact with it. SkyCube([name, data, wcs, energy_axis, meta]) Sky cube with dimensions lon, lat and energy. SkyModel(spatial_model, spectral_model[, name]) Sky model component. SourceLibrary(skymodels) Collection of SkyModel