def test_complex_to_arg(self): src_data = (1+2j, 3-4j, 5+6j, 7-8j, -9+10j) expected_data = (atan2(2, 1), atan2(-4,3), atan2(6, 5), atan2(-8, 7), atan2(10,-9)) src = blocks.vector_source_c(src_data) op = blocks.complex_to_arg() dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data(), 2)
def test_complex_to_arg(self): src_data = (1 + 2j, 3 - 4j, 5 + 6j, 7 - 8j, -9 + 10j) expected_data = (atan2(2, 1), atan2(-4, 3), atan2(6, 5), atan2(-8, 7), atan2(10, -9)) src = blocks.vector_source_c(src_data) op = blocks.complex_to_arg() dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data(), 2)
def do_check_phase_shift(self, type, name): sps = 2 L = 1 in_bits = (1,) * 20 src = blocks.vector_source_b(in_bits, False) cpm = digital.cpmmod_bc(type, 0.5, sps, L) arg = blocks.complex_to_arg() sink = blocks.vector_sink_f() self.tb.connect(src, cpm, arg, sink) self.tb.run() symbol_phases = numpy.array(sink.data()[sps*L-1::sps]) phase_diff = numpy.mod(numpy.subtract(symbol_phases[1:], symbol_phases[:-1]), (2*numpy.pi,) * (len(symbol_phases)-1)) self.assertFloatTuplesAlmostEqual(tuple(phase_diff), (0.5 * numpy.pi,) * len(phase_diff), 5, msg="Phase shift was not correct for CPM method " + name)
def test_001_lgmsk(self): sps = 2 L = 5 bt = 0.3 in_bits = (1,) * 20 src = blocks.vector_source_b(in_bits, False) gmsk = digital.gmskmod_bc(sps, L, bt) arg = blocks.complex_to_arg() sink = blocks.vector_sink_f() self.tb.connect(src, gmsk, arg, sink) self.tb.run() symbol_phases = numpy.array(sink.data()[sps*L-1::sps]) phase_diff = numpy.mod(numpy.subtract(symbol_phases[1:], symbol_phases[:-1]), (2*numpy.pi,) * (len(symbol_phases)-1)) self.assertFloatTuplesAlmostEqual(tuple(phase_diff), (0.5 * numpy.pi,) * len(phase_diff), 5, msg="Phase shift was not correct for GMSK")
def do_check_phase_shift(self, type, name): sps = 2 L = 1 in_bits = (1, ) * 20 src = blocks.vector_source_b(in_bits, False) cpm = digital.cpmmod_bc(type, 0.5, sps, L) arg = blocks.complex_to_arg() sink = blocks.vector_sink_f() self.tb.connect(src, cpm, arg, sink) self.tb.run() symbol_phases = numpy.array(sink.data()[sps * L - 1::sps]) phase_diff = numpy.mod( numpy.subtract(symbol_phases[1:], symbol_phases[:-1]), (2 * numpy.pi, ) * (len(symbol_phases) - 1)) self.assertFloatTuplesAlmostEqual( tuple(phase_diff), (0.5 * numpy.pi, ) * len(phase_diff), 5, msg="Phase shift was not correct for CPM method " + name)
def test_001_lgmsk(self): sps = 2 L = 5 bt = 0.3 in_bits = (1, ) * 20 src = blocks.vector_source_b(in_bits, False) gmsk = digital.gmskmod_bc(sps, L, bt) arg = blocks.complex_to_arg() sink = blocks.vector_sink_f() self.tb.connect(src, gmsk, arg, sink) self.tb.run() symbol_phases = numpy.array(sink.data()[sps * L - 1::sps]) phase_diff = numpy.mod( numpy.subtract(symbol_phases[1:], symbol_phases[:-1]), (2 * numpy.pi, ) * (len(symbol_phases) - 1)) self.assertFloatTuplesAlmostEqual( tuple(phase_diff), (0.5 * numpy.pi, ) * len(phase_diff), 5, msg="Phase shift was not correct for GMSK")