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

Improving the optical depth calculation #46

Merged
merged 19 commits into from
Oct 19, 2020
Merged

Conversation

cosimoNigro
Copy link
Owner

Hello,

This PR tries to improve the optical depth calculations.
It solves issue #16 though the agreement with Finke is not yet good.

Here a comparison of the optical depths for Disk
tau_disk_comaprison_figure_14_finke_2016
agnpy absorption starts much earlier (a factor ten in energy) than the one in Finke (2016).
Additionally agnpy absorption uses the full integration: if I try to use the simplified formula in Finke (2016) - green line (blob moving parallel to the jet) I get an absorption similarly starting at lower energies than the one of the figure sampled from the paper plot (blue line).

The absorption for the Broad Line Region and Dust Torus instead starts at larger energies than in Finke
tau_dt_comparison_figure_14_finke_2016
tau_blr_lyman_alpha_comparison_figure_14_finke_2016

Note though that agnpy's absorption is self-consistent. If I replace the dust torus and the BLR with a monochromatic point-like source approximating them at large distances (larger than the size of the target) I have a very good agreement (I did the same tests for the external Compton).
tau_dt_point_source_comparison
tau_blr_point_source_comparison

I don't know what am I doing wrong, any suggestion @jsitarek, @pawel21?
@jsitarek you still have that code you used to compute optical depths, might we use it for crosschecks?

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 19, 2020

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 1.56%.

Quality metrics Before After Change
Complexity 0.25 ⭐ 0.33 ⭐ 0.08 👎
Method Length 89.49 🙂 90.93 🙂 1.44 👎
Working memory 9.90 😞 10.48 😞 0.58 👎
Quality 73.37% 🙂 71.81% 🙂 -1.56% 👎
Other metrics Before After Change
Lines 1191 1517 326
Changed files Quality Before Quality After Quality Change
agnpy/absorption.py 71.93% 🙂 69.92% 🙂 -2.01% 👎
agnpy/compton.py 75.90% ⭐ 75.90% ⭐ 0.00%
agnpy/tests/test_absorption.py 65.38% 🙂
agnpy/tests/test_compton.py 67.70% 🙂 66.86% 🙂 -0.84% 👎
agnpy/tests/test_synchrotron.py 71.51% 🙂 71.95% 🙂 0.44% 👍
agnpy/tests/utils.py 74.63% 🙂 71.43% 🙂 -3.20% 👎
docs/conf.py 68.36% 🙂 61.82% 🙂 -6.54% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
agnpy/tests/utils.py make_comparison_plot 3 ⭐ 243 ⛔ 22 ⛔ 39.30% 😞 Try splitting into smaller methods. Extract out complex expressions
agnpy/absorption.py Absorption._opacity_disk 3 ⭐ 235 ⛔ 17 ⛔ 43.11% 😞 Try splitting into smaller methods. Extract out complex expressions
agnpy/tests/test_synchrotron.py TestSynchrotron.test_ssa_reference_sed 0 168 😞 35 ⛔ 45.12% 😞 Try splitting into smaller methods. Extract out complex expressions
agnpy/compton.py ExternalCompton._sed_flux_disk 0 266 ⛔ 15 😞 46.64% 😞 Try splitting into smaller methods. Extract out complex expressions
agnpy/absorption.py tau_disk_finke_2016 0 202 😞 18 ⛔ 47.40% 😞 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

@codecov
Copy link

codecov bot commented Oct 19, 2020

Codecov Report

Merging #46 into master will increase coverage by 7.67%.
The diff coverage is 99.62%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #46      +/-   ##
==========================================
+ Coverage   83.23%   90.90%   +7.67%     
==========================================
  Files          15       16       +1     
  Lines        1312     1462     +150     
==========================================
+ Hits         1092     1329     +237     
+ Misses        220      133      -87     
Flag Coverage Δ
#unittests 90.90% <99.62%> (+7.67%) ⬆️

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

Impacted Files Coverage Δ
agnpy/tests/utils.py 98.11% <97.91%> (-1.89%) ⬇️
agnpy/absorption.py 100.00% <100.00%> (+83.01%) ⬆️
agnpy/compton.py 86.63% <100.00%> (ø)
agnpy/tests/test_absorption.py 100.00% <100.00%> (ø)
agnpy/tests/test_compton.py 100.00% <100.00%> (ø)
agnpy/tests/test_synchrotron.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c073c48...4eb4fc7. Read the comment docs.

@cosimoNigro
Copy link
Owner Author

I am merging, let us continue the discussion with issues.

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.

1 participant