Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SafeMaskMaker fails with fixed_offset option #3984

Closed
adonath opened this issue Jun 10, 2022 · 1 comment · Fixed by #3987
Closed

SafeMaskMaker fails with fixed_offset option #3984

adonath opened this issue Jun 10, 2022 · 1 comment · Fixed by #3987
Labels
Milestone

Comments

@adonath
Copy link
Member

adonath commented Jun 10, 2022

Gammapy version
v0.20

Bug description
When using the fixed_offset option and the "aeff-max" option the SafeMaskMaker fails with:

ValueError: observation argument is mandatory with 1 deg

Expected behavior
It should handle the case correctly.

To Reproduce

from gammapy.data import DataStore
from gammapy.makers import SafeMaskMaker, MapDatasetMaker
from gammapy.maps import WcsGeom, MapAxis
from gammapy.datasets import MapDataset


data_store = DataStore.from_dir("$GAMMAPY_DATA/hess-dl3-dr1")
selection = dict(
    type="sky_circle",
    frame="icrs",
    lon="83.633 deg",
    lat="22.014 deg",
    radius="5 deg",
)
selected_obs_table = data_store.obs_table.select_observations(selection)
observations = data_store.get_observations(selected_obs_table["OBS_ID"])
energy_axis = MapAxis.from_energy_bounds(1.0, 10.0, 4, unit="TeV")

geom = WcsGeom.create(
    skydir=(85.633, 22.014),
    binsz=0.02,
    width=(10, 10),
    frame="icrs",
    proj="CAR",
    axes=[energy_axis],
)

# Reduced IRFs are defined in true energy (i.e. not measured energy).
energy_axis_true = MapAxis.from_energy_bounds(
    0.5, 20, 10, unit="TeV", name="energy_true"
)

stacked = MapDataset.create(
    geom=geom, energy_axis_true=energy_axis_true, name="crab-stacked"
)
offset_max = 2.5 * u.deg
maker = MapDatasetMaker()
maker_safe_mask = SafeMaskMaker(
    methods=["offset-max", "aeff-max"], fixed_offset="1 deg"
)


for obs in observations:
    empty = stacked.copy(name=f"obs-{obs.obs_id}")
    # A MapDataset is filled in this cutout geometry
    dataset = maker.run(empty, obs)
    # The data quality cut is applied
    dataset = maker_safe_mask.run(dataset, obs)

Triggered by #3978.

@adonath adonath added the bug label Jun 10, 2022
@adonath adonath added this to the 0.20.1 milestone Jun 10, 2022
@adonath
Copy link
Member Author

adonath commented Jun 10, 2022

The issue here is that the observation argument is not passed correctly to the other methods:

@registerrier registerrier linked a pull request Jun 13, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant