-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhistograma_step.py
81 lines (54 loc) · 1.78 KB
/
histograma_step.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
import matplotlib.pyplot as plt
def his(timestep,thermo,np):
step = timestep/thermo
x = []
y = []
z = []
f = open("posicion6.xyz","r")
mylines = []
for line in f:
mylines.append(line)
#print(mylines[1][17:])
#print('Atoms. Timestep: {}'.format(timestep))
#print(mylines[int(1 + (np+2)*i)][17:19])
init = 3 + np*step
ev = np + init
i = init
k = 0
while k < 3: # this loop selects a k-column
#print(mylines[i].split()[1])
while i < ev:
#print(mylines[int(i)][0])
if (mylines[int(i)][0]) == '2':
if k == 0:
x.append(float(mylines[int(i)].split()[1]))
elif k == 1:
y.append(float(mylines[int(i)].split()[2]))
elif k == 2:
z.append(float(mylines[int(i)].split()[3]))
i = i + 1
i = init
k = k + 1
#print(x[0:100])
#print(len(x))
#print(len(x))
#print(len(y))
#print(len(z))
#y_dict_x = {k:x.count(k) for k in x}
#my_dict_y = {k:y.count(k) for k in y}
#my_dict_z = {k:z.count(k) for k in z}
plt.figure(figsize=(8,5))
plt.hist(x,40,label='x')
plt.hist(y,40,label = 'y')
plt.hist(z,40,label = 'z')
plt.xlabel('Posiciones')
plt.legend(loc="upper left")
#plt.bar(my_dict_x.keys(),my_dict_x.values(),width = 0.1)
#plt.subplot(132)
#plt.bar(my_dict_y.keys(),my_dict_y.values())
#plt.subplot(133)
#plt.bar(my_dict_z.keys(),my_dict_z.values())
plt.grid(True)
plt.title('Histograma,step:{}'.format(timestep))
plt.show()
his(17000,100,11264)