forked from Agent-Aslan/Halo-AI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHCread.py
More file actions
228 lines (172 loc) · 6.07 KB
/
HCread.py
File metadata and controls
228 lines (172 loc) · 6.07 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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# This import registers the 3D projection, but is otherwise unused.
#from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
import matplotlib.pyplot as plt
import numpy as np
#import matplotlib.animation as animation
#import os
import sys
#import serial
#from serial.tools import list_ports
#import time
import math
import scipy.stats
#import matplotlib.gridspec as gridspec
import warnings
#from matplotlib.widgets import Button
#import tkinter as tk
#from astral import LocationInfo
#import datetime
#from astral.sun import sunrise,sunset
warnings.simplefilter('ignore')
#auto detection, common words aem clock
#with lightbox etc fine...but ALSO HERE have color coherence. Data Z trend modules too and cross cmp times. color coherence p cum trend lk over time when have code lv back or remake here
#Milti file chisq
#p cum... and full data strawberry both there here.
#readable dts
#rngs = 4
#NEDspeed = 250
#TurboUse = False
#ColorZ = 1.65
#RotZ = 1.85
outpath = 'E:/PeaceIncExperiments/Formal_Experiments/Strawberry Moon 2021'
anlzfile = sys.argv[1]
readFile = open('%s/%s'%(outpath,anlzfile),'r')
sepfile = readFile.read().split('\n')
head = sepfile[0].split(' ')
Type = head[1]
ColorZ = float(head[3])
RotZ = float(head[5])
firstline = sepfile[1].split(',')
if firstline[-1]=='T':
TurboUse = True
else:
TurboUse = False
NEDspeed = len(firstline)-2
rngs = 1
rngct = 0
while rngct==0:
line = sepfile[rngs+1]
if 'QBYTE' in line:
rngct += 1
else:
rngs += 1
if Type == 'hypercube':
infile = 'SimulationsHC.txt'
if Type == 'sphere' or Type == 'nye':
infile = 'Simulations_Sphere12.txt'
if Type=='AEM' or Type=='AEMclock':
infile = 'Simulations_AEM10.txt'
print(rngs,NEDspeed,TurboUse,ColorZ,RotZ)#next is auto input readM
ActionNumC = math.ceil((ColorZ*((8*NEDspeed*0.25)**0.5))+(4*NEDspeed))
Pmod_Color = (scipy.stats.binom((NEDspeed*8),0.5).sf(ActionNumC-1))*2
ActionNumR = math.ceil((RotZ*((8*NEDspeed*0.25)**0.5))+(4*NEDspeed))
Pmod_Rot = (scipy.stats.binom((NEDspeed*8),0.5).sf(ActionNumR-1))*2
SimMI = []
readFileM = open('%s/%s'%(outpath,infile),'r')
sepfileM = readFileM.read().split('\n')
for a in range (0,len(sepfileM)):
SimMI.append(float(sepfileM[a]))
Msorted = sorted(SimMI)
def M2P(MIv):
idx = 0
for a in range (0,len(Msorted)):
if Msorted[a]>MIv:
idx += 1
if idx==0:
idx += 1
p_i = idx/1000000
#print(idx,MIv,np.amin(Msorted),np.amax(Msorted))
return p_i
ult_t=[]
ult_sums=[]
ax1y=[]
for a in range (0,rngs+1):
ult_sums.append([])
ax1y.append([])
ax1s=[]
ax1sN=[]
MIt=[]
MIp=[]
CumP=[]
colorsave=[]
rotsave=[]
colorct=0
rotct = 0
Mplt=[]
Mstd=[]
Rplt=[]
Rstd=[]
KMlog = 0
for a in range (0,len(sepfile)):
if 'QBYTE' in sepfile[a]:#goal: get bitsums. EE can be read. hopefully retrieve code for good read_lights code. so yeah anlz dep on LV..
bitct = 0
xandy = sepfile[a].split(',')
for b in range (0,len(xandy)-2):
strnode = str(bin(256+int(xandy[b])))[3:]
bitct += int(strnode[0])+int(strnode[1])+int(strnode[2])+int(strnode[3])+int(strnode[4])+int(strnode[5])+int(strnode[6])+int(strnode[7])
ult_sums[0].append(bitct)
ult_t.append((int(xandy[-2])-1622530800000)/86400000)
for b in range (1,rngs+1):
bitct = 0
xandy = sepfile[a-b].split(',')
for c in range (0,len(xandy)-2):
strnode = str(bin(256+int(xandy[c])))[3:]
bitct += int(strnode[0])+int(strnode[1])+int(strnode[2])+int(strnode[3])+int(strnode[4])+int(strnode[5])+int(strnode[6])+int(strnode[7])
ult_sums[b].append(bitct)
colorsave.append(colorct)
rotsave.append(rotct)
if 'color' in sepfile[a]:
MIt.append(ult_t[-1])
ival = float(sepfile[a].split(',')[1])
pval = M2P(ival)
MIp.append(1/(pval))
KMlog += np.log(pval)
CumP.append(scipy.stats.chi2.sf((KMlog*-2),(2*len(MIt))))
colorct += 1
if 'rotation' in sepfile[a]:
rotct += 1
if a%10000==0:
print("processing line %d of %d"%(a,len(sepfile)))
for a in range (0,len(ult_t)):
Nt = (a-(10*colorsave[a]))-11
Mplt.append(colorsave[a] - (Pmod_Color*Nt))
Mstd.append(((Nt*Pmod_Color*(1-Pmod_Color))**0.5)*1.65)
NtR = (a-(10*rotsave[a]))-11
Rplt.append(rotsave[a] - (Pmod_Rot*NtR))
Rstd.append(((NtR*Pmod_Rot*(1-Pmod_Rot))**0.5)*1.65)
for a in range (0,len(ult_t)):
for b in range (0,len(ax1y)):
ax1y[b].append(np.sum(ult_sums[b][0:a])-((a)*NEDspeed*8*0.5))
ax1s.append((((a)*NEDspeed*8*0.25)**0.5)*1.96)
ax1sN.append((((a)*NEDspeed*8*0.25)**0.5)*-1.96)
plt.style.use('dark_background')
#plt.grid([False])
fig = plt.figure(constrained_layout=True)
#gs = fig.add_gridspec(3,2)
#ax1 = fig.add_subplot(gs[:,0], projection='3d')
ax2 = fig.add_subplot(311)
ax3 = fig.add_subplot(312)
ax4 = fig.add_subplot(313)
#Q,T,1234...,
ax2.plot(ult_t,ax1y[0],color='magenta',linewidth='1')
if TurboUse==True:
ax2.plot(ult_t,ax1y[1],color='red',linewidth='1')
for a in range (2,len(ax1y)):
ax2.plot(ult_t,ax1y[a],color='lightgray',linewidth='1')
else:
for a in range (1,len(ax1y)):
ax2.plot(ult_t,ax1y[a],color='lightgray',linewidth='1')
ax2.plot(ult_t,ax1s,color='aqua',linestyle='--')
ax2.plot(ult_t,ax1sN,color='aqua',linestyle='--')
ax3.plot(ult_t,Mplt,color='aqua')
ax3.plot(ult_t,Mstd,color='aqua',linestyle='--')
ax3.plot(ult_t,Rplt,color='red')
ax3.plot(ult_t,Rstd,color='red',linestyle='--')
ax4.plot(MIt,MIp,color='aqua')
ax4.set_ylabel('Color Coherence 1/p')
ax4.set_yscale('log')
ax4t = ax4.twinx()
ax4t.plot(MIt,CumP,color='red')
ax2.set_ylabel('Color Change')
ax3.set_ylabel('Rotation / Color Change')
plt.show()