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
"""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()
"""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()
"""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()