afterglowpy.flux module

afterglowpy.flux.checkCocoonArgs(argsDict)
afterglowpy.flux.checkJetArgs(argsDict)
afterglowpy.flux.checkTNu(t, nu)
afterglowpy.flux.checkThetaPhiTNu(theta, phi, t, nu)
afterglowpy.flux.fluxDensity(t, nu, *args, **kwargs)

Compute the flux density \(F_{\nu}\) of a GRB afterglow.

Utiliizes the single shell approximation described in Ryan et al 2020 to compute the synchrotron emission from the forward shock of a blast wave at the specified times and frequencies.

fluxDensity takes many model-dependent parameters which are specified via keyword arguments. It is recommended to collect these parameters in a dictionary Z and call fluxDensity() by:

Fnu = fluxDensity(t, nu, **Z)

Alternately model parameters may be specified as positional arguments, although this interface is not recommended and may be deprecated in the future. To call a jetted model with positional and keyword arguments:

Fnu = fluxDensity(t, nu, jetType, specType, thetaObs, E0, thetaCore,
                  thetaWing, b, L0, q, ts, n0, p, epsilon_e, epsilon_B,
                  xi_N, d_L, **Z)

To call a spherical refreshed shock model with positional arguments:

Fnu = fluxDensity(t, nu, jet.Spherical, specType, uMax, uMin, Er, k,
                  MFast_solar, L0, q, ts, n0, p, epsilon_e, epsilon_B,
                  xi_N, d_L, **Z)
Parameters:
  • t (array_like or scalar) – Time since burst in observer frame, measured in seconds.

  • nu (array_like or scalar) – Frequency of flux in observer frame, measured in Hz, same size as t.

  • jetType (int) – Code for type of jet. Model codes are available in afterglowpy.jet and include: jet.TopHat, jet.Cone, jet.Gaussian, jet.PowerLaw, jet.GaussianCore, jet.PowerLawCore, and jet.Spherical.

  • specType (int) –

    Flags for type of spectrum/emissivity function. Spectrum flags are available in afterglowpy.jet and include:

    • jet.SimpleSpec broken power law with nu_m and nu_c (Ryan+ 2020,

      default),

    • jet.DeepNewtonian better handling of late-time emission when

      some electrons become non-relativistic (e.g. Sironi+ 2013),

    • jet.EpsEBar interpret the epsilon_e parameter as

      \(\bar{\epsilon}_e = \epsilon_e (p-2) / (p-1)\) (e.g. Granot & Sari 2002),

    • jet.ICCooling simple inverse-compton contribution to cooling

      (experimental).

    Flags can be combined with the | operator.

  • thetaObs (float) – Viewing angle in radians. Jet models only.

  • E0 (float) – Isotropic-equivalent energy along the jet axis in ergs. Jet models only.

  • thetaCore (float) – Half opening angle of jet core in radians. Jet models only.

  • thetaWing (float) – Outer truncation angle of the jet in radians. Ignored by jet.TopHat, jet models only.

  • b (float) – Power law index of jet angular energy distribution. Only used by jet.PowerLaw and jet.PowerLawCore.

  • n0 (float) – Number density of protons in circumburst medium in cm^{-3}.

  • p (float) – Power law index of relativistic electron energy distribution, generally p > 2.

  • epsilon_e (float) – Fraction of thermal energy in relativistic electrons, epsilon_e <= 1.

  • epsilon_B (float) – Fraction of thermal energy in magnetic field, epsilon_B <= 1.

  • xi_N (float) – Fraction of electrons that get accelerated, xi_N <= 1.

  • d_L (float) – Luminosity distance to burst, in cm.

  • z (float, optional) – Redshift of burst, defaults to 0.

  • L0 (float, optional) – Luminosity of energy injection, in erg/s. Default 0.0.

  • q (float, optional) – Power law index of energy injection: L = L0 (t/t0)^{-q}, t0 = 1 ks. Default 0.0.

  • ts (float, optional) – Time energy injection ends in burster frame, in seconds. Default 0.0.

  • g0 (float, optional) – EXPERIMENTAL. Initial Lorentz factor of outflow along jet axis, defaults to -1 (unset, jet has deceleration radius 0). Do not use with jet spreading enabled.

  • uMax (float) – Maximum 4-velocity of outflow. Only for spherical models.

  • uMin (float) – Minimum 4-velocity of outflow. Only for spherical models

  • Er (float) – Normalization of outflow’s energy distribution in ergs. Only for spherical models. E(u>U) = Er * U^{-k}

  • k (float) – Power law index of outflow’s energy distribution. Only for spherical models

  • MFast_solar (float) – Mass of material at u_max in solar masses. Only for spherical models.

  • spread ({True, False}, optional) – Whether to include jet spreading. Defaults to True.

  • counterjet ({'True', 'False'}, optional) – Whether to include counterjet emission. Defaults to False.

  • ignoreBounds ({'True', 'False'}, optional) – Whether to ignore built-in parameter bounds checking.

  • moment (array_like, optional) – An integer array the same shape as the larger of t or nu. Selects which image moment to compute. Observer’s sky is on the x-y plane, with the jet propagating in the x-direction. Moments are in terms of proper length (in cm) Options are: jet.MOM_0 Flux, default, jet.MOM_X x^1 moment, jet.MOM_Y y^1 moment, jet.MOM_Z z^1 moment, jet.MOM_XX x^2 moment, jet.MOM_YY y^2 moment, jet.MOM_ZZ, z^2 moment, jet.MOM_XY x^1 y^1, jet.MOM_YZ, jet.MOM_XZ.

  • tRes (int, optional) – Time resolution, number of points per decade in t, for shock evolution. Defaults to 1000.

  • latRes (int, optional) – Lateral resolution of structured jet, number of conical sections per thetaCore-sized interval. Defaults to 5.

  • intType (int, optional) – Integration scheme to use when computing flux. Defaults to jet.Cadre. Changing this may result in longer run times or larger than expected numerical errors.

  • rtolStruct (float, optional) – Overall relative tolerance of flux integration for structured jets. Defaults to 1.0e-2.

  • rtolTheta (float, optional) – Relative tolerance of flux integration over theta within each conical section. Defaults to 1.0e-2.

  • rtolPhi (float, optional) – Relative tolerance of flux integration over phi within each conical section. Defaults to 1.0e-2.

  • NPhi (int, optional) – Maximum number of evaluations to perform in phi direction during numerical integration. Default 1000.

  • NTheta (int, optional) – Maximum number of evaluations to perform in theta direction during numerical integration. Default 1000.

