def test_002_per_subcarrier(self): # set up fg n_frames = self.n_frames active_subcarriers = 110 subcarriers = 128 timeslots = 205 smap = np.arange(active_subcarriers) + (subcarriers - active_subcarriers) // 2 data = get_random_qpsk(active_subcarriers * timeslots) ref = map_to_waveform_resources(data, active_subcarriers, subcarriers, smap, False) for i in range(n_frames - 1): d = get_random_qpsk(active_subcarriers * timeslots) data = np.concatenate((data, d)) ref = np.concatenate( (ref, map_to_waveform_resources(d, active_subcarriers, subcarriers, smap, False))) src = blocks.vector_source_c(data) mapper = gfdm.resource_mapper_cc(timeslots, subcarriers, active_subcarriers, smap, False) snk = blocks.vector_sink_c() self.tb.connect(src, mapper, snk) self.tb.run() # check data res = snk.data() self.assertComplexTuplesAlmostEqual(ref, res)
def test_001_t(self): np.set_printoptions(precision=2) n_frames = 3 alpha = .5 active = 8 M = 8 K = 16 L = 2 cp_len = 8 cs_len = 4 ramp_len = 4 block_len = M * K window_len = get_window_len(cp_len, M, K, cs_len) taps = get_frequency_domain_filter('rrc', alpha, M, K, L) taps /= np.sqrt(calculate_signal_energy(taps) / M) window_taps = get_raised_cosine_ramp(ramp_len, window_len) pn_symbols = get_random_qpsk(K) H_preamble = get_frequency_domain_filter('rrc', alpha, 2, K, L) preamble = get_sync_symbol(pn_symbols, H_preamble, K, L, cp_len, ramp_len)[0] smap = get_subcarrier_map(K, active, dc_free=True) ref = np.array([], dtype=complex) data = np.array([], dtype=complex) frame_len = window_len + len(preamble) frame_gap = np.zeros(frame_len) for i in range(n_frames): d = get_random_qpsk(active * M) dd = map_to_waveform_resources(d, active, K, smap) D = get_data_matrix(dd, K, group_by_subcarrier=False) b = gfdm_modulate_block(D, taps, M, K, L, False) b = add_cyclic_starfix(b, cp_len, cs_len) b = pinch_block(b, window_taps) ref = np.concatenate((ref, frame_gap, preamble, b)) data = np.concatenate((data, d)) src = blocks.vector_source_c(data) mapper = gfdm.resource_mapper_cc(active, K, M, smap, True) mod = gfdm.simple_modulator_cc(M, K, L, taps) prefixer = gfdm.cyclic_prefixer_cc(block_len, cp_len, cs_len, ramp_len, window_taps) preambler = blocks.vector_insert_c(preamble, window_len + len(preamble), 0) gapper = blocks.vector_insert_c(frame_gap, frame_len + len(frame_gap), 0) dst = blocks.vector_sink_c() self.tb.connect(src, mapper, mod, prefixer, preambler, gapper, dst) # self.tb.connect(src, mapper, dst) self.tb.run() res = np.array(dst.data())[0:len(ref)] self.assertComplexTuplesAlmostEqual(ref, res, 5)
def test_004_active_subcarriers(self): n_frames = 1 timeslots = 9 subcarriers = 32 active_subcarriers = 20 overlap = 2 ic_iterations = 64 f_taps = filters.get_frequency_domain_filter("rrc", 0.5, timeslots, subcarriers, overlap) gfdm_constellation = digital.constellation_qpsk().base() print(gfdm_constellation.points()) subcarrier_map = get_subcarrier_map(subcarriers, active_subcarriers) data = get_random_qpsk(n_frames * timeslots * active_subcarriers) data *= 2.0 src = blocks.vector_source_c(data) mapper = gfdm.resource_mapper_cc(timeslots, subcarriers, active_subcarriers, subcarrier_map, True) mod = gfdm.simple_modulator_cc(timeslots, subcarriers, overlap, f_taps) demod = gfdm.advanced_receiver_sb_cc( timeslots, subcarriers, overlap, ic_iterations, f_taps, gfdm_constellation, subcarrier_map, 0, ) demod.set_ic(64) demapper = gfdm.resource_demapper_cc(timeslots, subcarriers, active_subcarriers, subcarrier_map, True) snk = blocks.vector_sink_c() self.tb.connect(src, mapper, mod, demod, demapper, snk) self.tb.run() res = np.array(snk.data()) print(data[0:10]) print(res[0:10]) self.assertComplexTuplesAlmostEqual(data, res, 1)
def test_002_subcarrier_first(self): timeslots = 9 subcarriers = 32 active_subcarriers = 20 subcarrier_map = get_subcarrier_map(subcarriers, active_subcarriers) data = get_random_qpsk(10 * timeslots * active_subcarriers) src = blocks.vector_source_c(data) mapper = gfdm.resource_mapper_cc(timeslots, subcarriers, active_subcarriers, subcarrier_map, False) demapper = gfdm.resource_demapper_cc(timeslots, subcarriers, active_subcarriers, subcarrier_map, False) snk = blocks.vector_sink_c() self.tb.connect(src, mapper, demapper, snk) self.tb.run() # check data res = np.array(snk.data()) self.assertComplexTuplesAlmostEqual(data, res)