gammapy icon indicating copy to clipboard operation
gammapy copied to clipboard

Dark Matter module: Include the option of using either CosmiXs or PPPC4 as a source for creating the DM spectra

Open rcervinoucm opened this issue 1 month ago • 9 comments

Hello, my name is Alexander Cerviño, and I am a PhD student at the High Energies Group (GAE) at the Complutense University of Madrid, supervised by Daniel Nieto. This is my first contribution to Gammapy.

In this contribution regarding the Dark Matter block, I have implemented the possibility of using CosmiXs instead of PPPC4 as a source for creating the DM spectra. The benefit of using CosmiXs is that the results they provide are more accurate since they obtain them while considering more robust approaches and more precise algorithms and physical processes.

For the implementation , I have set an option in the spectra.py file, so the user can choose between any of the sources, with PPPC4 as the default option. I have also made a match between the available channels in both projects and have found and indicated in the code that there are some discrepancies.

One thing to note is that I include the CosmiXs production file as an external source (path: gammapy/external/CosmiXs/Data/AtProduction-Gamma.dat), and I would like to know if it is possible to include it in the datasets module, just to be consistent with the procedure followed with PPPC4.

Additionally, after conducting some tests, I have checked that the differences in the results obtained by using the current Gammapy interpolator and the one provided by CosmiXs are negligible . Therefore , for simplicity, I have considered it correct to keep using the current one.

Thanks!

rcervinoucm avatar Nov 25 '25 10:11 rcervinoucm

I am currently on my phone and can't check but maybe we need to check if the authors of CosmiXs use the same interpolation as we do.

https://github.com/ajueid/CosmiXs/blob/main/Interpolate.py

Also, they provide uncertainties for the spectra, can we incorporate them as well?

StFroese avatar Nov 25 '25 11:11 StFroese

Hi, the interpolator is not exactly the same, but I have perform some tests and the difference between methods are negligible.

rcervinoucm avatar Nov 25 '25 11:11 rcervinoucm

@rcervinoucm hi, sry, should have read to the end of pr message :D

StFroese avatar Nov 25 '25 11:11 StFroese

The main question here is where the CosmiXs file should lie. It can be shipped with GAMMAPY_DATA as we do for the PPPC4 models, but it is a general question of how much we can bloat up GAMMAPY_DATA. This file is ~4.5MB, so probably it's OK to put it there for now. Opinions @registerrier ?

Yes, this is not an issue;) When one put data on our gammapy-data, one should add a readme with all the provenance and licence information. Please have a look on the other data

bkhelifi avatar Nov 25 '25 13:11 bkhelifi

I have included the test for this part on gammapy/astro/darkmatter/tests/test_spectra.py.

rcervinoucm avatar Nov 25 '25 14:11 rcervinoucm

Just some minor comments :) Nice PR!

StFroese avatar Nov 26 '25 02:11 StFroese

Thanks for the comments! I have made the corrections :)

rcervinoucm avatar Nov 26 '25 09:11 rcervinoucm

Thanks for the comments!

  • I am not sure what of you mean by specialising the PrimaryFlux class, but my intention was to make the less changes as possible in the classes structure, since the changes were mainly about the correlation between both datasets classes.
  • I have updated the to_dict() methods, thanks for noticing. In principle the serialization is working, the tests have passed.

Thanks!

rcervinoucm avatar Nov 26 '25 14:11 rcervinoucm

I have modified the code to get the ComiXs file from the new path. I have opened a PR in gammapy-data with the file inclusion https://github.com/gammapy/gammapy-data/pull/80. Thanks!

rcervinoucm avatar Nov 29 '25 11:11 rcervinoucm