# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np

#read data

Si_E, Si_coh, Si_incoh, Si_photo, Si_nucl, Si_elect, Si_totwc, Si_totwo = np.loadtxt('X-section-Si.dat', skiprows=4, unpack=True)
Fe_E, Fe_coh, Fe_incoh, Fe_photo, Fe_nucl, Fe_elect, Fe_totwc, Fe_totwo = np.loadtxt('X-section-Fe.dat', skiprows=4, unpack=True)
Pb_E, Pb_coh, Pb_incoh, Pb_photo, Pb_nucl, Pb_elect, Pb_totwc, Pb_totwo = np.loadtxt('X-section-Pb.dat', skiprows=4, unpack=True)
U_E, U_coh, U_incoh, U_photo, U_nucl, U_elect, U_totwc, U_totwo = np.loadtxt('X-section-U.dat', skiprows=4, unpack=True)


fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex='col', sharey='row')
#fig, ax1 = plt.subplots()

ax1.set_xscale('log')
ax1.set_xlabel('E [MeV]')
ax1.set_ylabel(u'Verhältnis')
ax1.plot(Si_E, Si_photo/Si_totwc, c='k', label='Photo')
ax1.plot(Si_E, Si_incoh/Si_totwc, c='r', label='Comp.')
ax1.plot(Si_E, Si_nucl/Si_totwc, c='b', label='nu. P.')
ax1.title.set_text('Si')
ax1.legend(loc='center right')

ax2.set_xscale('log')
ax2.set_xlabel('E [MeV]')
ax2.set_ylabel(u'Verhältnis')
ax2.plot(Fe_E, Fe_photo/Fe_totwc, c='k', label='Photo')
ax2.plot(Fe_E, Fe_incoh/Fe_totwc, c='r', label='Comp.')
ax2.plot(Fe_E, Fe_nucl/Fe_totwc, c='b', label='nu. P.')
ax2.title.set_text('Fe')
ax2.legend(loc='center right')

ax3.set_xscale('log')
ax3.set_xlabel('E [MeV]')
ax3.set_ylabel(u'Verhältnis')
ax3.plot(Pb_E, Pb_photo/Pb_totwc, c='k', label='Photo')
ax3.plot(Pb_E, Pb_incoh/Pb_totwc, c='r', label='Comp.')
ax3.plot(Pb_E, Pb_nucl/Pb_totwc, c='b', label='nu. P.')
ax3.title.set_text('Pb')
ax3.legend(loc='center right')

ax4.set_xscale('log')
ax4.set_xlabel('E [MeV]')
ax4.set_ylabel(u'Verhältnis')
ax4.plot(U_E, U_photo/U_totwc, c='k', label='Photo')
ax4.plot(U_E, U_incoh/U_totwc, c='r', label='Comp.')
ax4.plot(U_E, U_nucl/U_totwc, c='b', label='nu. P.')
ax4.title.set_text('U')
ax4.legend(loc='center right')

plt.savefig('vergleich-querschnitte.png',dpi=300)
plt.show()


