-
Notifications
You must be signed in to change notification settings - Fork 0
/
5.bin.py
62 lines (41 loc) · 921 Bytes
/
5.bin.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
import numpy as np
import statistics
import glob
import os
bin_size=##bin_size##
arr = os.listdir()
name_bin='bin_'+str(bin_size)
try:
os.mkdir(name_bin)
except FileExistsError:
pass
for rdf in arr:
num_rdf=rdf[3:].split('.')[0]
ver_rdf=rdf[0:3]
name_rdf_bin='bin_'+str(bin_size)+'/rdf'+str(num_rdf)+'_bin'+str(bin_size)+'.dat'
if ver_rdf == 'rdf':
rdf_bin=open(name_rdf_bin, 'w+')
rdf_x=np.loadtxt(rdf)[:, 0]
rdf_y=np.loadtxt(rdf)[:, 1]
list_x=[]
list_y=[]
i=0
b=1
# loop for lines of pfm
while i < len(rdf_x):
if b == bin_size:
list_x.append(rdf_x[i])
list_y.append(rdf_y[i])
new_x=statistics.mean(list_x)
new_y=statistics.mean(list_y)
rdf_bin.write(f"{new_x}\t{round(new_y,10)}\n")
list_x=[]
list_y=[]
b=1
#i-=bin_size-1
else:
list_x.append(rdf_x[i])
list_y.append(rdf_y[i])
b+=1
i+=1
rdf_bin.close()