Files
katrin-plasma/docs/masters/creiling/LaTeX/backup_python_scripts/spectrum.ipynb
T

120 KiB

In [1]:
import numpy as np
import os
import sys

from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes
from mpl_toolkits.axes_grid1.inset_locator import mark_inset
import tikzplotlib
In [2]:
import matplotlib.pyplot as plt
%matplotlib inline

import seaborn as sns
sns.set(
    context='paper', 
    style='whitegrid', 
    palette='tab10', 
    font='sans-serif', 
    font_scale=1, 
    color_codes=True, 
    rc= {'figure.dpi' : 100,
        'text.usetex' : True,
        'axes.labelsize' : 10,
        'xtick.labelsize' : 10, 
        'ytick.labelsize' : 10,
        'legend.fontsize' : 10
        })
In [3]:
#style_path = "/Users/ChristianReiling/Documents/Masterarbeit/mcelectron-analysis/science.mplstyle"
latex_path = "/Users/ChristianReiling/Documents/Masterarbeit/docs/LaTeX/pics"
#plt.style.use(style_path)
In [4]:
me_eV = 0.511e6
decay_constant = 1.2072343416696292e-47
end_point_eV = 18.574e3
Z = 2
normation = 1.2078059173513103e-24
Ue1 = 0.82
Ue2 = 0.55
Ue3 = 0.145

def beta_dist_mass(E_eV, mnue_eV):
    if E_eV > (end_point_eV-mnue_eV):
        return 0.
    if E_eV <= 0:
        return 0.
    gamma = 1+E_eV/me_eV
    beta = np.sqrt(1 - pow(gamma,-2))
    eta =Z/beta/137.
    fermi_function = 2*np.pi*eta/(1-np.exp(-2*np.pi*eta));

    p_eV = np.sqrt(E_eV*E_eV + 2 * E_eV * me_eV)
    sqrtterm = np.sqrt(pow(end_point_eV-E_eV,2) - mnue_eV**2)
    
    return decay_constant*fermi_function*p_eV*(E_eV+me_eV)*(end_point_eV-E_eV)*sqrtterm*1e28
beta_dist_mass = np.vectorize(beta_dist_mass)
In [5]:
E_eV = np.linspace(1e-5, end_point_eV, 200)
#E_eV = 10**np.linspace(np.log10(1e1), np.log10(end_point_eV), 200)
n = beta_dist_mass(E_eV,0 )
In [6]:
plt.plot(E_eV, n)
Out [6]:
[<matplotlib.lines.Line2D at 0x122686cc0>]
In [7]:
#Eend_eV = 10**np.linspace(np.log10(end_point_eV-3), np.log10(end_point_eV), 200)
Eend_eV = np.linspace(end_point_eV-3, end_point_eV, 200)
n_0 = beta_dist_mass(Eend_eV, 0)
n_1 = beta_dist_mass(Eend_eV, 1)
In [8]:
plt.xscale('linear')
plt.yscale('linear')
plt.xlabel('Energy (eV)')
plt.ylabel('Normalized intensity (arb. units)')
plt.xlim([end_point_eV-3 ,end_point_eV])
#plt.ylim([0,0.1])
plt.plot(Eend_eV, n_0)
plt.plot(Eend_eV, n_1)
Out [8]:
[<matplotlib.lines.Line2D at 0x1227bf550>]
In [34]:
prop_cycle = plt.rcParams['axes.prop_cycle']
colors = prop_cycle.by_key()['color']

fig, ax = plt.subplots(figsize=[8.3/2.54,6/2.54])

ax.plot(E_eV, n, linewidth=2)

ax.set_xlabel(r'Electron energy ($E_0$)')
ax.set_xlim (0,2.5e4)
ax.set_xticks([0,end_point_eV/2,end_point_eV])
ax.set_xticklabels(['0','0.5','1'])

