-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata_extract.py
64 lines (46 loc) · 1.49 KB
/
data_extract.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
import os
import numpy as np
path='/expanse/lustre/scratch/ssonti/temp_project/amber_learn/chignolin_tutorial/westpa_tutorials/tutorial7.3-chignolin/ParGaMD_finer'
os.chdir(path)
iters=len(next(os.walk('traj_segs'))[1])
iter_iters=[]
print(iters)
os.chdir('traj_segs')
for i in range(iters):
#os.chdir('C:\\Users\\svdnr\\Desktop\\test1\\traj_segs')
iters_sub=len(next(os.walk('0000{:02d}'.format(i+1)))[1])
iter_iters.append(iters_sub)
print(iter_iters)
gamd_all=[]
rmsd_all=[]
rg_all=[]
#os.chdir(path)
for i in range(iters):
os.chdir(path)
os.chdir('traj_segs/00{:04d}'.format(i+1))
for j in range(iter_iters[i]):
try:
os.chdir(path)
os.chdir('traj_segs/00{:04d}/00{:04d}'.format(i+1,j))
gamd=np.genfromtxt('gamd.log')
rmsd=np.genfromtxt('rmsd.dat')
rg=np.genfromtxt('rg.dat')
gamd_all.append(gamd)
rmsd_all.append(np.delete(rmsd,0,0))
rg_all.append(np.delete(rg,0,0))
#os.chdir(path)
print(j)
print(j,i)
except:
continue
dims1=np.shape(gamd_all)
print(dims1)
dims2=np.shape(rmsd_all)
dims3=np.shape(rg_all)
gamd_write=np.reshape(gamd_all,(dims1[0]*dims1[1],dims1[2]))
rmsd_write=np.reshape(rmsd_all,(dims2[0]*dims2[1],dims2[2]))
rg_write=np.reshape(rg_all,(dims3[0]*dims3[1],dims3[2]))
os.chdir(path)
log_gamd=np.savetxt('gamd.log',gamd_write)
log_rmsd=np.savetxt('rmsd.dat',rmsd_write)
log_rg=np.savetxt('rg.dat',rg_write)