Exemplo n.º 1
0
def test_hadronic_jet(plot=True):
    from jetset.jet_model import Jet
    j = Jet(proton_distribution='plc')
    j.parameters.gmin.val = 2
    j.parameters.gmax.val = 1E8
    j.parameters.NH_pp.val = 1E10
    j.parameters.N.val = 1E1
    j.parameters.B.val = 80

    j.parameters.p.val = 2.5
    j.eval()
    j.show_model()
    sum1 = j.spectral_components.Sum.SED.nuFnu
    if plot is True:
        j.plot_model()
    j.save_model('test_jet_hadronic.pkl')
    j_new = Jet.load_model('test_jet_hadronic.pkl')
    j_new.eval()
    sum2 = j_new.spectral_components.Sum.SED.nuFnu
    np.testing.assert_allclose(sum2, sum1, rtol=1E-5)
Exemplo n.º 2
0
              electron_distribution_log_values=False)
# set parameters according to Figure 7.4 of Dermer 2009
pwl_jet.set_par("N", 1298.13238394)
pwl_jet.set_par("p", 2.8)
pwl_jet.set_par("gmin", 1e2)
pwl_jet.set_par("gmax", 1e5)
pwl_jet.set_par("B", 1)
pwl_jet.set_par("R", 1e16)
pwl_jet.set_par("beam_obj", 10)
pwl_jet.set_par("z_cosm", 0.07)
# remove SSA
pwl_jet.spectral_components.Sync.state = "on"

# synchrotron emission
pwl_jet.set_nu_grid(1e9, 1e19, 100)
pwl_jet.show_model()
pwl_jet.eval()

synch_nu = pwl_jet.spectral_components.Sync.SED.nu
synch_sed = pwl_jet.spectral_components.Sync.SED.nuFnu
plt.loglog(synch_nu, synch_sed)
plt.ylim([1e-20, 1e-9])
plt.show()
condition = synch_sed.value > 1e-20
nu = synch_nu.value[condition]
sed = synch_sed.value[condition]
np.savetxt("synch_pwl_jetset_1.1.2.txt",
           np.asarray([nu, sed]).T,
           delimiter=",")

# SSC emission
Exemplo n.º 3
0
# generate a SSA synchrotron SED to be confronted with the one produced by agnpy
from jetset.jet_model import Jet
import numpy as np
import astropy.units as u
import matplotlib.pyplot as plt

# jet with power-law electron distribution
pwl_jet = Jet(
    name="", electron_distribution="pl", electron_distribution_log_values=False
)
pwl_jet.set_nu_grid(1e9, 1e20, 50)
pwl_jet.show_model()
pwl_jet.eval()
synch_nu = pwl_jet.spectral_components.Sync.SED.nu
synch_sed = pwl_jet.spectral_components.Sync.SED.nuFnu
plt.loglog(synch_nu, synch_sed)
plt.ylim([1e-20, 1e-9])
plt.show()
condition = synch_sed.value > 1e-20
nu = synch_nu.value[condition]
sed = synch_sed.value[condition]
np.savetxt("synch_ssa_pwl_jetset_1.1.2.txt", np.asarray([nu, sed]).T, delimiter=",")

# jet with broken power-law electron distribution
bpl_jet = Jet(name="", electron_distribution="bkn")
bpl_jet.set_nu_grid(1e9, 1e20, 50)
bpl_jet.show_model()
bpl_jet.eval()
synch_nu = bpl_jet.spectral_components.Sync.SED.nu
synch_sed = bpl_jet.spectral_components.Sync.SED.nuFnu
plt.loglog(synch_nu, synch_sed)