Background2D

class gammapy.irf.Background2D(energy_lo, energy_hi, offset_lo, offset_hi, data, meta=None, interp_kwargs=None)[source]

Bases: object

Background 2D.

Data format specification: BKG_2D

Parameters:
energy_lo, energy_hi : Quantity

Energy binning

offset_lo, offset_hi : Quantity

FOV coordinate offset-axis binning

data : Quantity

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

Attributes Summary

default_interp_kwargs Default Interpolation kwargs for NDDataArray.

Methods Summary

evaluate(self, fov_lon, fov_lat, energy_reco) Evaluate at a given FOV position and energy.
evaluate_integrate(self, fov_lon, fov_lat, …) 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(self)
plot(self[, ax, add_cbar]) Plot energy offset dependence of the background model.
read(filename[, hdu]) Read from file.
to_3d(self) Convert to Background3D.
to_fits(self[, name]) Convert to BinTableHDU.
to_table(self) Convert to Table.

Attributes Documentation

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

Default Interpolation kwargs for NDDataArray. Extrapolate.

Methods Documentation

evaluate(self, 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_lat : Angle

FOV coordinates expecting in AltAz frame, same shape than energy_reco

energy_reco : Quantity

Reconstructed energy, same dimension than fov_lat and fov_lat

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

Interpolation method

kwargs : dict

option for interpolation for RegularGridInterpolator

Returns:
array : Quantity

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

evaluate_integrate(self, 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_lat : Angle

FOV coordinates expecting in AltAz frame.

energy_reco: `~astropy.units.Quantity`

Reconstructed energy edges.

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

Interpolation method

Returns:
array : Quantity

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(self)[source]
plot(self, ax=None, add_cbar=True, **kwargs)[source]

Plot energy offset dependence of the background model.

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

Read from file.

to_3d(self)[source]

Convert to Background3D.

Fill in a radially symmetric way.

to_fits(self, name='BACKGROUND')[source]

Convert to BinTableHDU.

to_table(self)[source]

Convert to Table.