-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdensity_to_cns.py
More file actions
executable file
·64 lines (52 loc) · 1.29 KB
/
Copy pathdensity_to_cns.py
File metadata and controls
executable file
·64 lines (52 loc) · 1.29 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
60
61
62
63
#!/usr/bin/python
import sys,os
import numpy as np
import pickle
infile = sys.argv[1]
outfile = sys.argv[2]
resolution = 2.
bin_size = 0.5
grid_data = pickle.load(open(infile))
grid_shape = grid_data.shape
A,B,C = grid_shape
an, amin, amax = A,0,A-1
bn, bmin, bmax = B,0,B-1
cn, cmin, cmax = C,0,C-1
lattice_a = A*bin_size
lattice_b = B*bin_size
lattice_c = C*bin_size
lattice_alpha = 90.0
lattice_beta = 90.0
lattice_gamma = 90.0
comment_length = 1
ofp = open(outfile,'w')
#### Head
ofp.write("\n")
ofp.write("%8d\n"%comment_length)
for i in range(comment_length):
ofp.write("REMARK \n")
ofp.write("%8d%8d%8d"%(an,amin,amax))
ofp.write("%8d%8d%8d"%(bn,bmin,bmax))
ofp.write("%8d%8d%8d"%(cn,cmin,cmax))
ofp.write("\n")
ofp.write(" %8.5E %8.5E %8.5E"%(lattice_a,lattice_b,lattice_c))
ofp.write(" %8.5E %8.5E %8.5E"%(lattice_alpha,lattice_beta,lattice_gamma))
ofp.write("\n")
ofp.write("ZYX\n")
#### Body
for i in range(cn):
ofp.write("%8d\n"%(i+cmin))
s = grid_data[::,::,i].flatten()
tmp_i = 0
for num in s :
ofp.write( "%12.5E"%num )
tmp_i += 1
if tmp_i % 6 == 0 :
ofp.write("\n")
if tmp_i % 6 != 0 :
ofp.write("\n")
#### Tail
ofp.write("%8d\n"%-9999)
ofp.write(" 0.0000E+00 0.1000E+01\n")
ofp.close()
print "Done."