def add_snr_parameters(table): """Add SNR parameters to the table. TODO: document """ # Read relevant columns age = table["age"].quantity n_ISM = table["n_ISM"].quantity # Compute properties snr = SNR(n_ISM=n_ISM) E_SN = snr.e_sn * np.ones(len(table)) r_out = snr.radius(age) r_in = snr.radius_inner(age) L_SNR = snr.luminosity_tev(age) # Add columns to table table["E_SN"] = Column(E_SN, description="SNR kinetic energy") table["r_out"] = Column(r_out.to("pc"), description="SNR outer radius") table["r_in"] = Column(r_in.to("pc"), description="SNR inner radius") table["L_SNR"] = Column(L_SNR, description="SNR photon rate above 1 TeV") return table
"""Plot SNR brightness evolution.""" import numpy as np from astropy.units import Quantity import matplotlib.pyplot as plt from gammapy.astro.source import SNR densities = Quantity([1, 0.1], "cm-3") t = Quantity(np.logspace(0, 5, 100), "yr") for density in densities: snr = SNR(n_ISM=density) F = snr.luminosity_tev(t) / (4 * np.pi * Quantity(1, "kpc")**2) plt.plot(t.value, F.to("cm-2 s-1").value, label="n_ISM = {}".format(density.value)) plt.vlines(snr.sedov_taylor_begin.to("yr").value, 1e-13, 1e-10, linestyle="--") plt.vlines(snr.sedov_taylor_end.to("yr").value, 1e-13, 1e-10, linestyle="--") plt.xlim(1e2, 1e5) plt.ylim(1e-13, 1e-10) plt.xlabel("time [years]") plt.ylabel("flux @ 1kpc [s^-1 cm^-2]") plt.legend(loc=4) plt.loglog() plt.show()
"""Plot SNR brightness evolution.""" import numpy as np import matplotlib.pyplot as plt from astropy.units import Quantity from gammapy.astro.source import SNR densities = Quantity([1, 0.1], "cm-3") t = Quantity(np.logspace(0, 5, 100), "yr") for density in densities: snr = SNR(n_ISM=density) F = snr.luminosity_tev(t) / (4 * np.pi * Quantity(1, "kpc") ** 2) plt.plot(t.value, F.to("cm-2 s-1").value, label="n_ISM = {}".format(density.value)) plt.vlines(snr.sedov_taylor_begin.to("yr").value, 1e-13, 1e-10, linestyle="--") plt.vlines(snr.sedov_taylor_end.to("yr").value, 1e-13, 1e-10, linestyle="--") plt.xlim(1e2, 1e5) plt.ylim(1e-13, 1e-10) plt.xlabel("time [years]") plt.ylabel("flux @ 1kpc [s^-1 cm^-2]") plt.legend(loc=4) plt.loglog() plt.show()
"""Plot SNR brightness evolution.""" import numpy as np import matplotlib.pyplot as plt from astropy.units import Quantity from gammapy.astro.source import SNR densities = Quantity([1, 0.1], 'cm^-3') colors = ['b', 'g'] t = Quantity(np.logspace(0, 5, 100), 'yr') for color, density in zip(colors, densities): snr = SNR(n_ISM=density) F = snr.luminosity_tev(t) / (4 * np.pi * Quantity(1, 'kpc') ** 2) plt.plot(t.value, F.to('ph s^-1 cm^-2').value, color=color, label='n_ISM = {0}'.format(density.value)) plt.vlines(snr.sedov_taylor_begin.to('yr').value, 1E-13, 1E-10, linestyle='--', color=color) plt.vlines(snr.sedov_taylor_end.to('yr').value, 1E-13, 1E-10, linestyle='--', color=color) plt.xlim(1E2, 1E5) plt.ylim(1E-13, 1E-10) plt.xlabel('time [years]') plt.ylabel('flux @ 1kpc [ph s^-1 cm ^-2]') plt.legend(loc=4) plt.loglog() plt.show()
"""Plot SNR brightness evolution.""" import numpy as np import matplotlib.pyplot as plt from astropy.units import Quantity from gammapy.astro.source import SNR densities = Quantity([1, 0.1], 'cm-3') t = Quantity(np.logspace(0, 5, 100), 'yr') for density in densities: snr = SNR(n_ISM=density) F = snr.luminosity_tev(t) / (4 * np.pi * Quantity(1, 'kpc')**2) plt.plot(t.value, F.to('cm-2 s-1').value, label='n_ISM = {0}'.format(density.value)) plt.vlines(snr.sedov_taylor_begin.to('yr').value, 1E-13, 1E-10, linestyle='--') plt.vlines(snr.sedov_taylor_end.to('yr').value, 1E-13, 1E-10, linestyle='--') plt.xlim(1E2, 1E5) plt.ylim(1E-13, 1E-10) plt.xlabel('time [years]') plt.ylabel('flux @ 1kpc [s^-1 cm^-2]') plt.legend(loc=4) plt.loglog() plt.show()