TH2_to_FITS

gammapy.utils.root.TH2_to_FITS(hist, flipx=True)[source]

Convert ROOT 2D histogram to FITS format.

Parameters:

hist : ROOT.TH2

2-dim ROOT histogram

Returns:

hdu : ImageHDU

Histogram in FITS format.

Examples

>>> import ROOT
>>> from gammapy.utils.root import TH2_to_FITS
>>> root_hist = ROOT.TH2F()
>>> fits_hdu = TH2_to_FITS(root_hist)
>>> fits_hdu.writetofits('my_image.fits')