Background3D#

class gammapy.irf.Background3D[source]#

Bases: BackgroundIRF

Background 3D.

Data format specification: BKG_3D.

Parameters:
axeslist of MapAxis or MapAxes
Required axes (in the given order) are:
  • energy (reconstructed energy axis)

  • fov_lon (field of view longitude)

  • fov_lon (field of view latitude)

datandarray

Data array.

unitstr or Unit

Data unit usually s^-1 MeV^-1 sr^-1.

is_pointlikebool, optional

Whether the IRF is point-like. True for point-like IRFs, False for full-containment. Default is False.

fov_alignmentFoVAlignment, optional

The orientation of the field of view coordinate system. Default is FoVAlignment.RADEC.

metadict

Metadata dictionary.

interp_kwargsdict, optional

Keyword arguments passed to ScaledRegularGridInterpolator. If None, the following inputs are used bounds_error=False, fill_value=0.0 and values_scale="log". Default is None.

Examples

Here’s an example you can use to learn about this class:

>>> from gammapy.irf import Background3D
>>> filename = '$GAMMAPY_DATA/cta-1dc/caldb/data/cta/1dc/bcf/South_z20_50h/irf_file.fits'
>>> bkg_3d = Background3D.read(filename, hdu='BACKGROUND')
>>> print(bkg_3d)
Background3D
------------

  axes  : ['energy', 'fov_lon', 'fov_lat']
  shape : (21, 36, 36)
  ndim  : 3
  unit  : 1 / (MeV s sr)
  dtype : >f4

Attributes Summary

Methods Summary

peek([figsize])

Quick-look summary plots.

plot_at_energy([energy, add_cbar, ncols, ...])

Plot the background rate in FoV coordinates at a given energy.

to_2d()

Convert to Background2D.

Attributes Documentation

default_unit = Unit("1 / (MeV s sr)")#
required_axes = ['energy', 'fov_lon', 'fov_lat']#
tag = 'bkg_3d'#

Methods Documentation

peek(figsize=(10, 8))[source]#

Quick-look summary plots.

This method creates a figure with four subplots:

  • Offset dependence plot : background rate versus offset for a given energy axis

  • Integrated spectrum plot : background rate integrated over the full field of view versus energy

  • Energy dependence plot : background rate versus energy for a given offset

  • Energy offset dependence of the background model map

Parameters:
figsizetuple, optional

Size of the figure. Default is (10, 8).

plot_at_energy(energy=<Quantity 1. TeV>, add_cbar=True, ncols=3, figsize=None, axes_loc=None, kwargs_colorbar=None, **kwargs)[source]#

Plot the background rate in FoV coordinates at a given energy.

Parameters:
energyQuantity, optional

List of energies. Default is 1 TeV.

add_cbarbool, optional

Add color bar. Default is True.

ncolsint, optional

Number of columns to plot. Default is 3.

figsizetuple, optional

Figure size. Default is None.

axes_locdict, optional

Keyword arguments passed to append_axes.

kwargs_colorbardict, optional

Keyword arguments passed to colorbar.

**kwargsdict

Keyword arguments passed to pcolormesh.

to_2d()[source]#

Convert to Background2D.

This takes the values at Y = 0 and X >= 0.

__init__(axes, data=0, unit='', is_pointlike=False, fov_alignment=FoVAlignment.RADEC, meta=None, interp_kwargs=None)#
classmethod __new__(*args, **kwargs)#