def report_carrier(bufs, begin): x = np.concatenate(tuple(bufs)[-CARRIER_THRESHOLD:-1]) Hc = sigproc.exp_iwt(-config.Fc, len(x)) Zc = np.dot(Hc, x) / (0.5*len(x)) amp = abs(Zc) log.info('Carrier detected at ~%.1f ms @ %.1f kHz:' ' coherence=%.3f%%, amplitude=%.3f', begin * config.Tsym * 1e3 / config.Nsym, config.Fc / 1e3, np.abs(sigproc.coherence(x, config.Fc)) * 100, amp) return amp
def find_start(buf, length): Hc = sigproc.exp_iwt(config.Fc, len(buf)) P = np.abs(Hc.conj() * buf) ** 2 cumsumP = P.cumsum() return np.argmax(cumsumP[length:] - cumsumP[:-length])