MapEvaluator

class gammapy.cube.MapEvaluator(model=None, exposure=None, background=None, psf=None, edisp=None)[source]

Bases: object

Sky model evaluation on maps.

This is a first attempt to compute flux as well as predicted counts maps.

The basic idea is that this evaluator is created once at the start of the analysis, and pre-computes some things. It it then evaluated many times during likelihood fit when model parameters change, re-using pre-computed quantities each time. At the moment it does some things, e.g. cache and re-use energy and coordinate grids, but overall it is not an efficient implementation yet.

For now, we only make it work for 3D WCS maps with an energy axis. No HPX, no other axes, those can be added later here or via new separate model evaluator classes.

We should discuss how to organise the model and IRF evaluation code, and things like integrations and convolutions in a good way.

Parameters:

model : SkyModel

Sky model

exposure : Map

Exposure map

background : Map

background map

psf : PSFKernel

PSF kernel

edisp : EnergyDispersion

Energy dispersion

Attributes Summary

bin_volume Map pixel bin volume (solid angle times energy bin width).
energy_bin_width Energy axis bin widths (astropy.units.Quantity)
energy_center Energy axis bin centers (Quantity)
energy_edges Energy axis bin edges (Quantity)
geom
geom_image
lat
lon
lon_lat Spatial coordinate pixel centers.
solid_angle Solid angle per pixel

Methods Summary

apply_edisp(data) Convolve map data with energy dispersion.
apply_exposure(flux) Compute npred cube
apply_psf(npred) Convolve npred cube with PSF
compute_dnde() Compute model differential flux at map pixel centers.
compute_flux() Compute model integral flux over map pixel volumes.
compute_npred() Evaluate model predicted counts.

Attributes Documentation

bin_volume

Map pixel bin volume (solid angle times energy bin width).

energy_bin_width

Energy axis bin widths (astropy.units.Quantity)

energy_center

Energy axis bin centers (Quantity)

energy_edges

Energy axis bin edges (Quantity)

geom
geom_image
lat
lon
lon_lat

Spatial coordinate pixel centers.

Returns lon, lat tuple of Quantity.

solid_angle

Solid angle per pixel

Methods Documentation

apply_edisp(data)[source]

Convolve map data with energy dispersion.

apply_exposure(flux)[source]

Compute npred cube

For now just divide flux cube by exposure

apply_psf(npred)[source]

Convolve npred cube with PSF

compute_dnde()[source]

Compute model differential flux at map pixel centers.

Returns:

model_map : Map

Sky cube with data filled with evaluated model values. Units: cm-2 s-1 TeV-1 deg-2

compute_flux()[source]

Compute model integral flux over map pixel volumes.

For now, we simply multiply dnde with bin volume.

compute_npred()[source]

Evaluate model predicted counts.