-
Notifications
You must be signed in to change notification settings - Fork 186
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
Modify acceptance stacking behavior #5270
base: main
Are you sure you want to change the base?
Modify acceptance stacking behavior #5270
Conversation
Signed-off-by: Régis Terrier <rterrier@apc.in2p3.fr>
Signed-off-by: Régis Terrier <rterrier@apc.in2p3.fr>
…ng and needs to be masked first Signed-off-by: Régis Terrier <rterrier@apc.in2p3.fr>
Signed-off-by: Régis Terrier <rterrier@apc.in2p3.fr>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5270 +/- ##
==========================================
+ Coverage 94.25% 94.46% +0.20%
==========================================
Files 234 235 +1
Lines 35226 35496 +270
==========================================
+ Hits 33204 33531 +327
+ Misses 2022 1965 -57 ☔ View full report in Codecov by Sentry. |
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.
Works well in resolving #5245 for RBM analysis
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 a lot. I have just few suggestions for the docstrings
Counts outside the safe mask are lost. | ||
|
||
The ``acceptance`` of the stacked dataset is obtained by stacking the acceptance weighted | ||
by the other mask_safe onto the current unwieghted acceptance. |
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.
by the other mask_safe onto the current unwieghted acceptance. | |
by the other mask_safe onto the current unweighted acceptance. |
Note that the masking is not applied to the current dataset. If masking needs | ||
to be applied to it, use `~gammapy.MapDataset.to_masked()` first. | ||
|
||
The stacked ``acceptance_off`` is scaled so that: |
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.
Maybe one can put below the formulae for both acceptance, adding the use of the masks (in the `MapDataset.stack' docstring, one uses \epsilon for the mask
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.
We could instead put that information here https://docs.gammapy.org/1.2/user-guide/makers/ring.html ?
But, no strong opinion on if it should also be in the docstring
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.
As a user, I think it would definitely be helpful to have the formulae in the user guide (and maybe linked in the docs). Having it in the docstring might be nice too.
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.
We have all the formulas involved in stacking mentioned here, https://docs.gammapy.org/1.2/user-guide/datasets/index.html#stacking-multiple-datasets
So, maybe updating this and linking to this from the docstring would be useful
The ``acceptance`` of the stacked dataset is normalized to 1, | ||
and the stacked ``acceptance_off`` is scaled so that: | ||
Safe mask is applied to the other dataset to compute the stacked counts data. | ||
Counts outside the safe mask are lost. |
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.
I propose to add the formula, as in `MapDataset.stack'
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 @registerrier ! I think the tutorial can be adapted in a separate PR
Note that the masking is not applied to the current dataset. If masking needs | ||
to be applied to it, use `~gammapy.MapDataset.to_masked()` first. | ||
|
||
The stacked ``acceptance_off`` is scaled so that: |
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.
We have all the formulas involved in stacking mentioned here, https://docs.gammapy.org/1.2/user-guide/datasets/index.html#stacking-multiple-datasets
So, maybe updating this and linking to this from the docstring would be useful
Description
This pull request tries to solve #5245 by modifying the way
acceptance
is stacked forMapDatasetOnOff
.Now, instead of assuming the total acceptance to be equal to one, the
acceptance
is properly stacked. Becausealpha
is unchanged
acceptance_off
is therefore different now.The PR also corrects an inconsistency noted in #5261 .
MapDataset.stack
does not apply the mask ofself
when stacking. This avoids recomupting empty stacks all the time where in practice the first dataset is always empty.The
MapDataset.OnOff
had a different assumption. This is now made consistent.The docstrings where previously incorrect and have been modified. The formula are probably still incorrect.
Dear reviewer
This is ready, but docstrings need to be checked. Also the tutorial for Ring Background should be updated.