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

Add a function for integrating SED flux, for different types of radiative processes #153

Merged
merged 13 commits into from Jan 5, 2024

Conversation

grzegorzbor
Copy link
Contributor

The SedFluxIntegrable is a mixin that can be added to all classes that implement sed_flux function.
It provides 2 functions, one for calculating energy flux integral, and the other for photon flux integral, over frequency range.

added a test for more realistic data (based on the synchrotron radiation sample from the agnpy documentation); added the method for photon flux SED integral; changed input parameters (allow any equivalency of Hz)
Copy link
Owner

@cosimoNigro cosimoNigro left a comment

Choose a reason for hiding this comment

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

Hello @grzegorzbor, many thanks for this first contribution!

What about making this PR a bit more general?
That is, instead of SedFluxIntegrable, I think it would be much better to directly introduce a general SedFlux (or Flux) class (from which all the radiative processes would inherit) that not only performs the integration of the flux, but also handles all these conversions that we deal with (and keep repeating) in several parts of the package. For example, the class would return the flux either as $F_{\nu} [{\rm erg} {\rm cm}^{-2} {\rm s}^{-1} {\rm Hz}^{-1}]$, as $\nu F_{\nu} [{\rm erg} {\rm cm}^{-2} {\rm s}^{-1}]$ or as a differential flux in energy, ${\rm d} \phi / {\rm d} E [{\rm eV}^{-1} {\rm cm}^{-2} {\rm s}^{-1}]$ - what we actually pass to the Gammapy wrapper and what you would finally like to integrate to obtain the integral flux in ${\rm cm}^{-2} {\rm s}^{-1}$.

agnpy/utils/sedintegrable.py Outdated Show resolved Hide resolved
agnpy/utils/sedintegrable.py Outdated Show resolved Hide resolved
agnpy/utils/sedintegrable.py Outdated Show resolved Hide resolved
agnpy/utils/sedintegrable.py Outdated Show resolved Hide resolved
agnpy/tests/test_sedintegrable.py Outdated Show resolved Hide resolved
agnpy/tests/test_sedintegrable.py Outdated Show resolved Hide resolved
agnpy/tests/test_sedintegrable.py Outdated Show resolved Hide resolved
@cosimoNigro
Copy link
Owner

Hi @grzegorzbor, I took the liberty of doing some fixes and making the code a bit slimmer.
Let me know if you like the latest changes.
Thank you!

Copy link

codecov bot commented Jan 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e6f5783) 96.95% compared to head (be47b3f) 97.02%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #153      +/-   ##
==========================================
+ Coverage   96.95%   97.02%   +0.06%     
==========================================
  Files          40       43       +3     
  Lines        3319     3395      +76     
==========================================
+ Hits         3218     3294      +76     
  Misses        101      101              
Flag Coverage Δ
unittests 97.02% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@cosimoNigro cosimoNigro merged commit c3be0a3 into cosimoNigro:master Jan 5, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants