Exemple #1
0
def test_safe_mask_maker(observations):
    obs = observations[0]

    axis = MapAxis.from_edges([0.1, 1, 10],
                              name="energy",
                              interp="log",
                              unit="TeV")
    geom = WcsGeom.create(npix=(11, 11),
                          axes=[axis],
                          skydir=obs.pointing_radec)

    empty_dataset = MapDataset.create(geom=geom)
    dataset_maker = MapDatasetMaker(offset_max="3 deg")
    safe_mask_maker = SafeMaskMaker(offset_max="3 deg")
    dataset = dataset_maker.run(empty_dataset, obs)

    mask_offset = safe_mask_maker.make_mask_offset_max(dataset=dataset,
                                                       observation=obs)
    assert_allclose(mask_offset.sum(), 109)

    mask_energy_aeff_default = safe_mask_maker.make_mask_energy_aeff_default(
        dataset=dataset, observation=obs)
    assert_allclose(mask_energy_aeff_default.sum(), 242)

    with pytest.raises(NotImplementedError) as excinfo:
        safe_mask_maker.make_mask_energy_edisp_bias(dataset)

    assert "only supported" in str(excinfo.value)

    with pytest.raises(NotImplementedError) as excinfo:
        safe_mask_maker.make_mask_energy_edisp_bias(dataset)

    assert "only supported" in str(excinfo.value)
Exemple #2
0
def test_safe_mask_maker_dl3(spectrum_dataset_maker_crab,
                             observations_hess_dl3):
    safe_mask_maker = SafeMaskMaker()

    obs = observations_hess_dl3[0]
    dataset = spectrum_dataset_maker_crab.run(obs)
    dataset = safe_mask_maker.run(dataset, obs)
    assert_allclose(dataset.energy_range[0].value, 1)
    assert dataset.energy_range[0].unit == "TeV"

    mask_safe = safe_mask_maker.make_mask_energy_aeff_max(dataset)
    assert mask_safe.sum() == 4

    mask_safe = safe_mask_maker.make_mask_energy_edisp_bias(dataset)
    assert mask_safe.sum() == 3