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

Absorption with cubepy #133

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

pawel21
Copy link
Collaborator

@pawel21 pawel21 commented Jan 10, 2023

Hi,

I have created PR for my modification of code for absorption using cubepy.
I added example notebook in agnpy/docs/tutorials

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@pawel21
Copy link
Collaborator Author

pawel21 commented Mar 12, 2023

@cosimoNigro @jsitarek could you look on my PR? :)

@cosimoNigro
Copy link
Owner

I will @pawel21, sorry for the delay. I had little time in general and an issue to fix before this PR.
Will try in the next two weeks.

agnpy/absorption/absorption.py Outdated Show resolved Hide resolved
agnpy/absorption/absorption.py Outdated Show resolved Hide resolved
agnpy/absorption/absorption.py Show resolved Hide resolved
agnpy/absorption/absorption.py Outdated Show resolved Hide resolved
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from agnpy.absorption import Absorption\n",
"from agnpy.targets import SphericalShellBLR, lines_dictionary"
Copy link
Collaborator

Choose a reason for hiding this comment

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

you should add some explanations what this notebook is doing

"source": [
"SUM_RATIO_LINES_BLR = 30.652\n",
"\n",
"def get_absor_blrs(E, L_disk, R_line, r_blob_bh, z):\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

this function would be useful to be included in the main code of agnpy
XI_LINE and eps_abs should be then among the function parameters

@jsitarek
Copy link
Collaborator

sorry for a very late feedback on this
@pawel21 - I left a few comments on the PR
@cosimoNigro - how do you prefer to proceed - should this function substitute the current integration? or should it be added as a separate function (like Paweł did now)? In the latter case a test comparing the two methods should be added.
The former case might be more reasonable, because this method is more precise and do not have those crazy memore requirements of the standard integration scheme.

@jsitarek
Copy link
Collaborator

jsitarek commented Jul 6, 2023

digging through my old e-mails I realized that this PR is still pending.
@pawel21 I think that still 2 of my comments are not implemented/responded
@cosimoNigro any feedback about the general implementation and relation to the older code?

@cosimoNigro
Copy link
Owner

Sorry for letting it slip, will do the review later today.

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.

Thanks a lot for your work @pawel21, and apologies again if I got disconnected and took a while to review it.

I think once you fix mine and @jsitarek's comments we can merge it in.
Discussing how to handle the general approach towards integration (e.g. allowing to choose between trapezoidal and adaptive integration) is something we should discuss together at a certain point in the future, along with the re-organisation of the package, not in this PR.

# conversions
epsilon_1 = nu_to_epsilon_prime(nu, z)

def f(x):
Copy link
Owner

Choose a reason for hiding this comment

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

I think it's not a good idea to define a function within another function.
I think the nested function will be recompiled each time the outer function is called. Could you move it outside?

epsilon_line,
R_line,
r,
mu=mu_to_integrate,
Copy link
Owner

Choose a reason for hiding this comment

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

the mu and phi arguments are not used in the function, you use directly the default mu_to_integrate and phi_to_integrate

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

"""

tau_blr_list = []
for freq in nu:
Copy link
Owner

Choose a reason for hiding this comment

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

I think the problem of using integrators as cubepy, that rely on functions, instead of trapz is that you do not get directly the output as an array but you are forced to loop over each frequency value. Anyhow, I think this is good for the moment.

blr_shells = dict()
absorption_shells = dict()

for line_key in lines_dictionary.keys():
Copy link
Owner

Choose a reason for hiding this comment

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

I am a bit lost with the calculations in this for loop.
Are you assuming that the target is a SphericalShellBLR emitting the Hbeta line? If this is not the case then I have troubles in understanding why you scale radius and luminosity to the current (arbitrary) line.

Copy link
Owner

Choose a reason for hiding this comment

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

If, on the other hand, the user has to use the Hbeta line as a target, then this should be stated explicitly somewhere.

@@ -0,0 +1,275 @@
{
Copy link
Owner

Choose a reason for hiding this comment

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

Line #1.    SUM_RATIO_LINES_BLR = 30.652

If this notebook has to be included in the docs I think it needs to be considerably improved, at the moment it has no commentary and it does not explain what its purpose is.


Reply via ReviewNB

@cosimoNigro
Copy link
Owner

Another thing that is missing is an absorption function returning the actual attenuation factor in the cubepy case, now only tau is computed.

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