Example #1
0
def add_pwn_parameters(table):
    """Add PWN parameters to the table.

    TODO: document
    """
    # Some of the computations (specifically `pwn.radius`) aren't vectorised
    # across all parameters; so here we loop over source parameters explicitly

    results = []

    for idx in range(len(table)):
        age = table["age"].quantity[idx]
        E_SN = table["E_SN"].quantity[idx]
        n_ISM = table["n_ISM"].quantity[idx]
        P0_birth = table["P0_birth"].quantity[idx]
        b_psr = table["B_PSR"].quantity[idx]

        # Compute properties
        pulsar = Pulsar(P0_birth, b_psr)
        snr = SNRTrueloveMcKee(e_sn=E_SN, n_ISM=n_ISM)
        pwn = PWN(pulsar, snr)
        r_out_pwn = pwn.radius(age).to_value("pc")
        results.append(dict(r_out_pwn=r_out_pwn))

    # Add columns to table
    table["r_out_PWN"] = Column(
        [_["r_out_pwn"] for _ in results], unit="pc", description="PWN outer radius"
    )
    return table
Example #2
0
"""Plot PWN evolution with time."""
import numpy as np
import matplotlib.pyplot as plt
from astropy.units import Quantity
from astropy.constants import M_sun
from gammapy.astro.source import PWN, SNRTrueloveMcKee

t = Quantity(np.logspace(1, 5, 100), "yr")
n_ISM = Quantity(1, "cm^-3")
snr = SNRTrueloveMcKee(m_ejecta=8 * M_sun, n_ISM=n_ISM)
pwn = PWN(snr=snr)
pwn.pulsar.L_0 = Quantity(1e40, "erg/s")

plt.plot(t.value, pwn.radius(t).to("pc").value, label="Radius PWN")
plt.plot(t.value,
         snr.radius_reverse_shock(t).to("pc").value,
         label="Reverse Shock SNR")
plt.plot(t.value, snr.radius(t).to("pc").value, label="Radius SNR")

plt.xlabel("time [years]")
plt.ylabel("radius [pc]")
plt.legend(loc=4)
plt.loglog()
plt.show()
Example #3
0
"""Plot PWN evolution with time."""
import numpy as np
import matplotlib.pyplot as plt
from astropy.units import Quantity
from astropy.constants import M_sun
from gammapy.astro.source import PWN, SNRTrueloveMcKee

t = Quantity(np.logspace(1, 5, 100), 'yr')
n_ISM = Quantity(1, 'cm^-3')
snr = SNRTrueloveMcKee(m_ejecta=8 * M_sun, n_ISM=n_ISM)
pwn = PWN(snr=snr)
pwn.pulsar.L_0 = Quantity(1E40, 'erg/s')
plt.plot(t.value, pwn.radius(t).to('pc').value, label='Radius SNR')
plt.plot(t.value,
         pwn.snr.radius_reverse_shock(t).to('pc').value,
         label='Reverse Shock SNR')
plt.plot(t.value, pwn.snr.radius(t).to('pc').value, label='Radius PWN')
plt.xlabel('time [years]')
plt.ylabel('radius [pc]')
plt.legend(loc=4)
plt.loglog()
plt.show()
Example #4
0
# Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
from numpy.testing import assert_allclose
from astropy.units import Quantity
from gammapy.astro.source import SNR, SNRTrueloveMcKee

t = Quantity([0, 1, 10, 100, 1000, 10000], "yr")
snr = SNR()
snr_mckee = SNRTrueloveMcKee()


def test_SNR_luminosity_tev():
    """Test SNR luminosity"""
    reference = [0, 0, 0, 0, 1.076e33, 1.076e33]
    assert_allclose(snr.luminosity_tev(t).value, reference, rtol=1e-3)


def test_SNR_radius():
    """Test SNR radius"""
    reference = [0, 3.085e16, 3.085e17, 3.085e18, 1.174e19, 2.950e19]
    assert_allclose(snr.radius(t).value, reference, rtol=1e-3)


def test_SNR_radius_inner():
    """Test SNR radius"""
    reference = (1 - 0.0914) * np.array(
        [0, 3.085e16, 3.085e17, 3.085e18, 1.174e19, 2.950e19])
    assert_allclose(snr.radius_inner(t).value, reference, rtol=1e-3)


def test_SNRTrueloveMcKee_luminosity_tev():
Example #5
0
"""Plot PWN evolution with time."""
import numpy as np
import matplotlib.pyplot as plt
from astropy.units import Quantity
from astropy.constants import M_sun
from gammapy.astro.source import PWN, SNRTrueloveMcKee

t = Quantity(np.logspace(1, 5, 100), 'yr')
n_ISM = Quantity(1, 'cm^-3')
snr = SNRTrueloveMcKee(m_ejecta=8 * M_sun, n_ISM=n_ISM)
pwn = PWN(snr=snr)
pwn.pulsar.L_0 = Quantity(1E40, 'erg/s')

plt.plot(t.value, pwn.radius(t).to('pc').value, label='Radius PWN')
plt.plot(t.value, snr.radius_reverse_shock(t).to('pc').value, label='Reverse Shock SNR')
plt.plot(t.value, snr.radius(t).to('pc').value, label='Radius SNR')

plt.xlabel('time [years]')
plt.ylabel('radius [pc]')
plt.legend(loc=4)
plt.loglog()
plt.show()