-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaveragermsf.py
executable file
·53 lines (51 loc) · 1.54 KB
/
averagermsf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Requires Python3
from matplotlib import cm
import numpy as np
import sys
# Take filename from commandline useage
filename = str(sys.argv[1])
# Range depends on number of windows
for i in range(1, 51):
diffcheck = 0
count = 1
residcount=1
same = 1
samecount = 1
sametotal = 0
sameresidcounter = 1
# Prepare burner filer
file = open('sure.txt', 'w')
# With open(filename+str(i)+'.xvg') as f:
with open(filename + str(i) + '.xvg') as f:
for line in f:
if not "@" in line:
if not "#" in line:
splitline = line.split()
newreference = int(splitline[0])
if count<2:
oldreference = int(splitline[0])
file.write((str(count) + " " + str(splitline[1])+"\n"))
count = count+1
else:
if (newreference - oldreference) == 1:
file.write(str(residcount) + " " + str(splitline[1])+"\n")
oldreference = newreference
elif (newreference - oldreference)>1:
residcount = residcount+1
file.write(str(residcount) + " " + str(splitline[1]) + "\n")
oldreference = int(splitline[0])
f.close()
file.close()
with open("sure.txt") as c:
filenew = open("proc" + filename + str(i) + ".xvg", 'w')
for line in c:
splitlinesure = line.split()
if int(splitlinesure[0]) == same:
sametotal = sametotal + float(splitlinesure[1])
samecount = samecount + 1
else:
filenew.write(str(same) + " " + str(float(sametotal)/float(samecount-1)) + "\n")
same = same + 1
samecount = 1
sametotal = 0
filenew.write(str(same) + " " + str(float(sametotal)/float(samecount - 1)) + "\n")