<jupyter_start><jupyter_text>Calculation of dark matter spectrumThis notebook shows how to use the ```dmspectrum``` to compute spectrum from dark-matter annihilations or decay.I used PPPC4DMID tables to generate a 2D-interpolation function using ```scipy.interp2d```. You can select between the spectra including or not electroweak corrections (EW), and also the specific channel according to the available channels in the PPPC4DMID project.<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
from ctadmtool.dmspectrum.dmspectra import dmspectrum<jupyter_output><empty_output><jupyter_text>We can start by choosing some parameters for the dark matter particles and the target:<jupyter_code>masses   = (1.e+3, 1.e+4, 1.e+5)
z        = 0.018
channel  = 'Tau'<jupyter_output><empty_output><jupyter_text>Now, we can use the class method to create an instance of the ```dmspectrum``` class. This method create the instance with some default parameters:<jupyter_code>dmspec = dmspectrum.dminterp2d(channel, z)
print(dmspec.emin)
print(dmspec.energy)
print(dmspec.ebl_model)
print(dmspec.process)<jupyter_output>anna<jupyter_text>You can change properties of the ```dmspectrum``` using the corresponding setters<jupyter_code>dmspec.hasEW = False
print(dmspec.hasEW)
print(dmspec.z)
dmspec.z = 0.020
print(dmspec.z)<jupyter_output>0.018
0.02<jupyter_text>Plotting the spectrum for dark-matter anihilationsNow, we can plot the spectrum for the three dark matter candidates specified above<jupyter_code>fig, ax = plt.subplots(figsize=(9, 6))

cmap = plt.get_cmap('jet')
colors = [cmap(i) for i in np.linspace(0, 1, len(masses))]

for i , mass in enumerate( masses ) :

    evals         = (50, mass, 100)
    dmspec.mass   = mass
    dmspec.energy = evals
    
    dnde     = dmspec.spectra()
    energies = dmspec.energy
    
    ax.plot(energies, dnde, color=colors[i], lw=2, label='Mass: {:.2e}GeV'.format(mass))
    
ax.set_xlim(10, 1.e+5)
ax.set_ylim(1.0e-6, 1.0e-1)
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel('Energy (GeV)')
ax.set_ylabel('$\\frac{\\mathrm{d}N}{\\mathrm{d}E}$ (GeV$^{-1}$)')

ax.legend(loc='best', prop={'size':10})<jupyter_output><empty_output><jupyter_text>Plotting the spectrum for dark-matter decaysNow, we can do the same as before changing the process to ```decay```<jupyter_code>dmspec.process = 'decay'
fig, ax = plt.subplots(figsize=(9, 6))

cmap = plt.get_cmap('jet')
colors = [cmap(i) for i in np.linspace(0, 1, len(masses))]

for i , mass in enumerate( masses ) :

    evals         = (50, mass, 100)
    dmspec.mass   = mass
    dmspec.energy = evals
    
    dnde     = dmspec.spectra()
    energies = dmspec.energy
    
    ax.plot(energies, dnde, color=colors[i], lw=2, label='Mass: {:.2e}GeV'.format(mass))
    
ax.set_xlim(10, 1.e+5)
ax.set_ylim(1.0e-6, 1.0e-1)
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel('Energy (GeV)')
ax.set_ylabel('$\\frac{\\mathrm{d}N}{\\mathrm{d}E}$ (GeV$^{-1}$)')

ax.legend(loc='best', prop={'size':10})<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14233817701453105, 'fraction_numerical': 0.02443857331571995, 'mean_word_length': 4.93921568627451, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '480346', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1169, 'n_words': 269, 'path': 'notebooks/dmspectrum.ipynb', 'repo_name': 'sergiohcdna/ctadmtool', 'size': '3028'}