-
Notifications
You must be signed in to change notification settings - Fork 273
Open
Labels
Description
Describe the bug
The proton and electron effective areas in the IRF output have the same format as the gamma-ray one, however they should be distinguished by HDUCLAS
not just EXTNAME
to allow gammapy to correctly find them.
Gammapy uses a function that loads these IRFs into classes that looks at the HDUCLAS headers, and not specifically the name of the HDU, so in the example below, it finds 3 Aeff IRFs.
To Reproduce
Steps to reproduce the behavior:
print(fits.info(irf_file))
No. Name Ver Type Cards Dimensions Format
0 PRIMARY 1 PrimaryHDU 4 ()
1 EFFECTIVE AREA 1 BinTableHDU 39 1R x 5C [40D, 40D, 5D, 5D, 200D]
2 ENERGY DISPERSION 1 BinTableHDU 45 1R x 7C [40D, 40D, 30D, 30D, 5D, 5D, 6000D]
3 PSF 1 BinTableHDU 47 1R x 7C [40D, 40D, 5D, 5D, 100D, 100D, 20000D]
4 BACKGROUND 1 BinTableHDU 39 1R x 5C [20D, 20D, 5D, 5D, 100D]
5 EFFECTIVE AREA PROTONS 1 BinTableHDU 39 1R x 5C [40D, 40D, 5D, 5D, 200D]
6 EFFECTIVE AREA ELECTRONS 1 BinTableHDU 39 1R x 5C [40D, 40D, 5D, 5D, 200D]
from gammapy.irf import load_irf_dict_from_file
irfs = load_irf_dict_from_file(irf_file)
print(irfs)
more than one HDU of aeff type found
loaded the EFFECTIVE AREA HDU in the dictionary
more than one HDU of aeff type found
loaded the EFFECTIVE AREA HDU in the dictionary
{'aeff': <gammapy.irf.effective_area.EffectiveAreaTable2D at 0x17383ae90>,
'edisp': <gammapy.irf.edisp.core.EnergyDispersion2D at 0x1738d9940>,
'psf': <gammapy.irf.psf.table.PSF3D at 0x1738daea0>,
'bkg': <gammapy.irf.background.Background2D at 0x17383b890>}
Here, the correct Aeff IRF is loaded, since gammapy by default only retains the first one, but the order should not be relied upon.
Expected behavior
Gammapy doesn't complain about the extra IRFs that it doesn't need to know about.