'''
Main functions for running statistics routines for MD simulations
'''
import Statistics.Plots as Plots
import Statistics.Print as Print
import Statistics.Calcs as Calcs
[docs]def RunGen(filename,index,blocksize):
'''
Read in the *filename* for a data file, the *index* for the column that you would
like to read, and the *blocksize* for averaging.
'''
t0=10000 #0000
shift=0
dat=[line.split() for line in open(filename) if line.startswith('*') == False ]
tf=len(dat)
ts=[[float(dat[i][0])+shift,dat[i][index]] for i in range(t0,tf)]
Print.PrintGenAvgFluc(ts,filename,blocksize)
[docs]def Run(filename1,filename2,index):
'''
Read in two files (*filename1* and *filename2*) and the *index* of the specified
column. The averages are printed.
'''
dat1=[line.split() for line in open(filename1) if line.startswith('*') == False ]
ts1=[[float(dat1[i][0])+10000.,dat1[i][index]] for i in range(0,len(dat1))]
Print.PrintAvgFluc('',ts1,filename1)
dat2=[line.split() for line in open(filename2) if line.startswith('*') == False ]
ts2=[[float(dat2[i][0])+10000.,dat2[i][index]] for i in range(0,len(dat2))]
Print.PrintAvgFluc('',ts2,filename2)
#Plot_TS2(ts1,ts2)
[docs]def PrintRun(filename,index):
'''
Read in the *filename* for a data file and the *index* for the column that you would
like to read. The average is printed.
'''
dat=[line.split() for line in open(filename) if line.startswith('*') == False ]
ts=[[float(dat[i][0]),dat[i][index]] for i in range(10000,len(dat))]
Print.PrintAvgFluc('',ts,filename)
[docs]def RunX2(filename1,filename2,index):
'''
'''
dat1=[line.split() for line in open(filename1) if line.startswith('*') == False ]
dat2=[line.split() for line in open(filename2) if line.startswith('*') == False ]
if filename1.startswith('x2helixa'):
ts1=[[float(i+10001),float(dat1[i][index])] for i in range(0,len(dat1))]
if filename1.startswith('x2helixb'):
ts1=[[float(i+10001),-float(dat1[i][index])] for i in range(0,len(dat1))]
if filename2.startswith('x2helixa'):
ts2=[[float(i+10001),float(dat2[i][index])] for i in range(0,len(dat2))]
if filename2.startswith('x2helixb'):
ts2=[[float(i+10001),-float(dat2[i][index])] for i in range(0,len(dat2))]
Print.PrintAvgFluc('',ts1,filename1)
Print.PrintAvgFluc('',ts2,filename2)
[docs]def RunBlock(filename1,index,start,stop,blocksize,title):
'''
'''
dat1=[line.split() for line in open(filename1) if line.startswith('*') == False ]
if str(stop).lower() == 'end':
stop = dat1[-1][0]
else:
stop = float(stop)
ts1=[[float(dat1[i][0]),dat1[i][index]] for i in range(0,len(dat1)) if float(dat1[i][0]) <= stop ]
Print.PrintAvgFluc(title,ts1,filename1)