A Python 3 module to calculate GRB afterglow light curves and spectra. Details of the methods can be found in Ryan et al 2020. Builds on van Eerten & MacFadyen 2010 and van Eerten 2018. This code is under active development.
Documentation available at https://afterglowpy.readthedocs.io/
If you use this code in a publication, please refer to the package by name and cite "Ryan, G., van Eerten, H., Piro, L. and Troja, E., 2020, Astrophysical Journal 896, 166 (2020)" arXiv link.
This work is funded in part by the European Union’s Horizon 2020 Programme under the AHEAD2020 project (grant agreement n. 871158).
afterglowpy computes synchrotron emission from the forward shock of a relativistic blast wave. It includes:
- Fully trans-relativistic shock evolution through a constant density medium.
- On-the-fly integration over the equal-observer-time slices of the shock surface.
- Approximate prescription for jet spreading.
- Arbitrary viewing angles.
- Angularly structured jets, ie. E(θ)
- Spherical velocity-stratified outflows, ie. E(u)
- Counter-jet emission.
- Deep Newtonian emission.
- Image moments suitable for astrometry: centroid position and image size.
It has limited support (these should be considered experimental) for:
- Initial energy injection
- Inverse comption spectra
- Early coasting phase
It does not include (yet):
- External wind medium, ie. n ∝ r-2
- Synchrotron self-absorbtion
- Reverse shock emission
afterglowpy has been calibrated to the BoxFit code (van Eerten, van der Horst, & Macfadyen 2011, available at the Afterglow Library) and produces similar light curves for top hat jets (within 50% when same parameters are used) both on- and off-axis. Its jet models by default do not include an initial coasting phase, which may effect predictions for early observations.
afterglowpy is available via pip
:
$ pip install afterglowpy
If you are working on a local copy of this repo and would like to install from source, you can the run the following from the top level directory of the project.
$ pip install -e .
In your python code, import the library with import afterglowpy as grb
.
The main function of interest isgrb.fluxDensity(t, nu, **kwargs)
. See examples/plotLightCurve.py
for a simple example.
For jet-like afterglows there are up to 13 required keyword arguments:
jetType
an integer code setting the jet structure. It can begrb.jet.TopHat
,grb.jet.Gaussian
,grb.jet.PowerLawCore
,grb.jet.GaussianCore
,grb.jet.Spherical
, orgrb.jet.PowerLaw
.specType
an integer code specifying flags for the emissivity function and spectrum. Can begrb.jet.SimpleSpec
(basic spectrum with νm and νc),grb.jet.DeepNewtonian
,grb.jet.ICCooling
(simple inverse Compton effects on the cooling frequency, experimental).thetaObs
viewing angle in radiansE0
on-axis isotropic equivalent energy in ergthetaCore
half-width of the jet core in radians (jetType specific)thetaWing
"wing" truncation angle of the jet, in radiansb
power for power-law structure, θ-bn0
Number density of ISM, in cm-3p
Electron distribution power-law index (p>2)epsilon_e
Thermal energy fraction in electronsepsilon_B
Thermal energy fraction in magnetic fieldxi_N
Fraction of electrons that get acceleratedd_L
Luminosity distance in cm
Optional keyword arguments for all models are:
z
redshift (defaults to 0)spread
boolean (defaults to True), whether to allow the jet to spread.counterjet
boolean (defaults to False), whether to include the counterjetmoment
array (integer dtype, same shape as t and nu) which sky moment to compute.L0
Fiducial luminosity for energy injection, in erg/s, default 0.0.q
Temporal power-law index for energy injection, default 0.0.ts
Fiducial time-scale for energy injection, in seconds, default 0.tRes
time resolution of shock-evolution scheme, number of sample points per decade in timelatRes
latitudinal resolution for structured jets, number of shells perthetaC
rtol
target relative tolerance of flux integration