#!/usr/bin/python import re, os, sys f = open(sys.argv[1],'r') w1 = open(os.getcwd()+'/chi2acc','w') w2 = open(os.getcwd()+'/chi2tot','w') inp = f.read() f.close() numatoms = re.search(r'Configuration contains (\d+) atoms',inp) times = re.findall(r'Time\sused\s+(\d+\.\d+)',inp) moves = re.findall(r'(\d+)\s+moves accepted\s+(\d+)\s+generated',inp) chi2 = re.findall(r'Chi\*\*2\/dof\s+(\d+\.\d*\w*\+*\d*)',inp) n=0 correctionacc=0 correctiontot=0 prevacc=float(moves[0][0]) prevtot=float(moves[0][1]) for each in moves: if n < len(chi2): if prevacc > float(each[0]): correctionacc=correctionacc+1000000 print 'mil' if prevtot > float(each[1]): correctiontot=correctiontot+1000000 movesperatomacc=(float(each[0])+correctionacc)/float(numatoms.group(1)) movesperatom=(float(each[1])+correctiontot)/float(numatoms.group(1)) w2.write(str(movesperatom) + ' ' + chi2[n] + '\n') w1.write(str(movesperatomacc) + ' ' + chi2[n] + '\n') n+=1 prevacc = float(each[0]) prevtot = float(each[1]) w1.close() w2.close() os.system('xmgrace '+ os.getcwd() + '/chi2acc ' + os.getcwd() +'/chi2tot')