Skip to content

Commit

Permalink
Fill n_events in angular_resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Jul 3, 2023
1 parent fc688fc commit 887d9ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions pyirf/benchmarks/angular_resolution.py
Expand Up @@ -58,4 +58,5 @@ def angular_resolution(
by_bin = table[valid].group_by(bin_index[valid])
for bin_idx, group in zip(by_bin.groups.keys, by_bin.groups):
result[key][bin_idx] = np.nanquantile(group["theta"], ONE_SIGMA_QUANTILE)
result["n_events"][bin_idx] = len(group)
return result
8 changes: 6 additions & 2 deletions pyirf/benchmarks/tests/test_angular_resolution.py
Expand Up @@ -45,11 +45,15 @@ def test_angular_resolution(unit):
events["true_energy"].value[500] = np.nan
events["true_energy"].value[1500] = np.nan

ang_res = angular_resolution(
table = angular_resolution(
events,
[1, 10, 100] * u.TeV,
)['angular_resolution']
)

ang_res = table['angular_resolution']
assert len(ang_res) == 2
assert u.isclose(ang_res[0], TRUE_RES_1 * u.deg, rtol=0.05)
assert u.isclose(ang_res[1], TRUE_RES_2 * u.deg, rtol=0.05)

# one value in each bin is nan, which is ignored
np.testing.assert_array_equal(table["n_events"], [998, 998])

0 comments on commit 887d9ab

Please sign in to comment.