Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9bfc005
Merge branch 'pylint_and_flake8' of https://github.com/cosimoNigro/agnpy
pawel21 Nov 26, 2021
3bb4a33
Merge branch 'master' of https://github.com/cosimoNigro/agnpy
pawel21 Feb 3, 2022
a23cab0
calcurate absorption using cubepy
pawel21 Aug 31, 2022
0ca6f70
add set up error to integrate
pawel21 Sep 9, 2022
4b9f0e3
iterate freq to compute tau_blr
pawel21 Sep 20, 2022
be9979a
Merge branch 'master' of https://github.com/cosimoNigro/agnpy into ab…
pawel21 Nov 10, 2022
eff6965
Merge branch 'master' of https://github.com/cosimoNigro/agnpy into ab…
pawel21 Dec 6, 2022
bcd1888
add notebook with absorption in BLR with cubepy
pawel21 Jan 10, 2023
ffdecbe
Merge branch 'master' of https://github.com/cosimoNigro/agnpy into ab…
pawel21 Apr 6, 2023
403a0bb
remove l_size
pawel21 Apr 6, 2023
c0b6cfa
start develop funtion to calcurate absorption over all line for BLR
pawel21 Apr 6, 2023
8e21ba8
added fun to calculate absorption in all BLR lines
pawel21 May 16, 2023
57d67bc
nodified notebook to new function
pawel21 May 16, 2023
7039b98
add test for absorption in BLR with cubepy
pawel21 Apr 26, 2024
dd28724
remove not used parameters
pawel21 Apr 26, 2024
92eb17b
Add more clear explanations for docs string about calc tau in BLR
pawel21 Jun 3, 2024
e75d6d8
Add function to compute inegrand for cubepy
pawel21 Jun 3, 2024
d5b4778
Merge branch 'master' of https://github.com/cosimoNigro/agnpy into ab…
pawel21 Jun 3, 2024
a81e789
Add environment dependencies for cubepy
pawel21 Jun 3, 2024
eeed0a9
Fix environment dependencies
pawel21 Jun 3, 2024
3aabb7c
Check target name during calc tau
pawel21 Jun 3, 2024
e6b73df
Fix problem with cubepy instalion
pawel21 Jun 7, 2024
269eec2
add cubepy requires to setup.py
pawel21 Jun 7, 2024
70b6ef8
work on exmpale notebook
pawel21 Jul 19, 2024
246a7d3
remove notebook from docs
pawel21 Oct 2, 2024
ede4818
make code more concise and renamed function
pawel21 Oct 9, 2024
6c00ba1
add unit in doc and add tau_blr_lines_cubepy_function
pawel21 Dec 18, 2024
ea38e31
Merge branch 'master' into absorption_with_cubepy
pawel21 Jan 21, 2025
af96f66
improved docs description
pawel21 Jan 21, 2025
33f96df
start write test for compare tau blr standard with cubepy
pawel21 Jan 22, 2025
1ca2ef9
test
pawel21 Jan 22, 2025
9cd77ea
Merge branch 'absorption_with_cubepy' of https://github.com/pawel21/a…
pawel21 Jan 22, 2025
fe80a75
add test for tau calcuration with standard and cubepy method
pawel21 Jan 23, 2025
d9584a8
remove function for all lines and remove unnecessary objects
pawel21 Jan 27, 2025
a2b1aaf
pass line_dict.keys() as default argument
pawel21 Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions agnpy/absorption/absorption.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
from ..emission_regions import Blob
from ..synchrotron import nu_synch_peak, Synchrotron

import cubepy as cp


__all__ = ["sigma", "Absorption", "ebl_files_dict", "EBL"]

Expand Down Expand Up @@ -443,6 +445,99 @@ def evaluate_tau_blr_mu_s(
)
return (prefactor * integral).to_value("")

