|
| 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 | + |
0 commit comments