def test_001_filter_delay_one_input(self): tb = self.tb sampling_freq = 100 ntaps = 51 N = int(ntaps + sampling_freq * 0.10) data = sin_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) src1 = blocks.vector_source_f(data) dst2 = blocks.vector_sink_c() # calculate taps taps = filter.firdes.hilbert(ntaps, filter.firdes.WIN_HAMMING) hd = filter.filter_delay_fc(taps) expected_result = fir_filter(data, taps, (ntaps-1) // 2) tb.connect(src1, hd) tb.connect(hd, dst2) tb.run() # get output result_data = dst2.data() self.assertComplexTuplesAlmostEqual(expected_result, result_data, 5)
def test_002_filter_delay_two_inputs(self): # giving the same signal to both the inputs should fetch the same results # as above tb = self.tb sampling_freq = 100 ntaps = 51 N = int(ntaps + sampling_freq * 0.10) data = sin_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) src1 = blocks.vector_source_f(data) dst2 = blocks.vector_sink_c() # calculate taps taps = filter.firdes.hilbert(ntaps, filter.firdes.WIN_HAMMING) hd = filter.filter_delay_fc(taps) expected_result = fir_filter2(data, data, taps, (ntaps-1) // 2) tb.connect(src1, (hd,0)) tb.connect(src1, (hd,1)) tb.connect(hd,dst2) tb.run() # get output result_data = dst2.data() self.assertComplexTuplesAlmostEqual(expected_result, result_data, 5)
def test_002_filter_delay_two_inputs(self): # giving the same signal to both the inputs should fetch the same results # as above tb = self.tb sampling_freq = 100 ntaps = 51 N = int(ntaps + sampling_freq * 0.10) data = sin_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) src1 = blocks.vector_source_f(data) dst2 = blocks.vector_sink_c() # calculate taps taps = filter.firdes.hilbert(ntaps, filter.firdes.WIN_HAMMING) hd = filter.filter_delay_fc(taps) expected_result = fir_filter2(data, data, taps, (ntaps-1)/2) tb.connect(src1, (hd,0)) tb.connect(src1, (hd,1)) tb.connect(hd,dst2) tb.run() # get output result_data = dst2.data() self.assertComplexTuplesAlmostEqual(expected_result, result_data, 5)
def test_003_filter_delay_two_inputs(self): # give two different inputs tb = self.tb sampling_freq = 100 ntaps = 51 N = int(ntaps + sampling_freq * 0.10) data1 = sin_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) data2 = cos_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) src1 = blocks.vector_source_f(data1) src2 = blocks.vector_source_f(data2) taps = filter.firdes.hilbert(ntaps, filter.firdes.WIN_HAMMING) hd = filter.filter_delay_fc(taps) expected_result = fir_filter2(data1, data2, taps, (ntaps-1) // 2) dst2 = blocks.vector_sink_c() tb.connect(src1, (hd,0)) tb.connect(src2, (hd,1)) tb.connect(hd, dst2) tb.run() # get output result_data = dst2.data() self.assertComplexTuplesAlmostEqual(expected_result, result_data, 5)
def test_001_filter_delay_one_input(self): tb = self.tb sampling_freq = 100 ntaps = 51 N = int(ntaps + sampling_freq * 0.10) data = sin_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) src1 = blocks.vector_source_f(data) dst2 = blocks.vector_sink_c() # calculate taps taps = filter.firdes.hilbert(ntaps, filter.firdes.WIN_HAMMING) hd = filter.filter_delay_fc(taps) expected_result = fir_filter(data, taps, (ntaps-1)/2) tb.connect(src1, hd) tb.connect(hd, dst2) tb.run() # get output result_data = dst2.data() self.assertComplexTuplesAlmostEqual(expected_result, result_data, 5)
def test_003_filter_delay_two_inputs(self): # give two different inputs tb = self.tb sampling_freq = 100 ntaps = 51 N = int(ntaps + sampling_freq * 0.10) data1 = sin_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) data2 = cos_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) src1 = blocks.vector_source_f(data1) src2 = blocks.vector_source_f(data2) taps = filter.firdes.hilbert(ntaps, filter.firdes.WIN_HAMMING) hd = filter.filter_delay_fc(taps) expected_result = fir_filter2(data1, data2, taps, (ntaps-1)/2) dst2 = blocks.vector_sink_c() tb.connect(src1, (hd,0)) tb.connect(src2, (hd,1)) tb.connect(hd, dst2) tb.run() # get output result_data = dst2.data() self.assertComplexTuplesAlmostEqual(expected_result, result_data, 5)
def test_001_filter_delay_one_input(self): # expected result expected_result = (-1.4678005338941702e-11j, -0.0011950774351134896j, -0.0019336787518113852j, -0.0034673355985432863j, -0.0036765895783901215j, -0.004916108213365078j, -0.0042778430506587029j, -0.006028641015291214j, -0.005476709920912981j, -0.0092810001224279404j, -0.0095402700826525688j, -0.016060983762145042j, -0.016446959227323532j, -0.02523401565849781j, -0.024382550269365311j, -0.035477779805660248j, -0.033021725714206696j, -0.048487484455108643j, -0.04543270543217659j, -0.069477587938308716j, -0.066984444856643677j, -0.10703597217798233j, -0.10620346665382385j, -0.1852707713842392j, -0.19357112050056458j, (7.2191945754696007e-09 - 0.50004088878631592j), (0.58778399229049683 - 0.6155126690864563j), (0.95105588436126709 - 0.12377222627401352j), (0.95105588436126709 + 0.41524654626846313j), (0.5877838134765625 + 0.91611981391906738j), (5.8516356205018383e-09 + 1.0670661926269531j), (-0.5877840518951416 + 0.87856143712997437j), (-0.95105588436126709 + 0.35447561740875244j), (-0.95105588436126709 - 0.26055556535720825j), (-0.5877838134765625 - 0.77606213092803955j), (-8.7774534307527574e-09 - 0.96460390090942383j), (0.58778399229049683 - 0.78470128774642944j), (0.95105588436126709 - 0.28380891680717468j), (0.95105588436126709 + 0.32548999786376953j), (0.5877838134765625 + 0.82514488697052002j), (1.4629089051254596e-08 + 1.0096219778060913j), (-0.5877840518951416 + 0.81836479902267456j), (-0.95105588436126709 + 0.31451958417892456j), (-0.95105588436126709 - 0.3030143678188324j), (-0.5877838134765625 - 0.80480599403381348j), (-1.7554906861505515e-08 - 0.99516552686691284j), (0.58778399229049683 - 0.80540722608566284j), (0.95105582475662231 - 0.30557557940483093j), (0.95105588436126709 + 0.31097668409347534j), (0.5877838134765625 + 0.81027895212173462j), (2.3406542482007353e-08 + 1.0000816583633423j), (-0.5877840518951416 + 0.80908381938934326j), (-0.95105588436126709 + 0.30904293060302734j), (-0.95105588436126709 - 0.30904296040534973j), (-0.5877838134765625 - 0.80908387899398804j), (-2.6332360292258272e-08 - 1.0000815391540527j), (0.58778399229049683 - 0.80908381938934326j), (0.95105582475662231 - 0.30904299020767212j), (0.95105588436126709 + 0.30904293060302734j), (0.5877838134765625 + 0.80908381938934326j), (3.218399768911695e-08 + 1.0000815391540527j)) tb = self.tb sampling_freq = 100 ntaps = 51 N = int(ntaps + sampling_freq * 0.10) data = sin_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) src1 = blocks.vector_source_f(data) dst2 = blocks.vector_sink_c() # calculate taps taps = filter.firdes_hilbert(ntaps) hd = filter.filter_delay_fc(taps) tb.connect(src1, hd) tb.connect(hd, dst2) tb.run() # get output result_data = dst2.data() self.assertComplexTuplesAlmostEqual(expected_result, result_data, 5)
def test_003_filter_delay_two_inputs(self): # give two different inputs # expected result expected_result = (-0.0020331963896751404j, -0.0016448829555884004j, -0.0032375147566199303j, -0.0014826074475422502j, -0.0033034090884029865j, -0.00051144487224519253j, -0.0043686260469257832j, -0.0010198024101555347j, -0.0082517862319946289j, -0.003456643782556057j, -0.014193611219525337j, -0.005875137634575367j, -0.020293503999710083j, -0.0067503536120057106j, -0.026798896491527557j, -0.0073488112539052963j, -0.037041611969470978j, -0.010557252913713455j, -0.055669989436864853j, -0.018332764506340027j, -0.089904911816120148j, -0.033361352980136871j, -0.16902604699134827j, -0.074318811297416687j, -0.58429563045501709j, (7.2191945754696007e-09 - 0.35892376303672791j), (0.58778399229049683 + 0.63660913705825806j), (0.95105588436126709 + 0.87681591510772705j), (0.95105588436126709 + 0.98705857992172241j), (0.5877838134765625 + 0.55447429418563843j), (5.8516356205018383e-09 + 0.026006083935499191j), (-0.5877840518951416 - 0.60616838932037354j), (-0.95105588436126709 - 0.9311758279800415j), (-0.95105588436126709 - 0.96169203519821167j), (-0.5877838134765625 - 0.57292771339416504j), (-8.7774534307527574e-09 - 0.0073488391935825348j), (0.58778399229049683 + 0.59720659255981445j), (0.95105588436126709 + 0.94438445568084717j), (0.95105588436126709 + 0.95582199096679688j), (0.5877838134765625 + 0.58196049928665161j), (1.4629089051254596e-08 + 0.0026587247848510742j), (-0.5877840518951416 - 0.59129220247268677j), (-0.95105588436126709 - 0.94841635227203369j), (-0.95105588436126709 - 0.95215457677841187j), (-0.5877838134765625 - 0.58535969257354736j), (-1.7554906861505515e-08 - 0.00051158666610717773j), (0.58778399229049683 + 0.58867418766021729j), (0.95105582475662231 + 0.94965213537216187j), (0.95105588436126709 + 0.95050644874572754j), (0.5877838134765625 + 0.58619076013565063j), (2.3406542482007353e-08 + 1.1920928955078125e-07j), (-0.5877840518951416 - 0.58783555030822754j), (-0.95105588436126709 - 0.95113480091094971j), (-0.95105588436126709 - 0.95113474130630493j), (-0.5877838134765625 - 0.58783555030822754j), (-2.6332360292258272e-08 - 8.1956386566162109e-08j), (0.58778399229049683 + 0.58783555030822754j), (0.95105582475662231 + 0.95113474130630493j), (0.95105588436126709 + 0.95113474130630493j), (0.5877838134765625 + 0.58783560991287231j), (3.218399768911695e-08 + 1.1920928955078125e-07j)) tb = self.tb sampling_freq = 100 ntaps = 51 N = int(ntaps + sampling_freq * 0.10) data1 = sin_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) data2 = cos_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) src1 = blocks.vector_source_f(data1) src2 = blocks.vector_source_f(data2) taps = filter.firdes_hilbert(ntaps) hd = filter.filter_delay_fc(taps) dst2 = blocks.vector_sink_c() tb.connect(src1, (hd, 0)) tb.connect(src2, (hd, 1)) tb.connect(hd, dst2) tb.run() # get output result_data = dst2.data() self.assertComplexTuplesAlmostEqual(expected_result, result_data, 5)
def __init__(self): gr.top_block.__init__(self, "Delay Test") Qt.QWidget.__init__(self) self.setWindowTitle("Delay Test") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "delay_test") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.samp_rate = samp_rate = 6e6 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts) self.constel = constel = digital.constellation_calcdist( (digital.psk_4()[0]), (digital.psk_4()[1]), 4, 1).base() self.constel.gen_soft_dec_lut(8) ################################################## # Blocks ################################################## self.qtgui_time_sink_x_1_0_1_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Filter", #name 2 #number of inputs ) self.qtgui_time_sink_x_1_0_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_1_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_1_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_1_0_win) self.qtgui_time_sink_x_1_0_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Before and After Down Conversion", #name 2 #number of inputs ) self.qtgui_time_sink_x_1_0_1.set_update_time(0.10) self.qtgui_time_sink_x_1_0_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_1.enable_autoscale(False) self.qtgui_time_sink_x_1_0_1.enable_grid(False) self.qtgui_time_sink_x_1_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_1.enable_control_panel(False) self.qtgui_time_sink_x_1_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_1_win) self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Imaginary", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Real", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_win) self.filter_delay_fc_0 = filter.filter_delay_fc((rrc_taps)) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=constel, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.blocks_vector_source_x_0 = blocks.vector_source_b((255, 127, 0), True, 1, []) self.blocks_multiply_xx_0_0_2 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_0_1 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 10e4, 1, 0) self.analog_sig_source_x_0_0_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, 10e4, -1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, 10e4, -1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 10e4, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0_0, 0)) self.connect((self.analog_sig_source_x_0_0_0, 0), (self.blocks_multiply_xx_0_0_2, 1)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_0_0_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_0_0_1, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_0_0_2, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_1_0_1, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_0_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_1_0_0, 0)) self.connect((self.blocks_complex_to_float_0_0, 0), (self.qtgui_time_sink_x_1_0_1, 1)) self.connect((self.blocks_complex_to_float_0_0, 1), (self.qtgui_time_sink_x_1_0_1_0, 1)) self.connect((self.blocks_complex_to_float_0_0, 0), (self.qtgui_time_sink_x_1_0_1_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_0_0_1, 0), (self.filter_delay_fc_0, 0)) self.connect((self.blocks_multiply_xx_0_0_2, 0), (self.filter_delay_fc_0, 1)) self.connect((self.blocks_vector_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.filter_delay_fc_0, 0), (self.blocks_complex_to_float_0_0, 0))
def test_001_filter_delay_one_input(self): # expected result expected_result = ( -1.4678005338941702e-11j, -0.0011950774351134896j, -0.0019336787518113852j, -0.0034673355985432863j, -0.0036765895783901215j, -0.004916108213365078j, -0.0042778430506587029j, -0.006028641015291214j, -0.005476709920912981j, -0.0092810001224279404j, -0.0095402700826525688j, -0.016060983762145042j, -0.016446959227323532j, -0.02523401565849781j, -0.024382550269365311j, -0.035477779805660248j, -0.033021725714206696j, -0.048487484455108643j, -0.04543270543217659j, -0.069477587938308716j, -0.066984444856643677j, -0.10703597217798233j, -0.10620346665382385j, -0.1852707713842392j, -0.19357112050056458j, (7.2191945754696007e-09 -0.50004088878631592j), (0.58778399229049683 -0.6155126690864563j), (0.95105588436126709 -0.12377222627401352j), (0.95105588436126709 +0.41524654626846313j), (0.5877838134765625 +0.91611981391906738j), (5.8516356205018383e-09 +1.0670661926269531j), (-0.5877840518951416 +0.87856143712997437j), (-0.95105588436126709 +0.35447561740875244j), (-0.95105588436126709 -0.26055556535720825j), (-0.5877838134765625 -0.77606213092803955j), (-8.7774534307527574e-09 -0.96460390090942383j), (0.58778399229049683 -0.78470128774642944j), (0.95105588436126709 -0.28380891680717468j), (0.95105588436126709 +0.32548999786376953j), (0.5877838134765625 +0.82514488697052002j), (1.4629089051254596e-08 +1.0096219778060913j), (-0.5877840518951416 +0.81836479902267456j), (-0.95105588436126709 +0.31451958417892456j), (-0.95105588436126709 -0.3030143678188324j), (-0.5877838134765625 -0.80480599403381348j), (-1.7554906861505515e-08 -0.99516552686691284j), (0.58778399229049683 -0.80540722608566284j), (0.95105582475662231 -0.30557557940483093j), (0.95105588436126709 +0.31097668409347534j), (0.5877838134765625 +0.81027895212173462j), (2.3406542482007353e-08 +1.0000816583633423j), (-0.5877840518951416 +0.80908381938934326j), (-0.95105588436126709 +0.30904293060302734j), (-0.95105588436126709 -0.30904296040534973j), (-0.5877838134765625 -0.80908387899398804j), (-2.6332360292258272e-08 -1.0000815391540527j), (0.58778399229049683 -0.80908381938934326j), (0.95105582475662231 -0.30904299020767212j), (0.95105588436126709 +0.30904293060302734j), (0.5877838134765625 +0.80908381938934326j), (3.218399768911695e-08 +1.0000815391540527j)) tb = self.tb sampling_freq = 100 ntaps = 51 N = int(ntaps + sampling_freq * 0.10) data = sin_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) src1 = blocks.vector_source_f(data) dst2 = blocks.vector_sink_c() # calculate taps taps = filter.firdes_hilbert(ntaps) hd = filter.filter_delay_fc(taps) tb.connect(src1, hd) tb.connect(hd, dst2) tb.run() # get output result_data = dst2.data() self.assertComplexTuplesAlmostEqual(expected_result, result_data, 5)
def test_003_filter_delay_two_inputs(self): # give two different inputs # expected result expected_result = ( -0.0020331963896751404j, -0.0016448829555884004j, -0.0032375147566199303j, -0.0014826074475422502j, -0.0033034090884029865j, -0.00051144487224519253j, -0.0043686260469257832j, -0.0010198024101555347j, -0.0082517862319946289j, -0.003456643782556057j, -0.014193611219525337j, -0.005875137634575367j, -0.020293503999710083j, -0.0067503536120057106j, -0.026798896491527557j, -0.0073488112539052963j, -0.037041611969470978j, -0.010557252913713455j, -0.055669989436864853j, -0.018332764506340027j, -0.089904911816120148j, -0.033361352980136871j, -0.16902604699134827j, -0.074318811297416687j, -0.58429563045501709j, (7.2191945754696007e-09 -0.35892376303672791j), (0.58778399229049683 +0.63660913705825806j), (0.95105588436126709 +0.87681591510772705j), (0.95105588436126709 +0.98705857992172241j), (0.5877838134765625 +0.55447429418563843j), (5.8516356205018383e-09 +0.026006083935499191j), (-0.5877840518951416 -0.60616838932037354j), (-0.95105588436126709 -0.9311758279800415j), (-0.95105588436126709 -0.96169203519821167j), (-0.5877838134765625 -0.57292771339416504j), (-8.7774534307527574e-09 -0.0073488391935825348j), (0.58778399229049683 +0.59720659255981445j), (0.95105588436126709 +0.94438445568084717j), (0.95105588436126709 +0.95582199096679688j), (0.5877838134765625 +0.58196049928665161j), (1.4629089051254596e-08 +0.0026587247848510742j), (-0.5877840518951416 -0.59129220247268677j), (-0.95105588436126709 -0.94841635227203369j), (-0.95105588436126709 -0.95215457677841187j), (-0.5877838134765625 -0.58535969257354736j), (-1.7554906861505515e-08 -0.00051158666610717773j), (0.58778399229049683 +0.58867418766021729j), (0.95105582475662231 +0.94965213537216187j), (0.95105588436126709 +0.95050644874572754j), (0.5877838134765625 +0.58619076013565063j), (2.3406542482007353e-08 +1.1920928955078125e-07j), (-0.5877840518951416 -0.58783555030822754j), (-0.95105588436126709 -0.95113480091094971j), (-0.95105588436126709 -0.95113474130630493j), (-0.5877838134765625 -0.58783555030822754j), (-2.6332360292258272e-08 -8.1956386566162109e-08j), (0.58778399229049683 +0.58783555030822754j), (0.95105582475662231 +0.95113474130630493j), (0.95105588436126709 +0.95113474130630493j), (0.5877838134765625 +0.58783560991287231j), (3.218399768911695e-08 +1.1920928955078125e-07j)) tb = self.tb sampling_freq = 100 ntaps = 51 N = int(ntaps + sampling_freq * 0.10) data1 = sin_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) data2 = cos_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) src1 = blocks.vector_source_f(data1) src2 = blocks.vector_source_f(data2) taps = filter.firdes_hilbert(ntaps) hd = filter.filter_delay_fc(taps) dst2 = blocks.vector_sink_c() tb.connect(src1, (hd,0)) tb.connect(src2, (hd,1)) tb.connect(hd, dst2) tb.run() # get output result_data = dst2.data() self.assertComplexTuplesAlmostEqual(expected_result, result_data, 5)