question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unsafe SafeMaskMaker

See original GitHub issue

Gammapy version The dev version

Bug description The issue happens during the Data Reduction step, without the use of a cutout. When using a large FoV of the final stacked MapDataset, the processing by the SafeMaskMaker of an observation with a pointing position far from the center of the final MapDataset (e.g. >2.5deg for HESS) leads to a python error. The mask_safe can not be computed (crash in L176 of makers/safe.py). If a cutout centered on the pointing position is used to make an empty MapDataset from the final stacked MapDataset, the SafeMaskMaker works correctly.

It seems that there are two issues:

  • the handling of the position parameter of SafeMastMaker: the observation center is not used for a standard treatment of a run (in make_mask_energy_aeff_max and also in make_mask_energy_edisp_bias)
  • if no threshold is found in make_mask_energy_aeff_max, one should return an empty mask

Expected behavior If an observation is at the very edge of a MapDataset, the worst case should be that an empty mask is return. In all other case, no crash should happen and the mask_safe should be correctly computed.

To Reproduce

import astropy.units as u
from gammapy.maps import Map, MapAxis, WcsGeom
from gammapy.datasets import MapDataset
from gammapy.makers import MapDatasetMaker, SafeMaskMaker
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"], offset_max=offset_max
)

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)

Other information Any other information you think will be useful for us to fix the issue can go here.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
bkhelificommented, Sep 20, 2022

With the current code, the example returns:

Effective area is all zero at [85d37m58.8s 22d00m50.4s]. No safe energy band can be defined for the dataset 'obs-23592': setting mask_safeto all False. So, I think that we are safe now!

A second point is the improvement of the documentation about the Data Reduction as mentioned @AtreyeeS . One should use: empty = stacked.cutout(obs.pointing_radec, width=2 * offset_max, name=f"obs-{obs.obs_id}" ) instead of empty = stacked.copy(name=f"obs-{obs.obs_id}") I think that this is well described in this tutorial https://docs.gammapy.org/0.20.1/tutorials/starting/analysis_2.html.

So, I propose to close this issue.

0reactions
adonathcommented, Aug 2, 2022

Addressed in #3987.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Coronavirus Mask Ads Were Emailed To Millions Of ...
Roughly a billion emails promoted overpriced face masks with misleading claims. The man selling them says it isn't his fault.
Read more >
Untitled
Installationsvorschriften elektro bad, Finalist f106 rotalla, ... Murali achanta, Cannon safe safari 5932 36-gun safe, Mask maker game, Crash bash you fail ...
Read more >
UNIVERSIT`A DEGLI STUDI DI PADOVA
a SafeMaskMaker is exploited. For instance, a mask with a maximum effective area or offset angle. At this point the spectrum Dataset can...
Read more >
Affordable & Dangerous: Why You Should Avoid Surplus Gas ...
They made be cheap and plentiful, but surplus gas masks are dangerous and unreliable. Read our article to find out why you should...
Read more >
https://www.metro.net/media/board/recap/2019/20190...
No information is available for this page.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found