コード例 #1
0
 def test_007_constellation_type(self):
     dm = symbolmapping.SymbolMapping(4, "BORonka")
     self.assertEqual(dm.constellationType(), "BORONKA")
     dm = symbolmapping.SymbolMapping(4, "carson")
     self.assertEqual(dm.constellationType(), "CARSON")
     dm = symbolmapping.SymbolMapping(2, "carson")
     self.assertEqual(dm.constellationType(), "GRAY")
コード例 #2
0
 def test_003_constellation_set(self):
     dm = symbolmapping.SymbolMapping(1)
     orders = np.array([1, 2, 4, 6])
     for co in orders:
         dm.setConstellationOrder(co)
         c, b = generate_constellation(co)
         self.assertVectorAlmostEqual(c, dm.constellation())
コード例 #3
0
 def test_001_constellation_ref(self):
     orders = np.array([1, 2, 4, 6])
     for co in self._orders:
         dm = symbolmapping.SymbolMapping(co)
         c, b = generate_constellation(co)
         self.assertVectorAlmostEqual(c, dm.constellation())
         self.assertEqual(dm.constellationOrder(), co)
コード例 #4
0
    def test_006_llr_calculation(self):
        for co in self._orders:
            dm = symbolmapping.SymbolMapping(co)
            bits = np.random.randint(0, 2, co * 5).astype(np.uint8)
            symbols = dm.map_to_constellation(bits)

            llrs_d = dm.demap_llrs(symbols, float(3.0))

            if co in (1, 3) or co > 6:
                rb = np.sign(llrs_d) - 1.
                rb /= -2.
                rb = rb.astype(np.uint8)
                np.testing.assert_array_equal(bits, rb)
                continue

            ref_ln_probs = calculate_symbol_log_probabilities(
                symbols, dm.constellation(), float(3.0))

            ref_llrs = calculate_llrs(ref_ln_probs) * .5

            if co > 3:
                rb = np.sign(llrs_d) - 1.
                rb /= -2.
                rb = rb.astype(np.uint8)
                self.assertTrue(np.all(np.sign(ref_llrs) == np.sign(llrs_d)))
            else:
                self.assertTrue(
                    np.all(np.abs(ref_llrs - llrs_d) < self._precision))
コード例 #5
0
    def test_004_mapping(self):
        for co in self._orders:
            dm = symbolmapping.SymbolMapping(co)
            bits = np.random.randint(0, 2, co * 500).astype(np.uint8)

            ref_syms = map_to_constellation(bits, dm.constellation())
            uut_syms = dm.map_to_constellation(bits)
            self.assertVectorAlmostEqual(uut_syms, ref_syms)
コード例 #6
0
 def test_005_ln_prob_calculation(self):
     snr_db = float(3.0)
     for co in self._orders:
         dm = symbolmapping.SymbolMapping(co)
         bits = np.random.randint(0, 2, co * 500).astype(np.uint8)
         symbols = dm.map_to_constellation(bits)
         ln_probs = dm.calculate_ln_probabilities(symbols, snr_db)
         ref_ln_probs = calculate_symbol_log_probabilities(
             symbols, dm.constellation(), snr_db).flatten()
         self.assertFloatTuplesAlmostEqual(ref_ln_probs * .5, ln_probs, 4)
コード例 #7
0
    def test_006_llr_calculation(self):
        for co in (2, 4, 6):
            dm = symbolmapping.SymbolMapping(co)
            bits = np.random.randint(0, 2, co * 5).astype(np.uint8)
            symbols = dm.map_to_constellation(bits)

            ref_ln_probs = calculate_symbol_log_probabilities(
                symbols, dm.constellation(), float(3.0))
            ref_llrs = calculate_llrs(ref_ln_probs) * .5

            llrs_d = dm.demap_llrs(symbols, float(3.0))
            if co > 3:
                self.assertTrue(np.all(np.sign(ref_llrs) == np.sign(llrs_d)))
            else:
                self.assertTrue(
                    np.all(np.abs(ref_llrs - llrs_d) < self._precision))
コード例 #8
0
 def test_009_constellation_carson(self):
     dm = symbolmapping.SymbolMapping(4, "carSon")
     self.assertEqual(dm.constellationType(), "CARSON")
     res = dm.constellation()
     ref, bins = generate_constellation(4, 'cArSoN')
     self.assertTrue(np.all(np.abs(res - ref) < 1e-7))
コード例 #9
0
 def test_008_constellation_boronka(self):
     dm = symbolmapping.SymbolMapping(4, "BORonka")
     self.assertEqual(dm.constellationType(), "BORONKA")
     res = dm.constellation()
     ref, bins = generate_constellation(4, 'BoRoNkA')
     self.assertTrue(np.all(np.abs(res - ref) < 1e-7))