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

Flux maps combination #5161

Merged
merged 12 commits into from May 17, 2024
Merged

Flux maps combination #5161

merged 12 commits into from May 17, 2024

Conversation

QRemy
Copy link
Contributor

@QRemy QRemy commented Mar 9, 2024

Create a new FluxMaps by combining a list of flux maps with the same geometry.
Under the gaussian error approximation the likelihood is given by the gaussian distribution. The product of gaussians is also a gaussian so can derive dnde, dnde_err, and ts for the combined map.

Copy link

codecov bot commented Mar 9, 2024

Codecov Report

Attention: Patch coverage is 98.63014% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 94.47%. Comparing base (a55f23c) to head (3f54576).
Report is 1 commits behind head on main.

Files Patch % Lines
gammapy/estimators/utils.py 97.82% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5161   +/-   ##
=======================================
  Coverage   94.46%   94.47%           
=======================================
  Files         235      235           
  Lines       35493    35566   +73     
=======================================
+ Hits        33528    33600   +72     
- Misses       1965     1966    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bkhelifi
Copy link
Member

Hello @QRemy,
Thanks a lot for this nice utility function. I have two questions:

  • maybe one could add a check and a test of maps with different geometries. This might happen frequently
  • I am wondering whether one could not extend this function for non-gaussian errors, when the scan profile is present. Maybe one could make that later into an other PR, and add a ToDo in this one....

@QRemy
Copy link
Contributor Author

QRemy commented Mar 11, 2024

  • I am wondering whether one could not extend this function for non-gaussian errors, when the scan profile is present. Maybe one could make that later into an other PR, and add a ToDo in this one....

Yes I had that in mind but first we need to implement the stat_scan option on the ExcessMapEstimator and TSMapEstimator (at least so 2 other PRs).

@QRemy QRemy added this to the 1.3 milestone Mar 11, 2024
@QRemy QRemy added this to In progress in gammapy.estimators via automation Mar 11, 2024
@registerrier
Copy link
Contributor

From the dev call, let's try to find a more explicit name for the function. It could be possibly an independent function rather than a classmethod.

Copy link
Contributor

@registerrier registerrier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @QRemy. This is nice. I have left some inline comments.

A general question is whether applying this to a regular FluxMaps is safe or not. What use cases does this cover?

gammapy/estimators/utils.py Show resolved Hide resolved
gammapy/estimators/utils.py Outdated Show resolved Hide resolved
gammapy/estimators/utils.py Outdated Show resolved Hide resolved
gammapy/estimators/utils.py Outdated Show resolved Hide resolved
gammapy/estimators/utils.py Outdated Show resolved Hide resolved
gammapy/estimators/utils.py Show resolved Hide resolved
gammapy/estimators/utils.py Outdated Show resolved Hide resolved
@registerrier
Copy link
Contributor

There is a merge conflict here. Can you rebase @QRemy ?

AtreyeeS
AtreyeeS previously approved these changes May 9, 2024
Copy link
Member

@AtreyeeS AtreyeeS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @QRemy ! I have some questions inline, but it is okay from my side

gammapy/estimators/utils.py Show resolved Hide resolved
gammapy/estimators/utils.py Show resolved Hide resolved
gammapy/estimators/utils.py Outdated Show resolved Hide resolved
gammapy/estimators/utils.py Outdated Show resolved Hide resolved
AtreyeeS
AtreyeeS previously approved these changes May 10, 2024
Copy link
Member

@AtreyeeS AtreyeeS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @QRemy for the updates! No further comments

registerrier
registerrier previously approved these changes May 16, 2024
Copy link
Contributor

@registerrier registerrier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @QRemy. Looks good to me.

I simply propose to call the function average_flux_maps as this is more explicit. Joint flux map would rather be applied to flux maps extracted jointly from a group of datasets.Actually maybe stack is even more clear as this is consistent with typical gammapy semantics.

gammapy/estimators/map/tests/test_core.py Outdated Show resolved Hide resolved
gammapy/estimators/utils.py Outdated Show resolved Hide resolved
gammapy/estimators/map/tests/test_core.py Outdated Show resolved Hide resolved
gammapy/estimators/map/tests/test_core.py Outdated Show resolved Hide resolved
gammapy/estimators/map/tests/test_core.py Outdated Show resolved Hide resolved
@QRemy
Copy link
Contributor Author

QRemy commented May 17, 2024

I simply propose to call the function average_flux_maps as this is more explicit. Joint flux map would rather be applied to flux maps extracted jointly from a group of datasets.

Maybe combine_flux_maps as we have get_combined_significance_maps. I think the term combined is often used when combining likehoods from different experiments a posteriori, especially in cosmology like in https://arxiv.org/pdf/1807.06209 .

QRemy added 4 commits May 17, 2024 12:08
Signed-off-by: Quentin Remy <quentin.remy@mpi-hd.mpg.de>
Signed-off-by: Quentin Remy <quentin.remy@mpi-hd.mpg.de>
Signed-off-by: Quentin Remy <quentin.remy@mpi-hd.mpg.de>
Signed-off-by: Quentin Remy <quentin.remy@mpi-hd.mpg.de>
QRemy and others added 8 commits May 17, 2024 12:08
Signed-off-by: Quentin Remy <quentin.remy@mpi-hd.mpg.de>
Signed-off-by: Quentin Remy <quentin.remy@mpi-hd.mpg.de>
Co-authored-by: Régis Terrier <regis.terrier@m4x.org>
Signed-off-by: Quentin Remy <quentin.remy@mpi-hd.mpg.de>
Signed-off-by: Quentin Remy <quentin.remy@mpi-hd.mpg.de>
Signed-off-by: Quentin Remy <quentin.remy@mpi-hd.mpg.de>
Signed-off-by: Quentin Remy <quentin.remy@mpi-hd.mpg.de>
@QRemy QRemy dismissed stale reviews from registerrier and AtreyeeS via 3f54576 May 17, 2024 10:08
Copy link
Contributor

@registerrier registerrier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @QRemy. Looks good!

@registerrier registerrier merged commit dba0d2b into gammapy:main May 17, 2024
16 checks passed
gammapy.estimators automation moved this from In progress to Done May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants