-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathana_openmm_log.py
More file actions
executable file
·61 lines (49 loc) · 1.4 KB
/
Copy pathana_openmm_log.py
File metadata and controls
executable file
·61 lines (49 loc) · 1.4 KB
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
54
55
56
57
58
59
#!/usr/bin/python
import sys,os
import matplotlib.pyplot as plt
if len(sys.argv) <= 3:
print "Usage: $0 md.log N_AVERAGE figure_title"
sys.exit()
else:
infile = sys.argv[1]
AVERAGE = int(sys.argv[2])
title = sys.argv[3]
outdir = "OUT_FIG"
if not os.path.isdir(outdir):
os.mkdir(outdir)
print ">>>>> Loading data.."
lines = open(infile).readlines()
first_line = lines.pop(0)
N = len(lines)
names = list()
for name in first_line[1:].split(','):
names.append( name[1:-1].replace('/','\\') )
data = dict()
for name in names:
data[name] = list()
for line in lines:
numbers = line.split(',')
for (name,number) in zip(names,numbers):
data[name].append(float(number))
print "----- Deriving averaged data.."
avg_data = dict()
for name in names:
avg_data[name] = list()
for i in range(N):
left = min(i,AVERAGE/2)
right = min(N-i,AVERAGE/2)
avg = sum( data[name][i-left:i+right] ) / (left+right)
avg_data[name].append(avg)
name0 = names[0]
for name1 in names:
print "----- Ploting: %s "%name1
figname = "%s/%s.png"%(outdir,name1)
plt.plot(data[name0],data[name1],color = 'grey',label = 'Instaneous' )
plt.plot(data[name0],avg_data[name1],color = 'red',label = 'Average' )
plt.xlabel(name0)
plt.ylabel(name1)
plt.legend(loc='best')
plt.title(title)
plt.savefig(figname)
plt.cla()
print "----- All done. "