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
Add a SafeMaskMaker at DL3 level #4599
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AtreyeeS . This is interesting, but I think we have to understand how this fits in the workflow.
A few general comments/questions:
- technically this is more an event filtering scheme than a mask creation algorithm. One could use the existing
ObservationFilter
. - one can probably split event filtering from mask creation, but the latter is still necessary for further treatment and analysis.
- the advantage of creating the masks on the input geometry and apply them to filter events is that you don't have to worry about fractional exposures in the bins. If not,
mask_safe
has to contain weights between 0 and 1 rather than booleans. This might be useful in a number of situation but requires heavy modifications instacking
and other functionalities. Currentlyedisp
is the place where we do this (and once stacked, themask_safe
is partly redundant with theEdispKernelMap
). - The idea of having event filtering as part of the list of
Makers
is interesting because it could allow reading observations from theDataStore
within the loop over observations (or in that case obs_id).
One option could be first to adapt the SafeMaskMaker
to use the observation IRF
rather than the Dataset
IRF to build the mask. This would alleviate some of the difficulties we have currently.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #4599 +/- ##
==========================================
- Coverage 75.71% 75.67% -0.05%
==========================================
Files 228 229 +1
Lines 33778 33865 +87
==========================================
+ Hits 25576 25627 +51
- Misses 8202 8238 +36 ☔ View full report in Codecov by Sentry. |
This should be ready for review now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AtreyeeS, I left few minor comments. It may be further simplified to have less nested if tests, but if it is not possible it may be nicer to move the DL3/DL4 cases in separate functions. I will have a closer look into that.
Edit: I removed a bit of code duplication, @AtreyeeS, @registerrier could you look back to it ?
Signed-off-by: Atreyee Sinha <asinha@ucm.es>
Signed-off-by: Atreyee Sinha <atreyee@Debjyotis-Mac-mini.local>
Signed-off-by: Atreyee Sinha <atreyee@Debjyotis-Mac-mini.local>
Signed-off-by: Quentin Remy <quentin.remy@mpi-hd.mpg.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AtreyeeS . This looks good. I have only minor comments.
gammapy/makers/safe.py
Outdated
@@ -84,6 +88,10 @@ def __init__( | |||
"`position` and `fixed_offset` attributes are mutually exclusive" | |||
) | |||
|
|||
if irfs not in ["DL3", "DL4"]: | |||
raise IOError("Invalid option fro irfs. Choose 'DL3' or 'DL4'.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise IOError("Invalid option fro irfs. Choose 'DL3' or 'DL4'.") | |
raise ValueError("Invalid option for irfs: expected 'DL3' or 'DL4', got {irfs} instead.") |
gammapy/makers/safe.py
Outdated
Whether to use reprojected ("DL4") or raw ("DL3") irfs | ||
Default is "DL4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether to use reprojected ("DL4") or raw ("DL3") irfs | |
Default is "DL4" | |
Whether to use reprojected ("DL4") or raw ("DL3") irfs. | |
Default is "DL4". |
Co-authored-by: Régis Terrier <regis.terrier@m4x.org>
Co-authored-by: Régis Terrier <regis.terrier@m4x.org>
Co-authored-by: Régis Terrier <regis.terrier@m4x.org>
Thanks @registerrier ! Commited your suggestions. Should be good to merge now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AtreyeeS . No further comment.
CI fail is unrelated. Merging now. |
This PR implements a SafeMaskMaker to run on DL3 IRFs as discussed in #3878 .
The cuts are applied directly on the event list.
Since HAWC and SWGO are directly using DL4 IRFs, I guess there is no need to adapt this PR for non pointing instruments.
In this case, the
SafeMakerDL3
must be run before theMapDatasetMaker
, as opposed to theSafeMaskMaker
The energy dispersion is not applied as yet.