Background2D#

class gammapy.irf.Background2D[source]#

Bases: BackgroundIRF

Background 2D.

Data format specification: BKG_2D

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

  • offset (field of view offset axis)

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.

Attributes Summary

Methods Summary

peek([figsize])

Quick-look summary plots.

plot([ax, add_cbar, axes_loc, kwargs_colorbar])

Plot energy offset dependence of the background model.

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

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

plot_energy_dependence([ax, offset])

Plot background rate versus energy for a given offset.

plot_offset_dependence([ax, energy])

Plot background rate versus offset for a given energy.

plot_spectrum([ax])

Plot angle integrated background rate versus energy.

to_3d()

Convert to Background3D.

Attributes Documentation

default_unit = Unit("1 / (MeV s sr)")#
required_axes = ['energy', 'offset']#
tag = 'bkg_2d'#

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 the 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(ax=None, add_cbar=True, axes_loc=None, kwargs_colorbar=None, **kwargs)[source]#

Plot energy offset dependence of the background model.

Parameters:
axAxes, optional

Matplotlib axes. Default is None.

add_cbarbool, optional

Add a colorbar to the plot. Default is True.

axes_locdict, optional

Keyword arguments passed to append_axes.

kwargs_colorbardict, optional

Keyword arguments passed to colorbar.

kwargsdict

Keyword arguments passed to pcolormesh.

Returns:
axAxes

Matplotlib axes.

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

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

Parameters:
energyQuantity, optional

List of energy. 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.

**kwargsdict

Keyword arguments passed to pcolormesh.

plot_energy_dependence(ax=None, offset=None, **kwargs)[source]#

Plot background rate versus energy for a given offset.

Parameters:
axAxes, optional

Matplotlib axes. Default is None.

offsetAngle, optional

Offset. Default is None.

kwargsdict

Forwarded to plt.plot().

Returns:
axAxes

Matplotlib axes.

plot_offset_dependence(ax=None, energy=None, **kwargs)[source]#

Plot background rate versus offset for a given energy.

Parameters:
axAxes, optional

Matplotlib axes. Default is None.

energyQuantity, optional

Energy. Default is None.

Returns:
axAxes

Matplotlib axes.

plot_spectrum(ax=None, **kwargs)[source]#

Plot angle integrated background rate versus energy.

Parameters:
axAxes, optional

Matplotlib axes. Default is None.

**kwargsdict

Keyword arguments forwarded to plot.

Returns:
axAxes

Matplotlib axes.

to_3d()[source]#

Convert to Background3D.

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