diff --git a/docs/changes/290.feature.rst b/docs/changes/290.feature.rst index 42dacd1b..2be73b37 100644 --- a/docs/changes/290.feature.rst +++ b/docs/changes/290.feature.rst @@ -1,2 +1 @@ Make it possible to pass multiple quantiles to ``pyirf.benchmarks.angular_resolution``, calculating all of them. -If only one quantile is passed, the output is the same as before. diff --git a/examples/comparison_with_EventDisplay.ipynb b/examples/comparison_with_EventDisplay.ipynb index aa6321e2..564b8637 100644 --- a/examples/comparison_with_EventDisplay.ipynb +++ b/examples/comparison_with_EventDisplay.ipynb @@ -528,7 +528,7 @@ "\n", "plt.errorbar(\n", " 0.5 * (ang_res['reco_energy_low'] + ang_res['reco_energy_high']).to_value(u.TeV),\n", - " ang_res['containment_quantile_68'].to_value(u.deg),\n", + " ang_res['angular_resolution_68'].to_value(u.deg),\n", " xerr=0.5 * (ang_res['reco_energy_high'] - ang_res['reco_energy_low']).to_value(u.TeV),\n", " ls='',\n", " label='pyirf'\n", diff --git a/pyirf/benchmarks/angular_resolution.py b/pyirf/benchmarks/angular_resolution.py index 0fde76a9..a8d4f146 100644 --- a/pyirf/benchmarks/angular_resolution.py +++ b/pyirf/benchmarks/angular_resolution.py @@ -59,7 +59,7 @@ def angular_resolution( if not isinstance(quantile, Sequence): quantile = [quantile] - keys = [f"containment_quantile_{value * 100:.0f}" for value in quantile] + keys = [f"angular_resolution_{value * 100:.0f}" for value in quantile] for key in keys: result[key] = u.Quantity(np.nan, table["theta"].unit) diff --git a/pyirf/benchmarks/tests/test_angular_resolution.py b/pyirf/benchmarks/tests/test_angular_resolution.py index 07a7ce66..e66ed50d 100644 --- a/pyirf/benchmarks/tests/test_angular_resolution.py +++ b/pyirf/benchmarks/tests/test_angular_resolution.py @@ -17,7 +17,7 @@ def test_empty_angular_resolution(): table = angular_resolution(events, [1, 10, 100] * u.TeV) - assert np.all(np.isnan(table["containment_quantile_68"])) + assert np.all(np.isnan(table["angular_resolution_68"])) @pytest.mark.parametrize("unit", (u.deg, u.rad)) @@ -57,7 +57,7 @@ def test_angular_resolution(unit): bins = [1, 10, 100] * u.TeV table = angular_resolution(events, bins) - ang_res = table["containment_quantile_68"].to(u.deg) + ang_res = table["angular_resolution_68"].to(u.deg) 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) @@ -68,14 +68,14 @@ def test_angular_resolution(unit): # 2 sigma coverage interval quantile = norm(0, 1).cdf(2) - norm(0, 1).cdf(-2) table = angular_resolution(events, bins, quantile=quantile) - ang_res = table["containment_quantile_95"].to(u.deg) + ang_res = table["angular_resolution_95"].to(u.deg) assert len(ang_res) == 2 assert u.isclose(ang_res[0], 2 * TRUE_RES_1 * u.deg, rtol=0.05) assert u.isclose(ang_res[1], 2 * TRUE_RES_2 * u.deg, rtol=0.05) # 25%, 50%, 90% coverage interval table = angular_resolution(events, bins, quantile=[0.25, 0.5, 0.9]) - cov_25 = table["containment_quantile_25"].to(u.deg) + cov_25 = table["angular_resolution_25"].to(u.deg) assert len(cov_25) == 2 assert u.isclose( cov_25[0], norm(0, TRUE_RES_1).interval(0.25)[1] * u.deg, rtol=0.05 @@ -84,10 +84,10 @@ def test_angular_resolution(unit): cov_25[1], norm(0, TRUE_RES_2).interval(0.25)[1] * u.deg, rtol=0.05 ) - cov_50 = table["containment_quantile_50"].to(u.deg) + cov_50 = table["angular_resolution_50"].to(u.deg) assert u.isclose(cov_50[0], norm(0, TRUE_RES_1).interval(0.5)[1] * u.deg, rtol=0.05) assert u.isclose(cov_50[1], norm(0, TRUE_RES_2).interval(0.5)[1] * u.deg, rtol=0.05) - cov_90 = table["containment_quantile_90"].to(u.deg) + cov_90 = table["angular_resolution_90"].to(u.deg) assert u.isclose(cov_90[0], norm(0, TRUE_RES_1).interval(0.9)[1] * u.deg, rtol=0.05) assert u.isclose(cov_90[1], norm(0, TRUE_RES_2).interval(0.9)[1] * u.deg, rtol=0.05)