-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPLOT-status.py
executable file
·145 lines (103 loc) · 3.85 KB
/
PLOT-status.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/python
# -*- coding: utf-8 -*-
#_______________________________________________________________________________
from sys import stdin
from math import sqrt
from math import factorial
from pylab import *
import matplotlib.transforms as ptf
import matplotlib.ticker as ptk
import matplotlib.pyplot as plt
import pylab as pyl
import numpy
import sys
import os
#-------------------------------------------------------------------------------
def shell_value(variable,vlist,default):
v = default
e = False
for i in range(len(vlist)):
if ( vlist[i] == variable ): v = os.environ[variable] ; e = True ; break
return v, e
#-------------------------------------------------------------------------------
xlabel = u'Iteration number'
ylabel = r'RMSD $V_{SCF}$'
#-------------------------------------------------------------------------------
current = os.environ['PWD']
ev_list = os.environ.keys()
rundir = shell_value('EXCITINGRUNDIR',ev_list,current)[0]
rlabel = shell_value('RLABEL',ev_list,"")[0]
showpyplot = shell_value('SHOWPYPLOT',ev_list,"")[1]
dpipng = int(shell_value('DPIPNG',ev_list,300)[0])
#-------------------------------------------------------------------------------
narg = len(sys.argv)-1
if (narg < 1):
print "\nIncorrect number of arguments. **Usage**:\n\n",
print "PLOT-status.py DIRECTORYNAME\n"
sys.exit()
label = str(sys.argv[1])
#-------------------------------------------------------------------------------
inpf = current+"/"+rlabel+label+'/RMSDVEFF.OUT'
if (label == 'r'): inpf=rundir+'/xc-rundir/RMSDVEFF.OUT'
if (str(os.path.exists(inpf))=='False'):
sys.exit("\nERROR: file "+inpf+" not found!\n")
input_file = open(inpf,"r")
#-------------------------------------------------------------------------------
# set defauls parameters for the plot
fontlabel=20
fonttick=16
params = {'ytick.minor.size': 6,
'xtick.major.pad': 8,
'ytick.major.pad': 4,
'patch.linewidth': 2.,
'axes.linewidth': 2.,
'lines.linewidth': 1.8,
'lines.markersize': 8.0,
'axes.formatter.limits': (-5, 6)}
plt.rcParams.update(params)
plt.subplots_adjust(left=0.20, right=0.93,
bottom=0.18, top=0.88,
wspace=None, hspace=None)
yfmt = ptk.ScalarFormatter(useOffset=True,useMathText=True)
fig = matplotlib.pyplot.figure(1, figsize=(8,5.5))
ax = fig.add_subplot(111)
ax.text(0.5,-0.13,xlabel,size=fontlabel,
transform=ax.transAxes,ha='center',va='center',rotation=0)
ax.text(-0.16,0.5,ylabel,size=fontlabel,
transform=ax.transAxes,ha='center',va='center',rotation=90)
for line in ax.get_xticklines() + ax.get_yticklines():
line.set_markersize(6)
line.set_markeredgewidth(2)
plt.xticks(size=fonttick)
plt.yticks(size=fonttick)
pyl.grid(True)
#-------------------------------------------------------------------------------
x = [] ; y = []
iter=0
alast=0
alege=0
while True:
line = input_file.readline().strip()
if len(line) == 0:
if alast == 1: break
plt.plot(x,y,'b-')
plt.plot(x,y,'go',label='calculated')
if alege == 0: plt.legend(borderaxespad=.8,numpoints=1)
x = [] ; y = []
alast = 1
alege = 1
else:
alast = 0
iter = iter+1
y.append(float(line.split()[0]))
x.append(float(iter))
xmin = 1-iter/20. ; xmax = iter+iter/20.
#-------------------------------------------------------------------------------
ax.yaxis.set_major_formatter(yfmt)
ax.set_yscale('log')
ax.set_xlim(xmin,xmax)
ax.set_axisbelow(True)
plt.savefig('PLOT.ps', orientation='portrait',format='eps')
plt.savefig('PLOT.png', orientation='portrait',format='png',dpi=dpipng)
if (showpyplot): plt.show()
#-------------------------------------------------------------------------------