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

Fix the black body SEDs of the Disk and the Dust Torus #92

Merged
merged 12 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
88 changes: 35 additions & 53 deletions agnpy/compton/external_compton.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import numpy as np
from astropy.constants import c, sigma_T, G
from ..utils.math import (
trapz_loglog,
log,
axes_reshaper,
gamma_to_integrate,
mu_to_integrate,
Expand All @@ -18,7 +16,7 @@
SphericalShellBLR,
RingDustTorus,
)
from .kernels import isotropic_kernel, compton_kernel
from .kernels import compton_kernel

__all__ = ["ExternalCompton"]

Expand All @@ -34,6 +32,8 @@ class ExternalCompton:
class describing the target photon field
r : :class:`~astropy.units.Quantity`
distance of the blob from the Black Hole (i.e. from the target photons)
integrator : func
function to be used for integration (default = `np.trapz`)
"""

def __init__(self, blob, target, r=None, integrator=np.trapz):
Expand Down Expand Up @@ -79,10 +79,10 @@ def evaluate_sed_flux_iso_mono(
mu=mu_to_integrate,
phi=phi_to_integrate
):
r"""Evaluates the flux SED,
:math:`\nu F_{\nu} \, [\mathrm{erg}\,\mathrm{cm}^{-2}\,\mathrm{s}^{-1}]`,
for External Compton on a monochromatic isotropic target photon field
for a general set of model parameters
r"""Evaluates the flux SED (:math:`\nu F_{\nu}`) for external Compton
on a monochromatic isotropic target photon field, for a general set of model parameters

**Note** parameters after \*args need to be passed with a keyword

Parameters
----------
Expand All @@ -93,7 +93,7 @@ def evaluate_sed_flux_iso_mono(
redshift of the source
d_L : :class:`~astropy.units.Quantity`
luminosity distance of the source
delta_D: float
delta_D : float
Doppler factor of the relativistic outflow
mu_s : float
cosine of the angle between the blob motion and the jet axis
Expand All @@ -106,10 +106,8 @@ def evaluate_sed_flux_iso_mono(
energy density [erg cm-3] of the target photon field
n_e : :class:`~agnpy.spectra.ElectronDistribution`
electron energy distribution
*args
\*args
parameters of the electron energy distribution (k_e, p, ...)
ssa : bool
whether to consider or not the self-absorption, default false
integrator : func
which function to use for integration, default `numpy.trapz`
gamma : :class:`~numpy.ndarray`
Expand All @@ -118,8 +116,6 @@ def evaluate_sed_flux_iso_mono(
mu, phi : :class:`~numpy.ndarray`
arrays of cosine of zenith and azimuth angles to integrate over

**Note** arguments after *args are keyword-only arguments

Returns
-------
:class:`~astropy.units.Quantity`
Expand Down Expand Up @@ -182,10 +178,10 @@ def evaluate_sed_flux_ps_behind_jet(
integrator=np.trapz,
gamma=gamma_to_integrate
):
r"""Evaluates the flux SED,
:math:`\nu F_{\nu} \, [\mathrm{erg}\,\mathrm{cm}^{-2}\,\mathrm{s}^{-1}]`,
for External Compton on a point source of photons behind the jet
for a general set of model parameters
r"""Evaluates the flux SED (:math:`\nu F_{\nu}`) for external Compton
on a point source of photons behind the jet, for a general set of model parameters

**Note** parameters after \*args need to be passed with a keyword

Parameters
----------
Expand All @@ -196,7 +192,7 @@ def evaluate_sed_flux_ps_behind_jet(
redshift of the source
d_L : :class:`~astropy.units.Quantity`
luminosity distance of the source
delta_D: float
delta_D : float
Doppler factor of the relativistic outflow
mu_s : float
cosine of the angle between the blob motion and the jet axis
Expand All @@ -211,18 +207,14 @@ def evaluate_sed_flux_ps_behind_jet(
distance between the point source and the blob
n_e : :class:`~agnpy.spectra.ElectronDistribution`
electron energy distribution
*args
\*args
parameters of the electron energy distribution (k_e, p, ...)
ssa : bool
whether to consider or not the self-absorption, default false
integrator : func
which function to use for integration, default `numpy.trapz`
gamma : :class:`~numpy.ndarray`
array of Lorentz factor over which to integrate the electron
distribution

**Note** arguments after *args are keyword-only arguments

Returns
-------
:class:`~astropy.units.Quantity`
Expand Down Expand Up @@ -289,10 +281,10 @@ def evaluate_sed_flux_ss_disk(
mu_size=100,
phi=phi_to_integrate
):
r"""Evaluates the flux SED,
:math:`\nu F_{\nu} \, [\mathrm{erg}\,\mathrm{cm}^{-2}\,\mathrm{s}^{-1}]`,
for External Compton on a monochromatic isotropic target photon field
for a general set of model parameters
r"""Evaluates the flux SED (:math:`\nu F_{\nu}`) for external Compton
on the photon field of a Shakura Sunyaev disk, for a general set of model parameters

**Note** parameters after \*args need to be passed with a keyword

Parameters
----------
Expand Down Expand Up @@ -323,19 +315,17 @@ def evaluate_sed_flux_ss_disk(
distance between the disk and the blob
n_e : :class:`~agnpy.spectra.ElectronDistribution`
electron energy distribution
*args
\*args
parameters of the electron energy distribution (k_e, p, ...)
ssa : bool
whether to consider or not the self-absorption, default false
integrator : func
which function to use for integration, default `numpy.trapz`
gamma : :class:`~numpy.ndarray`
array of Lorentz factor over which to integrate the electron
distribution
mu, phi : :class:`~numpy.ndarray`
arrays of cosine of zenith and azimuth angles to integrate over

**Note** arguments after *args are keyword-only arguments
mu_size : int
size of the array of zenith angles to integrate over
phi : :class:`~numpy.ndarray`
arrays of azimuth angles to integrate over

Returns
-------
Expand All @@ -351,7 +341,7 @@ def evaluate_sed_flux_ss_disk(
# multidimensional integration
# for the disk we do not integrate mu from -1 to 1 but choose the range
# of zenith angles subtended from a given distance
mu = SSDisk.evaluate_mu_from_r_tilde(R_in_tilde, R_out_tilde, r_tilde)
mu = SSDisk.evaluate_mu_from_r_tilde(R_in_tilde, R_out_tilde, r_tilde, mu_size)
_gamma, _mu, _phi, _epsilon_s = axes_reshaper(gamma, mu, phi, epsilon_s)
V_b = 4 / 3 * np.pi * np.power(R_b, 3)
N_e = V_b * n_e.evaluate(_gamma / delta_D, *args)
Expand Down Expand Up @@ -427,10 +417,10 @@ def evaluate_sed_flux_blr(
mu=mu_to_integrate,
phi=phi_to_integrate
):
r"""Evaluates the flux SED,
:math:`\nu F_{\nu} \, [\mathrm{erg}\,\mathrm{cm}^{-2}\,\mathrm{s}^{-1}]`,
for External Compton on a monochromatic isotropic target photon field
for a general set of model parameters
r"""Evaluates the flux SED (:math:`\nu F_{\nu}`) for External Compton on
the photon field of a spherical shell BLR, for a general set of model parameters

**Note** parameters after \*args need to be passed with a keyword

Parameters
----------
Expand All @@ -457,10 +447,8 @@ def evaluate_sed_flux_blr(
distance between the Broad Line Region and the blob
n_e : :class:`~agnpy.spectra.ElectronDistribution`
electron energy distribution
*args
\*args
parameters of the electron energy distribution (k_e, p, ...)
ssa : bool
whether to consider or not the self-absorption, default false
integrator : func
which function to use for integration, default `numpy.trapz`
gamma : :class:`~numpy.ndarray`
Expand All @@ -469,8 +457,6 @@ def evaluate_sed_flux_blr(
mu, phi : :class:`~numpy.ndarray`
arrays of cosine of zenith and azimuth angles to integrate over

**Note** arguments after *args are keyword-only arguments

Returns
-------
:class:`~astropy.units.Quantity`
Expand Down Expand Up @@ -546,10 +532,10 @@ def evaluate_sed_flux_dt(
gamma=gamma_to_integrate,
phi=phi_to_integrate
):
r"""Evaluates the flux SED,
:math:`\nu F_{\nu} \, [\mathrm{erg}\,\mathrm{cm}^{-2}\,\mathrm{s}^{-1}]`,
for External Compton on a monochromatic isotropic target photon field
for a general set of model parameters
r"""Evaluates the flux SED (:math:`\nu F_{\nu}`) for External Compton on
the photon field of a ring dust torus, for a general set of model parameters

**Note** parameters after \*args need to be passed with a keyword

Parameters
----------
Expand All @@ -576,10 +562,8 @@ def evaluate_sed_flux_dt(
distance between the Broad Line Region and the blob
n_e : :class:`~agnpy.spectra.ElectronDistribution`
electron energy distribution
*args
\*args
parameters of the electron energy distribution (k_e, p, ...)
ssa : bool
whether to consider or not the self-absorption, default false
integrator : func
which function to use for integration, default `numpy.trapz`
gamma : :class:`~numpy.ndarray`
Expand All @@ -588,8 +572,6 @@ def evaluate_sed_flux_dt(
mu, phi : :class:`~numpy.ndarray`
arrays of cosine of zenith and azimuth angles to integrate over

**Note** arguments after *args are keyword-only arguments

Returns
-------
:class:`~astropy.units.Quantity`
Expand Down
21 changes: 9 additions & 12 deletions agnpy/compton/synchrotron_self_compton.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from .kernels import isotropic_kernel
from ..synchrotron import Synchrotron
from ..utils.math import (
trapz_loglog,
log,
axes_reshaper,
gamma_to_integrate,
nu_to_integrate,
Expand All @@ -26,8 +24,8 @@ class SynchrotronSelfCompton:
emission region and electron distribution hitting the photon target
synchrotron : :class:`~agnpy.synchrotron.Synchrotron`
class describing the synchrotron photons target
integrator : (`~agnpy.math.utils.trapz_loglog`, `~numpy.trapz`)
function to be used for the integration
integrator : func
function to be used for integration (default = `np.trapz`)
"""