@staticmethod
def evaluate_tau_blr_cubepy(
nu,
eps_abs,
z,
mu_s,
L_disk,
xi_line,
epsilon_line,
R_line,
r,
l_size=50,
Comment thread
jsitarek marked this conversation as resolved.
Outdated
mu=mu_to_integrate,
Comment thread
jsitarek marked this conversation as resolved.
Outdated
phi=phi_to_integrate,
):
"""Evaluates the gamma-gamma absorption produced by a spherical shell
BLR for a general set of model parameters using cubepy

Parameters
----------
nu : :class:`~astropy.units.Quantity`
array of frequencies, in Hz, to compute the tau
**note** these are observed frequencies (observer frame)
z : float
redshift of the source
mu_s : float
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this function is following evaluate_tau_blr that is only valid for mu_s=1 (otherwise integration over path of the photon and over the distance from the black hole is not equivalent), so it should not have it as a parameter (@cosimoNigro can you also have a look at this?)

cosine of the angle between the blob motion and the jet axis
L_disk : :class:`~astropy.units.Quantity`
Luminosity of the disk whose radiation is being reprocessed by the BLR
xi_line : float
fraction of the disk radiation reprocessed by the BLR
epsilon_line : string
dimensionless energy of the emitted line
R_line : :class:`~astropy.units.Quantity`
radius of the BLR spherical shell
r : :class:`~astropy.units.Quantity`
distance between the Broad Line Region and the blob
l_size : int
Comment thread
jsitarek marked this conversation as resolved.
Outdated
size of the array of distances from the BH to integrate over
mu, phi : :class:`~numpy.ndarray`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

those two are not in the list of parameters

arrays of cosine of zenith and azimuth angles to integrate over

Returns
-------
:class:`~astropy.units.Quantity`
Comment thread
jsitarek marked this conversation as resolved.
Outdated
array of the tau values corresponding to each frequency
"""
# conversions
epsilon_1 = nu_to_epsilon_prime(nu, z)

def f(x):
Comment thread
jsitarek marked this conversation as resolved.
Outdated
# mu -> x[0], phi -> x[1], log_l -> x[2]
mu = x[0]
phi = x[1]
log_l = x[2]
l = np.exp(log_l)
mu_star = mu_star_shell(mu, R_line.to_value('cm'), l)
_cos_psi = cos_psi(mu_s, mu_star, phi)
x = x_re_shell(mu, R_line.to_value('cm'), l)
s = epsilon_1 * epsilon_line * (1 - _cos_psi) / 2
integrand = (1 - _cos_psi)*l / x ** 2 * sigma(s).to_value("cm**2")
return integrand

# set boundary for integration
low = np.array(
[
[min(mu_to_integrate)],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the integration of mu and phi should be simply -1 to 1 and 0 to 2 pi.

[min(phi_to_integrate)],
[np.log(r.to_value('cm'))]
]
)

high = np.array(
[
[max(mu_to_integrate)],
[max(phi_to_integrate)],
[np.log(1e5*r.to_value('cm'))]
]
)


prefactor = (L_disk * xi_line) / (
(4 * np.pi) ** 2 * epsilon_line * m_e * c ** 3
)

prefactor = prefactor.to("cm-1")
eps = eps_abs / prefactor.to_value("cm-1")
value, error = cp.integrate(f, low, high, abstol=eps)
integral = value[0]*u.cm
return (prefactor * integral[0]).to_value("")



def tau_blr(self, nu):
"""Evaluates the gamma-gamma absorption produced by a spherical shell
BLR for a general set of model parameters
Expand All @@ -467,6 +562,7 @@ def tau_blr_mu_s(self, nu):
"""
return self.evaluate_tau_blr_mu_s(
nu,
eps_abs,
self.z,
self.mu_s,
self.target.L_disk,
Expand All @@ -479,6 +575,31 @@ def tau_blr_mu_s(self, nu):
phi=self.phi,
)

def tau_blr_cubepy(self, nu, eps_abs=1e-6):
"""Evaluates the gamma-gamma absorption produced by a spherical shell
BLR for a general set of model parameters with cubepy integration
method
"""

tau_blr_list = []
for freq in nu:
Comment thread
jsitarek marked this conversation as resolved.
tau_blr_list.append(
self.evaluate_tau_blr_cubepy(
freq,
eps_abs,
self.z,
self.mu_s,
self.target.L_disk,
self.target.xi_line,
self.target.epsilon_line,
self.target.R_line,
self.r,
l_size=self.l_size,
Comment thread
jsitarek marked this conversation as resolved.
Outdated
mu=self.mu,
phi=self.phi,
))
return tau_blr_list

@staticmethod
def evaluate_tau_dt(
nu,
Expand Down
Loading