Background2D

class gammapy.irf.Background2D(energy_axis, offset_axis, data, meta=None, interp_kwargs=None)[source]

Bases: object

Background 2D.

Data format specification: BKG_2D

Parameters
energy_axisMapAxis

Energy axis

offset_axisMapAxis

FOV coordinate offset-axis

dataQuantity

Background rate (usually: s^-1 MeV^-1 sr^-1)

Attributes Summary

default_interp_kwargs

Default Interpolation kwargs for NDDataArray.

tag

Methods Summary

evaluate(fov_lon, fov_lat, energy_reco[, method])

Evaluate at a given FOV position and energy.

evaluate_integrate(fov_lon, fov_lat, energy_reco)

Evaluate at given FOV position and energy, by integrating over the energy range.

from_hdulist(hdulist[, hdu])

Create from HDUList.

from_table(table)

Read from Table.

peek([figsize])

Quick-look summary plots.

plot([ax, add_cbar])

Plot energy offset dependence of the background model.

plot_energy_dependence([ax, offset, energy])

Plot background rate versus energy for a given offset.

plot_offset_dependence([ax, offset, energy])

Plot background rate versus offset for a given energy.

plot_spectrum([ax])

Plot angle integrated background rate versus energy.

read(filename[, hdu])

Read from file.

to_3d()

Convert to Background3D.

to_table()

Convert to Table.

to_table_hdu([name])

Convert to BinTableHDU.

Attributes Documentation

default_interp_kwargs = {'bounds_error': False, 'fill_value': None}

Default Interpolation kwargs for NDDataArray. Extrapolate.

tag = 'bkg_2d'

Methods Documentation

evaluate(fov_lon, fov_lat, energy_reco, method='linear', **kwargs)[source]

Evaluate at a given FOV position and energy.

The fov_lon, fov_lat, energy_reco has to have the same shape since this is a set of points on which you want to evaluate.

To have the same API than background 3D for the background evaluation, the offset is fov_altaz_lon.

Parameters
fov_lon, fov_latAngle

FOV coordinates expecting in AltAz frame, same shape than energy_reco

energy_recoQuantity

Reconstructed energy, same dimension than fov_lat and fov_lat

methodstr {‘linear’, ‘nearest’}, optional

Interpolation method

kwargsdict

option for interpolation for RegularGridInterpolator

Returns
arrayQuantity

Interpolated values, axis order is the same as for the NDData array

evaluate_integrate(fov_lon, fov_lat, energy_reco, method='linear')[source]

Evaluate at given FOV position and energy, by integrating over the energy range.

Parameters
fov_lon, fov_latAngle

FOV coordinates expecting in AltAz frame.

energy_reco: `~astropy.units.Quantity`

Reconstructed energy edges.

method{‘linear’, ‘nearest’}, optional

Interpolation method

Returns
arrayQuantity

Returns 2D array with axes offset

classmethod from_hdulist(hdulist, hdu='BACKGROUND')[source]

Create from HDUList.

classmethod from_table(table)[source]

Read from Table.

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

Quick-look summary plots.

plot(ax=None, add_cbar=True, **kwargs)[source]

Plot energy offset dependence of the background model.

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

Plot background rate versus energy for a given offset.

Parameters
axAxes, optional

Axis

offsetAngle

Offset

energyQuantity

Energy axis

kwargsdict

Forwarded tp plt.plot()

Returns
axAxes

Axis

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

Plot background rate versus offset for a given energy.

Parameters
axAxes, optional

Axis

offsetAngle

Offset axis

energyQuantity

Energy

Returns
axAxes

Axis

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

Plot angle integrated background rate versus energy.

Parameters
axAxes, optional

Axis

kwargsdict

Forwarded tp plt.plot()

Returns
axAxes

Axis

classmethod read(filename, hdu='BACKGROUND')[source]

Read from file.

to_3d()[source]

Convert to Background3D.

Fill in a radially symmetric way.

to_table()[source]

Convert to Table.

to_table_hdu(name='BACKGROUND')[source]

Convert to BinTableHDU.