def __init__(self, blob, ssa=False, integrator=np.trapz):
Expand All @@ -49,10 +47,11 @@ def evaluate_sed_flux(
integrator=np.trapz,
gamma=gamma_to_integrate,
):
r"""Evaluates the SSC flux SED,
:math:`\nu F_{\nu} \, [\mathrm{erg}\,\mathrm{cm}^{-2}\,\mathrm{s}^{-1}]`,
for a general set of model parameters. Eq. 21 in [Finke2008]_.

r"""Evaluates the flux SED (:math:`\nu F_{\nu}`) for synchrotron self-Compton,
for a general set of model parameters. Eq. 9 in [Finke2008]_.

**Note** parameters after \*args need to be passed with a keyword

Parameters
----------
nu : :class:`~astropy.units.Quantity`
Expand All @@ -62,15 +61,15 @@ def evaluate_sed_flux(
redshift of the source
d_L : :class:`~astropy.units.Quantity`
luminosity distance of the source
delta_D: float
delta_D : float
Doppler factor of the relativistic outflow
B : :class:`~astropy.units.Quantity`
magnetic field in the blob
R_b : :class:`~astropy.units.Quantity`
size of the emitting region (spherical blob assumed)
n_e : :class:`~agnpy.spectra.ElectronDistribution`
electron energy distribution
*args
\*args
parameters of the electron energy distribution (k_e, p, ...)
ssa : bool
whether to consider or not the self-absorption, default false
Expand All @@ -79,8 +78,6 @@ def evaluate_sed_flux(
gamma : :class:`~numpy.ndarray`
array of Lorentz factor over which to integrate the electron
distribution

**Note** arguments after *args are keyword-only arguments

Returns
-------
Expand Down
51 changes: 51 additions & 0 deletions agnpy/data/mwl_seds/PKS1510-089_2012.ecsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# %ECSV 0.9
# ---
# datatype:
# - {name: nu, unit: Hz, datatype: float64}
# - {name: flux, unit: erg / (cm2 s), datatype: float64}
# - {name: flux_err_lo, unit: erg / (cm2 s), datatype: float64}
# - {name: flux_err_hi, unit: erg / (cm2 s), datatype: float64}
# meta: !!omap
# - {source: PKS1510-089}
# - {instrument: MWL}
# - {state: 2012 active state}
# schema: astropy-2.0
nu flux flux_err_lo flux_err_hi
2.640e+09 7.564e-14 6.336e-16 8.712e-16
4.850e+09 2.180e-13 2.037e-15 2.668e-15
8.350e+09 4.308e-13 2.505e-15 7.348e-15
1.045e+10 5.352e-13 4.493e-15 1.003e-14
1.460e+10 7.198e-13 7.884e-15 2.978e-14
2.305e+10 9.787e-13 2.973e-14 8.091e-14
3.200e+10 1.230e-12 4.928e-14 1.069e-13
3.700e+10 1.757e-12 5.920e-14 5.920e-14
8.624e+10 3.748e-12 1.337e-13 1.337e-13
1.423e+11 4.705e-12 2.932e-13 2.932e-13
1.804e+14 1.009e-11 4.539e-13 4.074e-13
2.427e+14 9.946e-12 4.301e-13 6.428e-13
4.684e+14 8.839e-12 1.693e-13 1.876e-12
5.531e+14 9.824e-12 6.789e-13 6.784e-13
6.904e+14 1.110e-11 4.997e-13 5.018e-13
8.662e+14 1.208e-11 4.984e-13 5.024e-13
1.172e+15 1.258e-11 5.163e-13 5.173e-13
1.338e+15 1.370e-11 5.742e-13 5.730e-13
1.471e+15 1.316e-11 4.410e-13 4.406e-13
2.043e+17 1.750e-12 1.742e-13 1.742e-13
2.672e+17 1.948e-12 1.763e-13 1.763e-13
3.313e+17 2.438e-12 2.206e-13 2.206e-13
4.026e+17 2.794e-12 2.528e-13 2.528e-13
5.078e+17 2.824e-12 2.811e-13 2.811e-13
6.577e+17 3.201e-12 3.473e-13 3.473e-13
8.390e+17 4.527e-12 4.631e-13 4.631e-13
1.064e+18 5.457e-12 5.744e-13 5.744e-13
1.508e+18 6.327e-12 7.090e-13 7.090e-13
3.315e+22 7.145e-10 2.097e-11 2.097e-11
7.330e+22 6.139e-10 1.787e-11 1.787e-11
1.621e+23 4.628e-10 1.844e-11 1.844e-11
3.584e+23 2.942e-10 1.922e-11 1.922e-11
7.928e+23 2.096e-10 2.272e-11 2.272e-11
1.754e+24 7.157e-11 1.977e-11 1.977e-11
3.880e+24 8.435e-11 3.190e-11 3.190e-11
2.85194577e+25 1.27292e-11 4.63772e-12 4.63772e-12
4.63090882e+25 7.79888e-12 2.89844e-12 2.89844e-12
7.49593591e+25 4.28141e-12 2.58648e-12 2.58648e-12
Loading