import sys
import os


system = []
ev = []
hf_lda = []
val_lda = []
basis=sys.argv[1]
func=sys.argv[2]
print basis
print func 


filepath = 'G2_cc-p'+basis+'.dat'

with open(filepath, "r") as fp:
   cipsi = []
   for line in fp:
     a=line.split()
     cipsi.append(line.split())
     system.append(a[0])
     ev.append(a[1])


#print cipsi

filepath = 'data_HF_'+basis+'_'+func
with open(filepath, "r") as fp2:
   for line in fp2:
     a=line.split()
 #   print a[0], a[1]
     hf_lda.append(a[1])
     val_lda.append(a[2])

file_pbe = open("G2_CIPSI_"+basis+"_"+func+"_full.dat","w+")
count=0
for e in ev:
  file_pbe.write(system[count] +'  '+str(float(e)+float(hf_lda[count]))+'\n')
  count += 1


file_pbe_val = open("G2_CIPSI_"+basis+"_"+func+"_valence.dat","w+")
count=0
for e in ev:
  if (count==1):
   print float(e), float(val_lda[count]) , float(hf_lda[count])

  file_pbe_val.write(system[count] +'  '+''+str(float(e)+float(val_lda[count]))+'\n')
  count += 1


