Skip to content

Commit 55f080d

Browse files
committed
bruteforce
1 parent 57153af commit 55f080d

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

nintan/markbruteforce.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import utils_concore
2+
import numpy as np
3+
import matplotlib.pyplot as plt
4+
import concore
5+
6+
FREQ_BINS = 25
7+
8+
def brute_freqs(filename):
9+
y, yextra2, yextra3 = utils_concore.read_trellis_data([filename+'.nf3'],channums=[1,2,3,4])
10+
plt.figure()
11+
plt.subplot(411)
12+
plt.plot(range(len(y[0])),y[0])
13+
#plt.xlabel('Gastric 1')
14+
plt.subplot(412)
15+
plt.plot(range(len(y[1])),y[1])
16+
#plt.xlabel('Gastric 2')
17+
plt.subplot(413)
18+
plt.plot(range(len(y[2])),y[2])
19+
#plt.xlabel('Gastric 3')
20+
plt.subplot(414)
21+
plt.plot(range(len(y[3])),y[3])
22+
plt.xlabel('Raw file:'+filename+ ' iteration '+str(concore.simtime))
23+
plt.savefig(filename+str(concore.simtime)+"r.pdf")
24+
25+
result = []
26+
plt.figure()
27+
plt.subplot(411)
28+
result.append(smooth_freq(y,0,FREQ_BINS))
29+
plt.subplot(412)
30+
result.append(smooth_freq(y,1,FREQ_BINS))
31+
plt.subplot(413)
32+
result.append(smooth_freq(y,2,FREQ_BINS))
33+
plt.subplot(414)
34+
result.append(smooth_freq(y,3,FREQ_BINS))
35+
plt.xlabel('Freq:'+filename+ ' iteration '+str(concore.simtime))
36+
plt.savefig(filename+str(concore.simtime)+"f.pdf")
37+
#plt.show()
38+
return result
39+
40+
def smooth_freq(y,chan,bins):
41+
f=np.fft.fft(y[chan])
42+
f0=np.abs(f[-(bins-1):-1])
43+
f1=np.abs(f[-bins:-2])
44+
f2=np.abs(f[-(bins+1):-3])
45+
fa=f2+2*f1+f2
46+
# plt.plot(np.arange(bins,2,-1),np.log(np.abs(fa)))
47+
return bins-np.argmax((np.abs(fa)))
48+
49+

nintan/smoothfreq.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import numpy as np
2+
3+
def smooth_freq(y,bins):
4+
f=np.fft.fft(y)
5+
f0=np.abs(f[-(bins-1):-1])
6+
f1=np.abs(f[-bins:-2])
7+
f2=np.abs(f[-(bins+1):-3])
8+
fa=f2+2*f1+f2
9+
return bins-np.argmax((np.abs(fa)))
10+
11+
def dom_freq(y,t):
12+
ttot = (t[-1] - t[0]) * len(y)/(len(y)-1)
13+
f = np.fft.fft(y)
14+
fi = np.argmax((np.abs(f)))
15+
return np.fft.fftfreq(len(y))[fi]*len(y)/ttot

0 commit comments

Comments
 (0)