Skip to content

Commit ca3c39f

Browse files
author
Claudio Galelli
authored
Merge branch 'gammapy:main' into fitresults
2 parents 09d599c + 0845cfb commit ca3c39f

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

gammapy/estimators/map/tests/test_ts.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,12 +564,48 @@ def test_joint_ts_map_hawc():
564564
datasets = Datasets.read("$GAMMAPY_DATA/hawc/DL4/HAWC_pass4_public_Crab.yaml")
565565
datasets = Datasets(datasets[-2:])
566566

567-
estimator = TSMapEstimator(kernel_width=2 * u.deg, sum_over_energy_groups=False)
567+
estimator = TSMapEstimator(
568+
kernel_width=2 * u.deg, sum_over_energy_groups=False, n_jobs=4
569+
)
568570
result = estimator.run(datasets)
569571
assert_allclose(result["flux"].data[0, 59, 59], 1.909396e-13, rtol=1e-3)
570572
assert_allclose(result["sqrt_ts"].data[0, 59, 59], 10.878956, rtol=1e-3)
571573

572-
estimator = TSMapEstimator(kernel_width=2 * u.deg, sum_over_energy_groups=True)
574+
estimator = TSMapEstimator(
575+
kernel_width=2 * u.deg,
576+
sum_over_energy_groups=False,
577+
selection_optional=["stat_scan"],
578+
n_jobs=4,
579+
)
580+
result = estimator.run(datasets)
581+
assert_allclose(result["flux"].data[0, 59, 59], 1.909396e-13, rtol=1e-3)
582+
assert_allclose(result["sqrt_ts"].data[0, 59, 59], 10.878956, rtol=1e-3)
583+
assert result.stat_scan.geom.data_shape == (1, 109, 120, 120)
584+
assert result.dnde_scan_values.geom.data_shape == (1, 109, 120, 120)
585+
assert_allclose(
586+
result["dnde_scan_values"].data[0, 0, 59, 59], -3.164557e-13, rtol=1e-3
587+
)
588+
assert_allclose(result["stat_scan"].data[0, 0, 59, 59], 5193.588657, rtol=1e-3)
589+
590+
estimator = TSMapEstimator(
591+
kernel_width=2 * u.deg, sum_over_energy_groups=True, n_jobs=4
592+
)
593+
result = estimator.run(datasets)
594+
assert_allclose(result["flux"].data[0, 59, 59], 1.99452e-13, rtol=1e-3)
595+
assert_allclose(result["sqrt_ts"].data[0, 59, 59], 11.997135, rtol=1e-3)
596+
597+
estimator = TSMapEstimator(
598+
kernel_width=2 * u.deg,
599+
sum_over_energy_groups=True,
600+
selection_optional=["stat_scan"],
601+
n_jobs=4,
602+
)
573603
result = estimator.run(datasets)
574604
assert_allclose(result["flux"].data[0, 59, 59], 1.99452e-13, rtol=1e-3)
575605
assert_allclose(result["sqrt_ts"].data[0, 59, 59], 11.997135, rtol=1e-3)
606+
assert result.stat_scan.geom.data_shape == (1, 109, 120, 120)
607+
assert result.dnde_scan_values.geom.data_shape == (1, 109, 120, 120)
608+
assert_allclose(
609+
result["dnde_scan_values"].data[0, 0, 59, 59], -3.164557e-13, rtol=1e-3
610+
)
611+
assert_allclose(result["stat_scan"].data[0, 0, 59, 59], 7625.040553, rtol=1e-3)

gammapy/estimators/map/ts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ def estimate_flux_map(self, datasets):
511511
j, i = zip(*positions)
512512

513513
geom = maps[0]["counts"].geom.squash(axis_name="energy")
514-
energy_axis = maps[0]["counts"].geom.axes["energy"]
514+
energy_axis = geom.axes["energy"]
515515
dnde_ref = self.model.spectral_model(energy_axis.center)
516516

517517
for name in self.selection_all:

0 commit comments

Comments
 (0)