#!/usr/bin/env python
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
from sticking_data import *

mpl.rc("text", usetex=True)
plt.style.use('tableau-colorblind10')
Nrows = 1
Ncols = 1
fig, ax = plt.subplots(nrows=Nrows, ncols=Ncols, figsize=(3.69,3.))

ax1 = plt.subplot(Nrows,Ncols,1)

plt.errorbar( QCT_LO_CH4_bisson_2007[:,0], QCT_LO_CH4_bisson_2007[:,1], yerr=QCT_LO_CH4_bisson_2007[:,2], marker='o', color='C00', label=r'QCT', capsize=4 )
plt.errorbar( TRPMD_0323K_MS_beta1000K_CH4_bisson_2007[:,0], TRPMD_0323K_MS_beta1000K_CH4_bisson_2007[:,1], yerr=TRPMD_0323K_MS_beta1000K_CH4_bisson_2007[:,2], color='C01', marker='s', label=r'RPMD ($T=1000$ K)', capsize=4, ls='--' )
plt.errorbar( TRPMD_0323K_MS_beta500K_CH4_bisson_2007[:,0], TRPMD_0323K_MS_beta500K_CH4_bisson_2007[:,1], yerr=TRPMD_0323K_MS_beta500K_CH4_bisson_2007[:,2], color='C05', markerfacecolor='None', marker='s', label=r'RPMD ($T=500$ K)', capsize=4, ls='--', zorder=5 )
plt.errorbar( Exp_LO_CH4_bisson_2007[:,0], Exp_LO_CH4_bisson_2007[:,1], yerr=Exp_LO_CH4_bisson_2007[:,3], marker='d', color='C02', label=r'Exp.', capsize=4, ls=':' )
#plt.plot( RPH_GS_500_CH4[:,1], RPH_GS_500_CH4[:,4], color='C03', marker='^', label=r'RPH', ls='-.' )

#plt.plot([77.2,77.2],[0.,1.], c='k', ls=':')

#plt.annotate( r'(A) CH$_4$', xy=(0.1, 0.8), xycoords='axes fraction', fontsize=10)
#plt.annotate( r'CH$_4$', xy=(0.1, 0.8), xycoords='axes fraction', fontsize=12)

#plt.title(r'CH$_4$ (laser-off)')
plt.legend(loc='lower right', numpoints=1, fontsize=10)
#plt.legend(loc='best', numpoints=1, borderaxespad=0.4, handletextpad=0.5)
plt.xlim(25,70.)
plt.yscale('log')
plt.ylim(1e-5,3e-2)
locmaj = mpl.ticker.LogLocator(base=10,numticks=12)
ax1.yaxis.set_major_locator(locmaj)
locmin = mpl.ticker.LogLocator(base=10.0,subs=(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12)
ax1.yaxis.set_minor_locator(locmin)
ax1.yaxis.set_minor_formatter(mpl.ticker.NullFormatter())
plt.tick_params(axis='y', which=('minor'), direction='in', right=True)
plt.tick_params(length=6, width=1, direction='in', top=True, right=True)
plt.ylabel('Sticking probability')
plt.xlabel('Incidence energy (kJ/mol)')

# ax1 = plt.subplot(Nrows,Ncols,2)

# plt.errorbar( QCT_LO_CHD3_migliorini_2017[:,0], QCT_LO_CHD3_migliorini_2017[:,1], yerr=QCT_LO_CHD3_migliorini_2017[:,2], color='C00', marker='o', label=r'QCT', capsize=4 )
# plt.errorbar( TRPMD_beta1000K_CHD3_migliorini_2017[:,0], TRPMD_beta1000K_CHD3_migliorini_2017[:,1], yerr=TRPMD_beta1000K_CHD3_migliorini_2017[:,2], color='C01', marker='s', label=r'RPMD', capsize=4, ls='--' )
# #plt.errorbar( SSRPMD_beta1000K_CHD3_migliorini_2017[:,0], SSRPMD_beta1000K_CHD3_migliorini_2017[:,1], yerr=SSRPMD_beta1000K_CHD3_migliorini_2017[:,2], color='C05', marker='s', label=r'SSRPMD (LO)', capsize=4, ls='--' )
# plt.errorbar( Exp_LO_CHD3_migliorini_2017[:,0], Exp_LO_CHD3_migliorini_2017[:,1], yerr=Exp_LO_CHD3_migliorini_2017[:,2], color='C02', marker='d', label=r'Exp.', capsize=4 )
# plt.plot( RPH_LO_500_CHD3[:,0], RPH_LO_500_CHD3[:,1], color='C03', marker='^', label=r'RPH', ls='-.' )

# #plt.plot([77.2,77.2],[0.,1.], c='k', ls=':')

# plt.annotate( r'(B) CHD$_3$', xy=(0.1, 0.8), xycoords='axes fraction', fontsize=10)

# #plt.title(r'CHD$_3$ (laser-off)')
# #plt.legend(loc='best', numpoints=1)
# #plt.legend(loc='best', numpoints=1, borderaxespad=0.4, handletextpad=0.5)
# #plt.xlim(65,125.)
# plt.ylim(0,0.2)
# plt.tick_params(length=6, width=1, direction='in', top=True, right=True, labelleft=False, labelright=True)
# ax1.yaxis.set_label_position("right")
# plt.ylabel('Sticking probability')
# plt.xlabel('Incidence energy (kJ/mol)')

plt.tight_layout()
#plt.subplots_adjust(wspace=0, hspace=0)
plt.savefig('stickingprobability_beta.pdf')
#plt.show()
