IRF metrics should not assume linear binning
The IRF metrics that load the IRF tables into a Hist make an assumption of linear binning that may not be correct! There is no good reason to do that, since Hist supports arbitrary binning.
Bad (current code), where e_bins
are the bins defined in the FITS IRF table:
axis.Regular(
bins=len(e_bins) - 1,
start=e_bins[0].value,
stop=e_bins[-1].value,
name="Energy",
metadata=dict(unit=e_bins.unit),
transform=axis.transform.log,
),
Should be replaced with:
axis.Variable(
edges=e_bins.value,
name="Energy",
metadata=dict(unit=e_bins.unit),
),
In fact, a lot of the code in the IRF Metrics could be refactored into a single function that properly loads a standard IRF table into a set of axis bin edges and the value histogram. That function could be fairly generic:
ebins, offbins, value = read_irf_from_table(value_col="EFFAREA")
And that could even automatically return a Hist
. I'm not sure I understand the reasoning for turning the offset bins into categories instead of keeping them as non-category axes, so even that could be simplified.