-
Notifications
You must be signed in to change notification settings - Fork 0
/
jobAnalysis.py
executable file
·123 lines (109 loc) · 3.75 KB
/
jobAnalysis.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
import os, sys
class JobAnalysis():
def __init__(self, simName, lsf='runall.lsf'):
self.cwd = os.getcwd()
self.lsf = lsf
self.simName = simName
def getCurrDateTime(self):
''' Returns the date and time back in a format that is like
m/d/y hh:mm'''
import datetime
now = datetime.datetime.now()
now = [now.month, now.day, now.year, now.hour, now.minute]
time = '%02d/%02d/%04d %02d:%02d' % tuple(now)
return time
def getRunallTime(self):
times = []
with open(self.lsf) as f:
data_full = f.readlines()
for data in data_full:
try:
if data.split()[1] == 'day' or data.split()[1]=='endday':
times.append(int(data.split()[-1].rstrip(';')))
except:
pass
return times
def getPBSInfo(self):
PBS = []
with open(self.lsf) as f:
data_full = f.readlines()
for data in data_full:
try:
if data.split()[0] == '#PBS':
PBS.append(data)
except:
pass
return PBS
def getAprunInfo(self):
aprun = []
with open(self.lsf) as f:
data_full = f.readlines()
for data in data_full:
try:
if data.split()[0].find('aprun') != -1:
aprun.append(data)
except:
pass
return aprun
def getMSHViews(self):
with open('MSHviews') as f:
data = f.readlines()
return data
def getPreQCTxt(self):
txt = []
os.chdir('PreQC')
with open(simName+'.txt') as f:
for line in f:
txt.append(line)
os.chdir('../')
return txt
def readMesh(self, fname):
import sys
twoDM = False
threeDM = False
ext = fname.split('.')[-1]
if ext == '2dm':
twoDM = True
elif ext == '3dm':
threeDM = True
else:
print 'Invalid extension'
sys.exit()
nx = []
ny = []
nz = []
nnodes = 0
nfacets = 0
with open(fname) as f:
for line in f:
if line.split()[0] == "E3T" and twoDM:
nfacets += 1
elif line.split()[0] == "E4T" and threeDM:
nfacets += 1
elif line.split()[0] == "ND":
nnodes += 1
nx.append(float(line.split()[2]))
ny.append(float(line.split()[3]))
nz.append(float(line.split()[4]))
else:
pass
min_x = min(nx)
max_x = max(nx)
min_y = min(ny)
max_y = max(ny)
min_z = min(nz)
max_z = max(nz)
return (nnodes, nfacets, min_x, max_x, min_y, max_y, min_z, max_z)
def printMeshStats(self, stats):
nnodes, nfacets, min_x, max_x, min_y, max_y, min_z, max_z = stats
ctr_x = (max_x-min_x)/2
ctr_y = (max_y-min_y)/2
ctr_z = (max_z-min_z)/2
data_str = 'Number of nodes: %d\n' % nnodes
data_str += 'Number of facets: %d\n' %nfacets
data_str += 'Min x: %10.3f\tMax x: %10.3f\tCtr x: %10.3f\n' % (min_x, max_x, ctr_x)
data_str += 'Min y: %10.3f\tMax y: %10.3f\tCtr y: %10.3f\n' % (min_y, max_y, ctr_y)
data_str += 'Min z: %10.3f\tMax z: %10.3f\tCtr z: %10.3f\n' % (min_z, max_z, ctr_z)
data_str += 'Extents: %g m x %g m\n' % (max_x - min_x, max_y - min_y)
data_str += 'Depth: %g m' % (max_z - min_z)
return data_str