Skip to content

Commit

Permalink
Fix energy_bias_resolution_from_energy_dispersion
Browse files Browse the repository at this point in the history
This function still assumed the wrong normalization of
the energy dispersion fixed in pyirf 0.10.
  • Loading branch information
maxnoe committed Oct 19, 2023
1 parent dbacc33 commit 29bd509
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/changes/268.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix ``pyirf.benchmarks.energy_bias_resolution_from_energy_dispersion``.
This function was not adapted to the now correct normalization of the
energy dispersion matrix, resulting in wrong results on the now correct
matrices.
3 changes: 2 additions & 1 deletion pyirf/benchmarks/energy_bias_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def energy_bias_resolution_from_energy_dispersion(
Bin edges for the relative energy migration (``reco_energy / true_energy``)
"""

cdf = np.cumsum(energy_dispersion, axis=1)
bin_width = np.diff(migration_bins)
cdf = np.cumsum(energy_dispersion * bin_width[np.newaxis, :, np.newaxis], axis=1)

n_energy_bins, _, n_fov_bins = energy_dispersion.shape

Expand Down
2 changes: 2 additions & 0 deletions pyirf/benchmarks/tests/test_bias_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def test_energy_bias_resolution():
cdf[energy_bin, :, fov_bin] = norm.cdf(reco_energy, mu, sigma)

edisp = cdf[:, 1:, :] - cdf[:, :-1, :]
bin_width = np.diff(migra_bins)
edisp /= bin_width[np.newaxis, :, np.newaxis]

bias, resolution = energy_bias_resolution_from_energy_dispersion(
edisp,
Expand Down

0 comments on commit 29bd509

Please sign in to comment.