Exemplo n.º 1
0
def run_gfsk_simulation(snr):
    u = np.random.randint(2, size=chunkSize)
    s = gfsk.modulate(u)
    w = channel.noise.awgn(len(s), snr=snr)
    r = s+w
    hat_U = gfsk.demodulate(r)
    wrong, n = common.count_symbol_errors(u, hat_U)
    return wrong, n
Exemplo n.º 2
0
    def feed_data(self, data, snr) -> None:
        symbols = self.symbolenc.encode_msb(data)
        moded = self.modulator.modulate(symbols)

        received = moded + channel.awgn(len(moded), snr)

        symbols_hat = self.modulator.demodulate(received)
        data_hat = self.symbolenc.decode_msb(symbols_hat)

        self.bit_stats += np.array(
            common.count_symbol_errors(symbols, symbols_hat))
        self.sym_stats += np.array(common.count_bit_errors(data, data_hat))
Exemplo n.º 3
0
    def test(self):
        data = np.arange(100) * 23
        data_before = np.copy(data)

        data[0] = 23
        data[23] = 12
        data[3] = 12
        data[99] = 12

        faults, total = common.count_symbol_errors(data, data_before)
        self.assertEqual(total, 100)
        self.assertEqual(faults, 4)
    branch_snrs = []
    for i, gamma in enumerate(snr_todo):
        # create channel with the curretn branch and snr
        ch = channel.RayleighAWGNChannel(N=branch, snr=gamma)
        errors = 0
        numberOfBits = 0

        for k in range(max_tries):
            fram = make_frame_array()
            for slot in fram:
                signal = gfsk.modulate(slot)
                recieved, h = ch.run(signal)
                hat_recieved, _ = diversity_technique.selection_from_power(
                    recieved)
                hat_slot = gfsk.demodulate(hat_recieved)
                err, n = common.count_symbol_errors(slot, hat_slot)
                errors += err
                numberOfBits += n
            ch.frame_sent()

            if errors >= cfg.stop_at_errors:
                print(f"Stopping early at {k} runs")
                break

        ber = errors / numberOfBits
        print('snr', gamma, 'branch', branch, 'Prob:', ber)

        snrs[j][i] = gamma
        probs[j][i] = ber

        # Stop when below give_up_value