fermi-lat / Fermitools-conda

Conda recipe files for the Fermi Sciencetools software analysis package: Fermitools
https://fermi.gsfc.nasa.gov/ssc/data/analysis/
BSD 3-Clause "New" or "Revised" License
34 stars 17 forks source link

Incorrect energy bounds in "EBOUNDS" HDU in DRM file created with gtdrm #61

Closed me-manu closed 4 years ago

me-manu commented 4 years ago

Hi, I would like to export the detector response matrix from my analysis using the gtdrm tool. It runs ok and generates the desired output as a fits file. The fits file contains several HDUs, the one called DRM contains the energy dispersion matrix as well as the true energy bins. I suspect that the HDU called EBOUNDS should contain the reconstructed energy bounds, i.e., simply a copy of the bounds of the counts cube or source map used to run gtdrm. However, it's an array with the number of bins equal to the number of bins of the spatial binning used in the counts map. The array entries start at 500 and then simply increase linearly. This can't be right.

This is especially important for people who would like to do a combined analysis of Fermi and Cherenkov telescope data using, e.g., gammapy. With this bug, it's not possible to ingest the DRM into gammapy using this function: https://docs.gammapy.org/0.16/api/gammapy.irf.EDispKernel.html#gammapy.irf.EDispKernel

Furthermore, the hidden key word "edisp_bins" is not mentioned in the documentation: https://github.com/fermi-lat/fermitools-fhelp/blob/master/gtdrm.txt When calling gtdrm the query for it reads "Number of bins to consider energy dispersion for" which is very misleading. It should be something like "Number of energy bins to prepend and append to the reconstructed energy array for the true energy array".

Thanks!

eacharles commented 4 years ago

Ok, there was a bug that it was writing the y-pixel centers to the EBOUNDS HDU. I fixed that, but the default is to only write the EBOUNDS for the original energy binning, not the extra bins. I wanted to check if you needed the extra bins in the EBOUND HDU, or the original energy bins.

I also fixed the help string the in .par file to ask for the number of "extra bins" on "each side" of the spectrum.

Let me know about the if you need the extra bins in the EBOUNDS HDU and I'll fix it accordingly.

me-manu commented 4 years ago

Thanks, Eric. That should be fine, only the observed energy bins were missing. The true energy bins (with the appended bins on either side) are in the DRM HDU. I'm going ahead and close this issue.