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

# E, Zcom, standard error
NN = np.array(
[[91, 2.3829542, 0.22002404821285632],
[114, 2.1723581591504857, 0.039454588512236426],
[124, 2.1752311114651492, 0.03212013258749892],
[150, 2.0877884830800175, 0.01848128178632359],
[174, 2.0167093246718575, 0.013319835145583618],
[205, 1.9777044584910435, 0.01152885894973702],
[247, 1.906154338388394, 0.009449902429554216]]
)

NN_FS = np.array(
[[91, 2.2392050000000006, 0.01937919051457001],
[114, 2.3946569939705884, 0.04181738331097335],
[124, 2.3351935361455847, 0.030348285170979167],
[150, 2.2349051330514857, 0.015936079188770054],
[174, 2.1647723475980007, 0.011805276327571458],
[205, 2.108961976200791, 0.009884215798610905],
[247, 2.031903127144907, 0.008196232142368667]]
)

# E, Zcom, standard error for top, bridge, and hollow
NN_site = np.array(
[[91, 2.1947333333333336, 0.05770434222059132, 2.2129288888888894, 0.1292925680066625, 3.2892337499999997, 1.2909652004949872],
[114, 2.29108052325, 0.11448832924631898, 2.0891712764919355, 0.03810109965874797, 2.304888608809524, 0.11203350410605992],
[124, 2.3167326561111112, 0.1104007654844937, 2.154425003119266, 0.03731560717318679, 2.13617008264151, 0.06359970219577205],
[150, 2.3944720042236023, 0.07705462490670498, 2.0519141442716236, 0.022046555654985752, 2.001574554673367, 0.02456076054259117],
[174, 2.334796063713733, 0.05601048277664218, 1.9764516609622824, 0.015539842190223816, 1.936394789030663, 0.018835136029308194],
[205, 2.3235745554496647, 0.05027959301719725, 1.9340168002574525, 0.012903260747315237, 1.8882623076025016, 0.016266160023947856],
[247, 2.222303307034422, 0.03874480596602351, 1.8798230897121562, 0.011176304393576364, 1.7741925773581013, 0.009821205406025612]]
)

mpl.rc("text", usetex=True)
fig = plt.figure(figsize=(3.69,3))
#fig, ax = plt.subplots(nrows=2, ncols=1, figsize=(3.69,3.))

#plt.subplot(2,1,1)

#plt.errorbar( NN[:,0], NN[:,1], yerr=NN[:,2], marker='o', label='Mobile surface', color='r', capsize=4 )
plt.errorbar( NN_site[:,0], NN_site[:,1], yerr=NN_site[:,2], marker='o', label='Top', color='r', capsize=4 )
plt.errorbar( NN_site[:,0], NN_site[:,3], yerr=NN_site[:,4], marker='o', label='Bridge', color='orange', capsize=4 )
plt.errorbar( NN_site[:,0], NN_site[:,5], yerr=NN_site[:,6], marker='o', label='Hollow', color='b', capsize=4 )

#plt.errorbar( NN_FS[:,0], NN_FS[:,1], yerr=NN_FS[:,2], marker='o', label='Frozen surface', color='r', linestyle='--', capsize=4, markerfacecolor='None' )

plt.plot([0., 400.], [2.43,2.43], linestyle=':', color='k', label='')	#Global
plt.plot([0., 400.], [2.59,2.59], linestyle=':', color='r', label='')	#Top
plt.plot([0., 400.], [2.42,2.42], linestyle=':', color='b', label='')	#Hollow
plt.plot([0., 400.], [2.39,2.39], linestyle=':', color='orange', label='')	#Bridge

plt.legend(loc='best', numpoints=1, frameon=True)
#plt.legend(loc='upper left', numpoints=1, handletextpad=0.5, borderaxespad=0.2, frameon=False)
plt.xlim(80.,260.)
plt.ylim(1.6,2.7)
plt.tick_params(length=6, width=1)
plt.ylabel(r'Z$_{\textrm{Cl}}$ (\r{A})')
plt.xlabel('Incidence energy (kJ/mol)')

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