ax.set_ylim (0,1.5)
ax.set_ylabel('Intensity (arb. unit)')
ax.set_yticks([])
ax.set_yticklabels([])

ax.grid(False)

axins = zoomed_inset_axes(ax, 5500, loc=1) # zoom = 6
axins.plot(Eend_eV,n_0*4e3,linewidth=2)
axins.plot(Eend_eV,n_1*4e3,linewidth=2)
axins.set_xlim(end_point_eV-2.5, end_point_eV+0.25)

axins.set_ylim(0, 0.15e-3)
axins.set_xticks([end_point_eV-2, end_point_eV-1, end_point_eV])
axins.set_xticklabels([-2, -1, 0],size = 8, va = 'center')
axins.tick_params(direction='out', length=1, width=0)
axins.set_yticklabels([])

# draw a bbox of the region of the inset axes in the parent axes and
# connecting lines between the bbox and the inset axes area
mark_inset(ax, axins, loc1=3, loc2=4, fc="none", ec="0.5")

axins.text(end_point_eV-0.95, 0.4e-4, r'$m_{\nu}=0$\,eV', color=colors[0], size=10, ha='left')
axins.text(end_point_eV-2.4, 0.1e-4, r'$m_{\nu}=1$\,eV', color=colors[1], size=10, ha='left')
axins.set_xlabel(r'E - E$_0$ (eV)',size=8, ha='right', x=0.76, alpha=1, y=0.2)
axins.grid(False)
fig.tight_layout()
#plt.plot()
plt.savefig(latex_path + "/neutrinos/betaspec.pdf", bbox_inches='tight')
plt.savefig(latex_path + "/neutrinos/betaspec.pgf", bbox_inches='tight')
#tikzplotlib.save(latex_path + "/neutrinos/betaspec.tex")
In [35]:
from scipy import signal

E_eV = np.linspace(0, end_point_eV, 200)
n0 = beta_dist_mass(E_eV, 0)
n0 = n0/sum(n0)
n1 = beta_dist_mass(E_eV, 0)
E_eV_new = np.linspace(0, 2*end_point_eV, 399)
n01 = signal.fftconvolve(n0,n0,'full')
n01 = n01/sum(n01)

plt.plot(E_eV_new,n01)

plt.plot([2*end_point_eV-1, 2*end_point_eV, 2*end_point_eV+1], [0,0.003,0])

plt.show()
In [38]:
prop_cycle = plt.rcParams['axes.prop_cycle']
colors = prop_cycle.by_key()['color']

fig, ax = plt.subplots(figsize=[8.3/2.54, 5/2.54])

ax.plot(E_eV_new,n01,linewidth=2)
ax.plot([2*end_point_eV-1, 2*end_point_eV, 2*end_point_eV+1], [0,0.003,0],linewidth=2)

ax.set_xlabel(r'Sum of electron energies ($E_0$)')
ax.set_xlim (0,2.5*end_point_eV)
ax.set_xticks([0,end_point_eV, 2*end_point_eV])
ax.set_xticklabels(['0','0.5','1'])

ax.set_ylim (0,7.5e-3)
ax.set_ylabel('Intensity (arb. unit)')
ax.set_yticks([])
ax.set_yticklabels([])

ax.grid(False)

ax.text(0.9*end_point_eV, 5e-3, r'$2 \nu \beta \beta$', color=colors[0], size=10, ha='left')
ax.text(2*end_point_eV, 3.5e-3, r'$0 \nu \beta \beta$', color=colors[1], size=10, ha='left')

fig.tight_layout()
plt.plot()
plt.savefig(latex_path + "/neutrinos/doublebetaspec.pdf", bbox_inches='tight')
plt.savefig(latex_path + "/neutrinos/doublebetaspec.pgf", bbox_inches='tight')
#tikzplotlib.save(latex_path + "/neutrinos/betaspec.tex")
In [ ]:
In [ ]:
In [ ]: