mirror of
https://github.com/romanz/amodem.git
synced 2026-04-20 04:56:25 +08:00
Fix detect.
This commit is contained in:
12
recv.py
12
recv.py
@@ -27,7 +27,7 @@ def coherence(x, freq):
|
|||||||
Hc = exp_iwt(-freq, n) / np.sqrt(0.5*n)
|
Hc = exp_iwt(-freq, n) / np.sqrt(0.5*n)
|
||||||
return np.dot(Hc, x) / norm(x)
|
return np.dot(Hc, x) / norm(x)
|
||||||
|
|
||||||
def detect(freq):
|
def detect(x, freq):
|
||||||
counter = 0
|
counter = 0
|
||||||
for offset, coeff in iterate(x, Nsym, advance=Nsym, func=lambda x: coherence(x, Fc)):
|
for offset, coeff in iterate(x, Nsym, advance=Nsym, func=lambda x: coherence(x, Fc)):
|
||||||
if abs(coeff) > COHERENCE_THRESHOLD:
|
if abs(coeff) > COHERENCE_THRESHOLD:
|
||||||
@@ -126,10 +126,11 @@ def constellation(y):
|
|||||||
pylab.plot(np.arange(len(y)) * Tsym, y.real, '.')
|
pylab.plot(np.arange(len(y)) * Tsym, y.real, '.')
|
||||||
pylab.grid('on')
|
pylab.grid('on')
|
||||||
|
|
||||||
def main(t, x):
|
def main(fname):
|
||||||
|
|
||||||
x = (x - np.mean(x))
|
_, x = load(fname)
|
||||||
result = detect(Fc)
|
x = x - np.mean(x)
|
||||||
|
result = detect(x, Fc)
|
||||||
if result is None:
|
if result is None:
|
||||||
log.info('No carrier detected')
|
log.info('No carrier detected')
|
||||||
return
|
return
|
||||||
@@ -161,6 +162,5 @@ def main(t, x):
|
|||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
t, x = load('rx.int16')
|
main('rx.int16')
|
||||||
main(t, x)
|
|
||||||
pylab.show()
|
pylab.show()
|
||||||
|
|||||||
Reference in New Issue
Block a user