def notest_debug(self): src = blocks.vector_source_c(range(100), False, 1, []) separator = inspector_test.signal_separator_c(32000, firdes.WIN_HAMMING, 0.1, 100) msg = pmt.make_vector(1, pmt.PMT_NIL) flanks = pmt.make_f32vector(2, 0.0) pmt.f32vector_set(flanks, 0, 12500) pmt.f32vector_set(flanks, 1, 20) pmt.vector_set(msg, 0, flanks) msg_src = blocks.message_strobe(msg, 100)
def test_001_t(self): src = blocks.vector_source_c(list(range(10000)), False, 1, []) separator = inspector_test.signal_separator_c( 32000, firdes.WIN_HAMMING, 0.1, 100, False, inspector_test.map_float_vector({0.0: [0.0]})) vec_sink = blocks.vector_sink_c(1) ext = inspector_test.signal_extractor_c(0) snk = blocks.vector_sink_c(1) # pack message msg = pmt.make_vector(1, pmt.PMT_NIL) flanks = pmt.make_f32vector(2, 0.0) pmt.f32vector_set(flanks, 0, 12500) pmt.f32vector_set(flanks, 1, 20) pmt.vector_set(msg, 0, flanks) msg_src = blocks.message_strobe(msg, 100) taps = filter.firdes.low_pass(1, 32000, 500, 50, firdes.WIN_HAMMING, 6.76) self.tb.connect(src, separator) self.tb.connect(src, vec_sink) self.tb.msg_connect((msg_src, 'strobe'), (separator, 'map_in')) self.tb.msg_connect((separator, 'sig_out'), (ext, 'sig_in')) self.tb.connect(ext, snk) self.tb.start() time.sleep(0.3) self.tb.stop() self.tb.wait() data = vec_sink.data() sig = numpy.zeros(len(vec_sink.data()), dtype=complex) for i in range(len(vec_sink.data())): sig[i] = data[i] * numpy.exp( -1j * 2 * numpy.pi * 12500 * i * 1 / 32000) taps = filter.firdes.low_pass(1, 32000, 900, 90, firdes.WIN_HAMMING, 6.76) sig = numpy.convolve(sig, taps, 'full') out = numpy.empty([0]) decim = 32000 / 20 / 100 j = 0 for i in range(len(sig) / decim): out = numpy.append(out, sig[j]) j += decim data = snk.data() for i in range(min(len(out), len(data))): self.assertComplexAlmostEqual2(out[i], data[i], abs_eps=0.01)
def no_test_sebastian (self): src = blocks.vector_source_c(range(100), False, 1, []) separator = inspector_test.signal_separator_c(32000, firdes.WIN_HAMMING, 0.1, 100) # pack message msg = pmt.make_vector(1, pmt.PMT_NIL) flanks = pmt.make_f32vector(2, 0.0) pmt.f32vector_set(flanks, 0, 12490) pmt.f32vector_set(flanks, 1, 12510) pmt.vector_set(msg, 0, flanks) msg_src = blocks.message_strobe(msg, 100) self.tb.connect(src, separator) self.tb.msg_connect((msg_src, 'strobe'), (separator, 'map_in')) self.tb.run()
def test_001_t (self): src = blocks.vector_source_c(range(10000), False, 1, []) separator = inspector_test.signal_separator_c(32000, firdes.WIN_HAMMING, 0.1, 100, False, inspector_test.map_float_vector({0.0:[0.0]})) vec_sink = blocks.vector_sink_c(1) ext = inspector_test.signal_extractor_c(0) snk = blocks.vector_sink_c(1) # pack message msg = pmt.make_vector(1, pmt.PMT_NIL) flanks = pmt.make_f32vector(2, 0.0) pmt.f32vector_set(flanks, 0, 12500) pmt.f32vector_set(flanks, 1, 20) pmt.vector_set(msg, 0, flanks) msg_src = blocks.message_strobe(msg, 100) taps = filter.firdes.low_pass(1, 32000, 500, 50, firdes.WIN_HAMMING, 6.76) self.tb.connect(src, separator) self.tb.connect(src, vec_sink) self.tb.msg_connect((msg_src, 'strobe'), (separator, 'map_in')) self.tb.msg_connect((separator, 'sig_out'), (ext, 'sig_in')) self.tb.connect(ext, snk) self.tb.start() time.sleep(0.3) self.tb.stop() self.tb.wait() data = vec_sink.data() sig = numpy.zeros(len(vec_sink.data()), dtype=complex) for i in range(len(vec_sink.data())): sig[i] = data[i]*numpy.exp(-1j*2*numpy.pi*12500*i*1/32000) taps = filter.firdes.low_pass(1, 32000, 900, 90, firdes.WIN_HAMMING, 6.76) sig = numpy.convolve(sig, taps, 'full') out = numpy.empty([0]) decim = 32000/20/100 j = 0 for i in range(len(sig)/decim): out = numpy.append(out, sig[j]) j += decim data = snk.data() for i in range(min(len(out), len(data))): self.assertComplexAlmostEqual2(out[i], data[i], abs_eps=0.01)
def test_001_t (self): # set up fg src = blocks.vector_source_c(range(1024), False, 1, []) # pack message msg = pmt.make_vector(1, pmt.PMT_NIL) flanks = pmt.make_f32vector(2, 0.0) pmt.f32vector_set(flanks, 0, 12500) pmt.f32vector_set(flanks, 1, 8) pmt.vector_set(msg, 0, flanks) msg_src = blocks.message_strobe(msg, 100) separator = inspector_test.signal_separator_c(1024, firdes.WIN_HAMMING, 0.1, 1) extractor = inspector.signal_extractor_c(0) taps = firdes.low_pass(1, 1024, 2, 0.1*2, firdes.WIN_HAMMING, 6.76) reference = numpy.convolve(range(1024), taps, 'same') #xlator = filter.freq_xlating_fir_filter_ccf(160, taps, 12500, 32000) stv1 = blocks.stream_to_vector(gr.sizeof_gr_complex, 128) #stv2 = blocks.stream_to_vector(gr.sizeof_gr_complex, 128) snk1 = blocks.vector_sink_c(128) #snk2 = blocks.vector_sink_c(128) null1 = blocks.null_sink(gr.sizeof_gr_complex) # connect this self.tb.connect(src, separator) self.tb.msg_connect((msg_src, 'strobe'), (separator, 'map_in')) #self.tb.connect(src, xlator) #self.tb.connect(xlator, null1) self.tb.msg_connect((separator, 'msg_out'), (extractor, 'sig_in')) self.tb.connect(extractor, stv1) #self.tb.connect(xlator, stv2) self.tb.connect(stv1, snk1) #self.tb.connect(stv2, snk2) self.tb.start() time.sleep(0.5) self.tb.stop() # check data data1 = snk1.data() #data2 = snk2.data() data2 = reference[0::8] for i in range(min(len(data2), len(data1))): self.assertComplexAlmostEqual(data1[i], data2[i], 4)