-
Notifications
You must be signed in to change notification settings - Fork 0
/
stat_kura2.py
executable file
·183 lines (155 loc) · 7.24 KB
/
stat_kura2.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/usr/bin/env python3
import sys, os, numpy as np
import matplotlib as mpl
mpl.use('Agg')
from matplotlib import pyplot as plt
from scrapfilm import boundary
vboundary=np.vectorize(boundary)
mode = sys.argv[1]
path = './stat_kura/'
if not os.path.isdir(path):
os.mkdir(path)
if "--frames" in sys.argv:
frames_arg = sys.argv.index('--frames') + 1
if sys.argv[frames_arg]=='count':
filename_fi = 'fi.row_0_'+mode+'.npy'
print('Inspecting '+ filename_fi +' ...')
print('(oscillators, timesteps)')
print(np.load(filename_fi).shape)
raise SystemExit
try:
start, end, jump = [ int(x) for x in sys.argv[frames_arg].split(':') ]
if not os.path.isdir(path+'movie'):
os.mkdir(path+'movie')
except IndexError and ValueError:
print("--frames needs integers of the form start:end:jump ")
raise SystemExit
if "--line" in sys.argv:
line_arg = sys.argv.index('--line') + 1
line = int(sys.argv[line_arg])
print('Analyzing just line %i' % line )
# raise SystemExit
filename_k = 'kura.row_'+str(line)+'_'+mode+'.npy'
filename_fi = 'fi.row_'+str(line)+'_'+mode+'.npy'
filename_dfi = 'dfi.row_'+str(line)+'_'+mode+'.npy'
all_kura = np.load(filename_k)
all_fi = np.load(filename_fi)
all_dfi = np.load(filename_dfi)
order = np.absolute(all_kura)
psi = np.angle(all_kura)
red = np.linspace(255,0,all_dfi.shape[1])/255
green = np.linspace(0,255,all_dfi.shape[1])/255
blue = np.linspace(0,0,all_dfi.shape[1])/255
dms = np.mean( np.abs( vboundary(all_dfi, 2*np.pi) ),axis=0)**2
dsm = np.mean( vboundary( all_dfi, 2*np.pi )**2,axis=0)
sqrt_dsm = (dsm**.5)/np.pi
# s1=np.linspace(0,1,10)
# s2=np.linspace(1,1,10)
# for chain in range(all_dfi.shape[1]):
# plt.plot(boundary(all_dfi[0,chain,:],2*np.pi)/np.pi,color=(red[chain],green[chain],blue[chain]))
# plt.plot(all_dfi[0,chain,:],'b')#,color=(red[chain],green[chain],blue[chain]))
# plt.plot(s1,chain*s2,linewidth=10,color=(red[chain],green[chain],blue[chain])) #plt.plot(dms , 'b', linewidth=3)
# plt.plot(dsm , 'g', linewidth=3)
# plt.plot(dsm - dms , 'k', linewidth=3)
plt.plot(sqrt_dsm , linewidth=2)
plt.savefig(path+'root_mean_square_'+mode+'_row_'+str(line)+'.png',format='png')
print(order.shape)
fig, ax = plt.subplots(1,1)
# ax.plot(np.linspace(0,401, len(order) ), order, label='fila '+str(line))
ax.plot( order, label='fila '+str(line))
plt.legend()
fig.savefig(path+'order_'+mode+'_row_'+str(line)+'.png',format='png')
# plt.show()
# mean_rows = np.mean( order, axis=1)
# std_rows = np.std( order, axis=1)
# mean_kura = np.mean(mean_rows)
# with open(path+'kura_results_'+mode, 'w') as f:
# for l in range(mean_rows.size):
# f.write(str(l)+': '+str(mean_rows[l])+' '+str( std_rows[l])+'\n' )
# f.write('all: '+str(mean_kura)+' '+str(np.std(mean_rows))+'\n' )
# dsm = np.mean( vboundary( all_dfi[:,:], 2*np.pi )**2,axis=1)
# sqrt_dsm = (dsm**.5)/np.pi
# mean_sqrtdsm = np.mean(sqrt_dsm, axis = 1)
# dsm_std = np.std(sqrt_dsm, axis = 1 )
# with open(path+'rms_results_'+mode, 'w') as f:
# for l in range(mean_sqrtdsm.size):
# f.write(str(l)+': '+str(mean_sqrtdsm[l])+' '+str( dsm_std[l])+'\n' )
# f.write('all: '+str(np.mean(mean_sqrtdsm))+' '+str(np.std(mean_sqrtdsm))+'\n' )
else:
for i in range(6): # 0 -> bottom, 60 -> top
filename_k = 'kura.row_'+str(i)+'_'+mode+'.npy'
filename_fi = 'fi.row_'+str(i)+'_'+mode+'.npy'
filename_dfi = 'dfi.row_'+str(i)+'_'+mode+'.npy'
if i==0:
dummy_k = np.load(filename_k) #all_kura[i,:]
dummy_fi = np.load(filename_fi) #all_kura[i,:]
dummy_dfi = np.load(filename_dfi) #all_kura[i,:]
all_kura = np.empty([6,dummy_k.size], dtype=complex)
matsize = [x for x in dummy_fi.shape]; fisize=[6]
fisize.extend(matsize)
all_fi = np.empty(fisize)
all_dfi = np.empty(fisize)
#print(all_kura.shape)
#print(dummy[0:10])
all_kura[i,:] = np.load(filename_k)
all_fi[i,:,:] = np.load(filename_fi)
all_dfi[i,:,:] = np.load(filename_dfi)
order = np.absolute(all_kura)
psi = np.angle(all_kura)
red = np.linspace(255,0,all_dfi.shape[1])/255
green = np.linspace(0,255,all_dfi.shape[1])/255
blue = np.linspace(0,0,all_dfi.shape[1])/255
for row in range(6):
dms = np.mean( np.abs( vboundary(all_dfi[row,:,:], 2*np.pi) ),axis=0)**2
dsm = np.mean( vboundary( all_dfi[row,:,:], 2*np.pi )**2,axis=0)
sqrt_dsm = (dsm**.5)/np.pi
# s1=np.linspace(0,1,10)
# s2=np.linspace(1,1,10)
# for chain in range(all_dfi.shape[1]):
# plt.plot(boundary(all_dfi[0,chain,:],2*np.pi)/np.pi,color=(red[chain],green[chain],blue[chain]))
# plt.plot(all_dfi[0,chain,:],'b')#,color=(red[chain],green[chain],blue[chain]))
# plt.plot(s1,chain*s2,linewidth=10,color=(red[chain],green[chain],blue[chain])) #plt.plot(dms , 'b', linewidth=3)
# plt.plot(dsm , 'g', linewidth=3)
# plt.plot(dsm - dms , 'k', linewidth=3)
plt.plot(sqrt_dsm , linewidth=2)
plt.savefig(path+'root_mean_square_'+mode+'.png',format='png')
#plt.show()
if "--frames" in sys.argv:
fase=0
for time in range(start,end,jump):#range(1):#
fig, ax = plt.subplots(2,3,subplot_kw=dict(projection='polar'))
for row in range(3):
for chain in range(all_fi.shape[1]):
#ax.plot( np.cos(s), np.sin(s),'b')
for ud in range(2):
place=row+3*ud
ax[ud,row].set_aspect('equal')
ax[ud,row].plot(all_fi[place,chain,time]+fase,1,
marker='^', color='r', markersize=10 )
fig.suptitle('frame '+str(time), fontsize=14, fontweight='bold',
color='red')
fig.tight_layout()
fig.savefig(path+'movie/frame_'+str(time)+'.png',format='png')
plt.close(fig)
plt.clf()
fig, ax = plt.subplots(1,1)
for row in range(order.shape[0]):
ax.plot(order[row,:], label='fila '+str(row))
plt.legend()
fig.savefig(path+'order_'+mode+'.png',format='png')
#plt.show()
mean_rows = np.mean( order, axis=1)
std_rows = np.std( order, axis=1)
mean_kura = np.mean(mean_rows)
with open(path+'kura_results_'+mode, 'w') as f:
for l in range(mean_rows.size):
f.write(str(l)+': '+str(mean_rows[l])+' '+str( std_rows[l])+'\n' )
f.write('all: '+str(mean_kura)+' '+str(np.std(mean_rows))+'\n' )
dsm = np.mean( vboundary( all_dfi[:,:,:], 2*np.pi )**2,axis=1)
sqrt_dsm = (dsm**.5)/np.pi
mean_sqrtdsm = np.mean(sqrt_dsm, axis = 1)
dsm_std = np.std(sqrt_dsm, axis = 1 )
with open(path+'rms_results_'+mode, 'w') as f:
for l in range(mean_sqrtdsm.size):
f.write(str(l)+': '+str(mean_sqrtdsm[l])+' '+str( dsm_std[l])+'\n' )
f.write('all: '+str(np.mean(mean_sqrtdsm))+' '+str(np.std(mean_sqrtdsm))+'\n' )