Skip to content

Commit

Permalink
Merge pull request #264 from cta-observatory/no_nan_annoyance
Browse files Browse the repository at this point in the history
Ignore warnings of  possibly NaN bins in sensitivity
  • Loading branch information
Tobychev authored Sep 29, 2023
2 parents 4b617cc + ddd0946 commit dbacc33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changes/264.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ignore warnings about invalid floating point operations when calculating `n_signal` and `n_signal_weigthed` because the relative sensitivty is frequently NaN.
5 changes: 3 additions & 2 deletions pyirf/sensitivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,9 @@ def calculate_sensitivity(
k = "reco_energy_" + key
s[k] = signal_hist[k]

s["n_signal"] = signal_hist["n"] * rel_sens
s["n_signal_weighted"] = signal_hist["n_weighted"] * rel_sens
with np.errstate(invalid="ignore"):
s["n_signal"] = signal_hist["n"] * rel_sens
s["n_signal_weighted"] = signal_hist["n_weighted"] * rel_sens
s["n_background"] = background_hist["n"]
s["n_background_weighted"] = background_hist["n_weighted"]

Expand Down

0 comments on commit dbacc33

Please sign in to comment.