Skip to content

Commit 36493c0

Browse files
committed
dom_freq in pacq
1 parent 55f080d commit 36493c0

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

nintan/pacq.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ def extract(amplifierData):
4141
#time.sleep(0.5/len(amplifierData)) #make extract really slow for testing
4242
return s/len(amplifierData)
4343

44+
def smooth_freq(y,bins):
45+
f=np.fft.fft(y)
46+
f0=np.abs(f[-(bins-1):-1])
47+
f1=np.abs(f[-bins:-2])
48+
f2=np.abs(f[-(bins+1):-3])
49+
fa=f2+2*f1+f2
50+
return bins-np.argmax((np.abs(fa)))
51+
52+
def dom_freq(y,t):
53+
ttot = (t[-1] - t[0]) * len(y)/(len(y)-1)
54+
f = np.fft.fft(y)
55+
fi = np.argmax((np.abs(f)))
56+
return np.fft.fftfreq(len(y))[fi]*len(y)/ttot
57+
4458
def readUint32(array, arrayIndex):
4559
variableBytes = array[arrayIndex : arrayIndex + 4]
4660
variable = int.from_bytes(variableBytes, byteorder='little', signed=False)

0 commit comments

Comments
 (0)