Background3D

class gammapy.irf.Background3D(energy_lo, energy_hi, fov_lon_lo, fov_lon_hi, fov_lat_lo, fov_lat_hi, data, meta=None, interp_kwargs=None)[source]

Bases: object

Background 3D.

Data format specification: BKG_3D

Parameters
energy_lo, energy_hiQuantity

Energy binning

fov_lon_lo, fov_lon_hiQuantity

FOV coordinate X-axis binning.

fov_lat_lo, fov_lat_hiQuantity

FOV coordinate Y-axis binning.

dataQuantity

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

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
NDDataArray summary info
energy         : size =    21, min =  0.016 TeV, max = 158.489 TeV
fov_lon           : size =    36, min = -5.833 deg, max =  5.833 deg
fov_lat           : size =    36, min = -5.833 deg, max =  5.833 deg
Data           : size = 27216, min =  0.000 1 / (MeV s sr), max =  0.421 1 / (MeV s sr)

Attributes Summary

default_interp_kwargs

Default Interpolation kwargs for NDDataArray.

Methods Summary

evaluate(self, fov_lon, fov_lat, energy_reco)

Evaluate at given FOV position and energy.

evaluate_integrate(self, fov_lon, fov_lat, …)

Integrate in a given energy band.

from_hdulist(hdulist[, hdu])

Create from HDUList.

from_table(table)

Read from Table.

read(filename[, hdu])

Read from file.

to_2d(self)

Convert to Background2D.

to_fits(self[, name])

Convert to BinTableHDU.

to_table(self)

Convert to Table.

Attributes Documentation

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

Default Interpolation kwargs for NDDataArray. Extrapolate.

Methods Documentation

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

Evaluate at given FOV position and energy.

Parameters
fov_lon, fov_latAngle

FOV coordinates expecting in AltAz frame.

energy_recoQuantity

energy on which you want to interpolate. 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(self, fov_lon, fov_lat, energy_reco, method='linear', **kwargs)[source]

Integrate in a given energy band.

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.

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

Read from file.

to_2d(self)[source]

Convert to Background2D.

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

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

Convert to BinTableHDU.

to_table(self)[source]

Convert to Table.