How to use the amodem.dsp.norm function in amodem

To help you get started, we’ve selected a few amodem examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github romanz / amodem / tests / test_equalizer.py View on Github external
def assert_approx(x, y, e=1e-12):
    x = x.flatten()
    y = y.flatten()
    assert dsp.norm(x - y) < e * dsp.norm(x)
github romanz / amodem / amodem / detect.py View on Github external
def find_start(self, buf):
        carrier = dsp.exp_iwt(self.omega, self.Nsym)
        carrier = np.tile(carrier, self.START_PATTERN_LENGTH)
        zeroes = carrier * 0.0
        signal = np.concatenate([zeroes, carrier])
        signal = (2 ** 0.5) * signal / dsp.norm(signal)

        corr = np.abs(np.correlate(buf, signal))
        norm_b = np.sqrt(np.correlate(np.abs(buf)**2, np.ones(len(signal))))
        coeffs = np.zeros_like(corr)
        coeffs[norm_b > 0.0] = corr[norm_b > 0.0] / norm_b[norm_b > 0.0]

        index = np.argmax(coeffs)
        log.info('Carrier coherence: %.3f%%', coeffs[index] * 100)
        offset = index + len(zeroes)
        return offset