Esempio n. 1
0
def test_dmfluxmap(jfact):
    emin = 0.1 * u.TeV
    emax = 10 * u.TeV
    massDM = 1 * u.TeV
    channel = "W"

    diff_flux = DarkMatterAnnihilationSpectralModel(mass=massDM,
                                                    channel=channel)
    int_flux = (jfact *
                diff_flux.integral(emin=emin, emax=emax)).to("cm-2 s-1")
    actual = int_flux[5, 5]
    desired = 1.94834138e-12 / u.cm**2 / u.s
    assert_quantity_allclose(actual, desired, rtol=1e-5)
Esempio n. 2
0
def test_DMAnnihilation():
    channel = "b"
    massDM = 5 * u.TeV
    jfactor = 3.41e19 * u.Unit("GeV2 cm-5")
    energy_min = 0.01 * u.TeV
    energy_max = 10 * u.TeV

    model = DarkMatterAnnihilationSpectralModel(
        mass=massDM, channel=channel, jfactor=jfactor
    )
    integral_flux = model.integral(energy_min=energy_min, energy_max=energy_max).to(
        "cm-2 s-1"
    )
    differential_flux = model.evaluate(energy=1 * u.TeV, scale=1).to("cm-2 s-1 TeV-1")

    assert_quantity_allclose(integral_flux.value, 6.19575457e-14, rtol=1e-3)
    assert_quantity_allclose(differential_flux.value, 2.97506768e-16, rtol=1e-3)
Esempio n. 3
0
    def _set_model_dataset(self, ch, mass):
        """Attach to loop dataset the model to fit."""

        jfactor = (self.flux_model.parameters["jfactor"].value *
                   self.flux_model.parameters["jfactor"].unit)
        flux_model = DarkMatterAnnihilationSpectralModel(
            mass=mass,
            channel=ch,
            sv=1,
            jfactor=jfactor,
            z=self.flux_model.model2.z,
            k=self.flux_model.model2.k,
        )
        ds = self.dataset.copy()
        ds.models = self.dataset.models.copy()
        ds.models[0].spectral_model.model2 = flux_model
        return ds
Esempio n. 4
0
    def _set_model_dataset(self, ch, mass):
        """Attach to loop dataset the model to fit."""

        jfactor = self.flux_model.parameters[
            "jfactor"].value * self.flux_model.parameters["jfactor"].unit
        flux_model = DarkMatterAnnihilationSpectralModel(mass=mass,
                                                         channel=ch,
                                                         sv=1,
                                                         jfactor=jfactor,
                                                         z=self.flux_model.z,
                                                         k=self.flux_model.k)
        if isinstance(self.dataset.models[0].spectral_model,
                      AbsorbedSpectralModel):
            flux_model = AbsorbedSpectralModel(
                flux_model, self.dataset.models[0].spectral_model.absorption,
                self.flux_model.z)
        ds = self.dataset.copy()
        ds.models[0].spectral_model = flux_model
        return ds
Esempio n. 5
0
        )

axes[0].legend()
plt.subplots_adjust(hspace=0.5)


# ## Flux maps
# 
# Finally flux maps can be produced like this:

# In[ ]:


channel = "Z"
massDM = 10 * u.TeV
diff_flux = DarkMatterAnnihilationSpectralModel(mass=massDM, channel=channel)
int_flux = (jfact * diff_flux.integral(emin=0.1 * u.TeV, emax=10 * u.TeV)).to(
    "cm-2 s-1"
)


# In[ ]:


flux_map = WcsNDMap(geom=geom, data=int_flux.value, unit="cm-2 s-1")

fig, ax, im = flux_map.plot(cmap="viridis", norm=LogNorm(), add_cbar=True)
plt.title(
    "Flux [{}]\n m$_{{DM}}$={}, channel={}".format(
        int_flux.unit, fluxes.mDM.to("TeV"), fluxes.channel
    )
# Energy axis in TeV
emin = 30 / 1000
emax = 100
energy_axis = MapAxis.from_energy_bounds(emin,
                                         emax,
                                         10,
                                         unit="TeV",
                                         name="energy")

# Define spectral model
JFAC = 3.03e18 * u.Unit("GeV2 cm-5")
mDM = 10000 * u.Unit("GeV")
channel = "b"
redshift = 0.017284
spectral_model = DarkMatterAnnihilationSpectralModel(mass=mDM,
                                                     channel=channel,
                                                     jfactor=JFAC,
                                                     z=redshift)

# If want to consider EBL, uncomment following to lines and in the following change spectral_model->model_simu
#absorption = EBLAbsorptionNormSpectralModel.read_builtin("dominguez", redshift=redshift)
#model_simu = spectral_model * absorption

# Plot the spectral model
fig_1 = plt.figure()
spectral_model.plot([(emin * 1000) / mDM.value, (emax * 1000) / mDM.value],
                    energy_power=1)
plt.title("Simulated model")
form = plt.FormatStrFormatter('$%g$')
gca().xaxis.set_major_formatter(form)
plt.close(fig_1)
fig_1.savefig('original_spectra_10tev.png', quality=95, dpi=1000)
# **Declare constants and parameters for our DM model**

#JFAC = 2.00e19 * u.Unit("GeV2 cm-5") # <--- Reticulum II Point Source
JFAC = 3.27e19 * u.Unit("GeV2 cm-5")  # <--- Reticulum II Extended
#JFAC = 1.26e20 * u.Unit("GeV2 cm-5") # <--- Draco I Extended

mDM = 40000 * u.Unit("GeV")
channel = "b"
xsection = 1e-26 * u.Unit("cm3 s-1")
redshift = 0
RATIO = 2.71

# **Define 3D Sky Model**
DarkMatterAnnihilationSpectralModel.THERMAL_RELIC_CROSS_SECTION = xsection
flux_model = DarkMatterAnnihilationSpectralModel(mass=mDM,
                                                 channel=channel,
                                                 jfactor=JFAC)

spatial_model = TemplateSpatialModel.read(jfactor_filename)

sky_model = SkyModel(spatial_model=spatial_model,
                     spectral_model=flux_model,
                     name="model-simu")

bkg_model = FoVBackgroundModel(dataset_name="dataset-simu")

models = Models([sky_model, bkg_model])

# ## Declare observation values

pointing = src_pos