Files
katrin-plasma/docs/paper/monte-carlo-electron-spectrum/JINST/calculations/crossSections/plot_electron_elastic.py
T

125 lines
3.1 KiB
Python

#!/bin/python3
import numpy as np
import os
import sys
from astropy import units as u
from astropy import constants as const
import matplotlib
import matplotlib.pyplot as plt
# Specific includes
# =======================
homebase = os.getenv('HOMEBASE')
if homebase == None:
homebase = "/home/jonas/new_workspace/Coding/ACRONYM/acronym"
includes = homebase + "/src/grpic/boundaries_3d"
sys.path.append(includes)
import precalculation.functions.plasmaFunctions as plasmaFuncs
import analysis.plotDataFromAcronym.plot_standards as pltStd
import electronCrossSections as ecs
# inputs
# =====================
paper_path = "/home/jonas/new_workspace/notes/paper/docs/paper/monte-carlo-electron-spectrum/"
output_folder = paper_path+"/figures/"
# calculation
# ======================
energies_eV = np.logspace(-3,4,100)
energy_elastic_extrapolation = np.logspace(-3, np.log10(0.019), 50)
energy_elastic_experiment = np.logspace(np.log10(0.019), 2, 50)
energy_elastic_calculated = np.logspace(2, 4, 50)
elastic_extrapolation = ecs.electronCrossSection.elastic(energy_elastic_extrapolation)*1E4
elastic_experiment = ecs.electronCrossSection.elastic(energy_elastic_experiment)*1E4
elastic_calculated = ecs.electronCrossSection.elastic(energy_elastic_calculated)*1E4
data_elastic = np.genfromtxt(
"./TCS_concatenated.txt",
dtype=float,
delimiter=" ",
skip_header=1)
energy_extrapolation = data_elastic[:,0]
sigma_extraploation = data_elastic[:,1]
E_plot = energy_extrapolation[energy_extrapolation >= 0.02]
sigmal_plot = sigma_extraploation[energy_extrapolation >= 0.02]
sigmal_plot = sigmal_plot[E_plot < 1]
E_plot = E_plot[E_plot < 1]
def lin_fit(x):
expo = 0.12530538432192462
fact = 1.2082514958458152e-19
return fact*x**expo
x_fit = np.linspace(1e-2,1, 100)
y_fit = lin_fit(x_fit)
# plots
# ======================
pltStd.setRcParams()
prop_cycle = plt.rcParams['axes.prop_cycle']
colors = prop_cycle.by_key()['color']
(width, height) = pltStd.set_size('thesis')
fig, ax = plt.subplots(1, 1, figsize=(width, height*0.7),sharex=True)
ax.set_facecolor('#e7e7e7ff')
ax.grid(color='white')
ax.set_axisbelow(True)
ax.plot(energy_elastic_extrapolation, elastic_extrapolation, '--', label='extrapolated')
ax.plot(energy_elastic_experiment, elastic_experiment, '-', label='experiment')
ax.plot(energy_elastic_calculated, elastic_calculated, '-.', label='calculated')
ax.set_yscale('log')
ax.set_xscale('log')
ax.legend()
ax.set_xlabel(r'Energy $E$ (eV)')
ax.set_ylabel(r'Cross section $\sigma$ (cm$^{2}$)')
plt.savefig(output_folder+"eT2_ela.pdf",bbox_inches='tight')
#plt.show()
(width, height) = pltStd.set_size('thesis')
fig, ax = plt.subplots(1, 1, figsize=(width, height*0.7),sharex=True)
ax.set_facecolor('#e7e7e7ff')
ax.grid(color='white')
ax.plot(x_fit, y_fit, '--', label='fit')
ax.plot(E_plot, sigmal_plot, 'x', label='exp. data')
#ax.set_xlim((1E-3, 2E-2))
#ax.set_yscale('log')
ax.set_xscale('log')
ax.legend()
ax.set_xlabel(r'Energy $E$ (eV)')
ax.set_ylabel(r'Cross section $\sigma$ (cm$^{2}$)')
plt.savefig(output_folder+"eT2_ela_fit.pdf",bbox_inches='tight')
#plt.show()