Returns:

Fnu – The flux density F_nu in the observer frame, same shape as t and nu.

Return type:

array

Raises:

ValueError – If t, nu are the wrong shape or arguments take illegal values.

afterglowpy.flux.intensity(theta, phi, t, nu, *args, **kwargs)

Compute the intensity I_nu of a GRB afterglow.

Utiliizes the single shell approximation described in Ryan et al 2019 to compute the synchrotron emission from the forward shock of a blast wave at the specified angular coordinates, times, and frequencies.

The returned intensity is that emitted by the blast wave, not that directly observed from Earth. To get the observed flux, integrate over the surface of the blast wave in the frame of the burst.

\[F_\nu = \int \! d\Omega\ I_\nu\]

Angular coordinates are in a spherical coordinate system, centered on the burst, with z-axis aligned on the jet axis.

intensity takes many model-dependent parameters which are specified via keyword arguments. It is recommended to collect these parameters in a dictionary Z and call fluxDensity() by:

Inu = intensity(theta, phi, t, nu, **Z)

Alternately model parameters may be specified as positional arguments, although this interface is not recommended and may be deprecated in the future. To call a jetted model with positional and keyword arguments:

Inu = fluxDensity(theta, phi, t, nu, jetType, specType, thetaObs, E0,
                  thetaCore, thetaWing, b, L0, q, ts, n0, p, epsilon_e,
                  epsilon_B, xi_N, d_L, **Z)

This is currently only implemented for jetted models. Do not use with jetType=jet.Spherical.

Parameters:
  • theta (array_like or scalar) – Polar angle from jet axis in radians. Scalar, or array of same shape as phi, t, and nu.

  • phi (array_like or scalar) – Azimuthal angle around jet axis in radians. Observer is at phi = 0. Scalar, or array of same shape as theta, t, and nu.

  • t (array_like or scalar) – Time since burst in observer frame, measured in seconds.

  • nu (array_like or scalar) – Frequency of flux in observer frame, measured in Hz, same size as t.

  • jetType (int) – Code for type of jet. Model codes are available in afterglowpy.jet and include: jet.TopHat, jet.Cone, jet.Gaussian, jet.PowerLaw, jet.GaussianCore, jet.PowerLawCore, and jet.Spherical.

  • specType (int) –

    Flags for type of spectrum/emissivity function. Spectrum flags are available in afterglowpy.jet and include:

    • jet.SimpleSpec broken power law with nu_m and nu_c

      (Ryan+ 2020, default),

    • jet.DeepNewtonian better handling of late-time emission when

      some electrons become non-relativistic (e.g. Sironi+ 2013),

    • jet.EpsEBar interpret the epsilon_e parameter as

      \(\bar{\epsilon}_e = \epsilon_e (p-2) / (p-1)\) (e.g. Granot & Sari 2002),

    • jet.ICCooling simple inverse-compton contribution to cooling

      (experimental).

    Flags can be combined with the | operator.

  • thetaObs (float) – Viewing angle in radians. Jet models only.

  • E0 (float) – Isotropic-equivalent energy along the jet axis in ergs. Jet models only.

  • thetaCore (float) – Half opening angle of jet core in radians. Jet models only.

  • thetaWing (float) – Outer truncation angle of the jet in radians. Ignored by jet.TopHat, jet models only.

  • b (float) – Power law index of jet angular energy distribution. Only used by jet.PowerLaw and jet.PowerLawCore.

  • n0 (float) – Number density of protons in circumburst medium in cm^{-3}.

  • p (float) – Power law index of relativistic electron energy distribution, generally p > 2.

  • epsilon_e (float) – Fraction of thermal energy in relativistic electrons, epsilon_e <= 1.

  • epsilon_B (float) – Fraction of thermal energy in magnetic field, epsilon_B <= 1.

  • xi_N (float) – Fraction of electrons that get accelerated, xi_N <= 1.

  • d_L (float) – Luminosity distance to burst, in cm.

  • z (float, optional) – Redshift of burst, defaults to 0.

  • L0 (float, optional) – Luminosity of energy injection, in erg/s. Default 0.0.

  • q (float, optional) – Power law index of energy injection: L = L0 (t/t0)^{-q}, t0 = 1 ks. Default 0.0.

  • ts (float, optional) – Time energy injection ends in burster frame, in seconds. Default 0.0.

  • g0 (float, optional) – EXPERIMENTAL. Initial Lorentz factor of outflow along jet axis, defaults to -1 (unset, jet has deceleration radius 0). Do not use with jet spreading enabled.

  • spread ({True, False}, optional) – Whether to include jet spreading. Defaults to True.

  • counterjet ({'True', 'False'}, optional) – Whether to include counterjet emission. Defaults to False.

  • ignoreBounds ({'True', 'False'}, optional) – Whether to ignore built-in parameter bounds checking.

  • tRes (int, optional) – Time resolution, number of points per decade in t, for shock evolution. Defaults to 1000.

  • latRes (int, optional) – Lateral resolution of structured jet, number of conical sections per thetaCore-sized interval. Defaults to 5.

  • intType (int, optional) – fluxDensity() parameter ignored by intensity()

  • rtolStruct (float, optional) – fluxDensity() parameter ignored by intensity()

  • rtolTheta (float, optional) – fluxDensity() parameter ignored by intensity()

  • rtolPhi (float, optional) – fluxDensity() parameter ignored by intensity()

  • NPhi (int, optional) – fluxDensity() parameter ignored by intensity()

  • NTheta (int, optional) – fluxDensity() parameter ignored by intensity()

Returns:

Inu – The specific intensity I_nu in the observer frame, same shape as theta, phi, t, and nu.

Return type:

array

Raises:

ValueError – If theta, phi, t, nu are the wrong shape or arguments take illegal values.

afterglowpy.flux.parseArgs(args, kwargs)

Parse the arguments to fluxDensity() or intensity(). Supports both positional and keyword arguments for now.