Пример #1
0
        def test_002_t (self):
                self.vector_len = 2**12
                self.num_max_vals = 5

                # generate vector from octave
                oc = oct2py.Oct2Py()
                oc.addpath(os.path.dirname(__file__))
                data, expected_pks, expected_t_pks = oc.test002_findpeaks(self.num_max_vals, self.vector_len)
                data = data.flatten().tolist()

                ##################################################
                # Blocks
                ##################################################
                self.blocks_vector_source_x_0 = blocks.vector_source_f(data, False, self.vector_len, [])
                self.doa_find_local_max_0 = doa.find_local_max(self.num_max_vals, self.vector_len, 0.0, 2*numpy.pi)
                self.blocks_vector_sink_x_0 = blocks.vector_sink_f(self.num_max_vals)
                self.blocks_vector_sink_x_1 = blocks.vector_sink_f(self.num_max_vals)

                ##################################################
                # Connections
                ##################################################
                self.tb.connect((self.blocks_vector_source_x_0, 0), (self.doa_find_local_max_0, 0))
                self.tb.connect((self.doa_find_local_max_0, 0), (self.blocks_vector_sink_x_0, 0))
                self.tb.connect((self.doa_find_local_max_0, 1), (self.blocks_vector_sink_x_1, 0))

                # set up fg
                self.tb.run ()

                # get data from sink
                measured_pks = self.blocks_vector_sink_x_0.data()
                measured_pks_locs = self.blocks_vector_sink_x_1.data()

                # check data
                for i in range(len(measured_pks)):
                        self.assertAlmostEqual(expected_pks[i], measured_pks[i], 5) and self.assertAlmostEqual(expected_t_pks[i], measured_t_pks[i], 5)
    def __init__(self):
        gr.top_block.__init__(self, "Run Music Lin Array Simulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Run Music Lin Array Simulation")
        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", "run_MUSIC_lin_array_simulation")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.theta1_deg = theta1_deg = 123
        self.theta0_deg = theta0_deg = 30
        self.input_variables = input_variables = struct({'SampleRate': 320000, 'ToneFreq1': 10000, 'ToneFreq2': 20000, 'NormSpacing': 0.4, 'NumTargets': 2, 'NumArrayElements': 4, 'PSpectrumLength': 2**10, 'SnapshotSize': 2**11, 'OverlapSize': 2**9, })
        self.theta1 = theta1 = numpy.pi*theta1_deg/180
        self.theta0 = theta0 = numpy.pi*theta0_deg/180
        self.ant_locs = ant_locs = numpy.dot(input_variables.NormSpacing, numpy.arange(input_variables.NumArrayElements/2, -input_variables.NumArrayElements/2, -1) if (input_variables.NumArrayElements%2==1) else numpy.arange(input_variables.NumArrayElements/2-0.5, -input_variables.NumArrayElements/2-0.5, -1))
        self.amv1 = amv1 = numpy.exp(-1j*ant_locs*2*numpy.pi*numpy.cos(theta1))
        self.amv0 = amv0 = numpy.exp(-1j*ant_locs*2*numpy.pi*numpy.cos(theta0))
        self.array_manifold_matrix = array_manifold_matrix = numpy.array([amv0, amv1]).transpose()

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'Pseudo-Spectrum')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'Direction of Arrival')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'Direction of Arrival')
        self.top_layout.addWidget(self.tab)
        self._theta1_deg_range = Range(0, 180, 1, 123, 200)
        self._theta1_deg_win = RangeWidget(self._theta1_deg_range, self.set_theta1_deg, 'AoA', "counter_slider", float)
        self.top_layout.addWidget(self._theta1_deg_win)
        self._theta0_deg_range = Range(0, 180, 1, 30, 200)
        self._theta0_deg_win = RangeWidget(self._theta0_deg_range, self.set_theta0_deg, 'AoA', "counter_slider", float)
        self.top_layout.addWidget(self._theta0_deg_win)
        self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f(
            input_variables.PSpectrumLength,
            0,
            180.0/input_variables.PSpectrumLength,
            "angle (in degrees)",
            "Pseudo-Spectrum (dB)",
            "",
            1 # Number of inputs
        )
        self.qtgui_vector_sink_f_0.set_update_time(0.05)
        self.qtgui_vector_sink_f_0.set_y_axis(-50, 0)
        self.qtgui_vector_sink_f_0.enable_autoscale(False)
        self.qtgui_vector_sink_f_0.enable_grid(True)
        self.qtgui_vector_sink_f_0.set_x_axis_units("")
        self.qtgui_vector_sink_f_0.set_y_axis_units("")
        self.qtgui_vector_sink_f_0.set_ref_level(0)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [2, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        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_vector_sink_f_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_vector_sink_f_0.set_line_label(i, labels[i])
            self.qtgui_vector_sink_f_0.set_line_width(i, widths[i])
            self.qtgui_vector_sink_f_0.set_line_color(i, colors[i])
            self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_vector_sink_f_0_win = sip.wrapinstance(self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.addWidget(self._qtgui_vector_sink_f_0_win)
        self.doa_find_local_max_0 = doa.find_local_max(input_variables.NumTargets, input_variables.PSpectrumLength, 0.0, 180.0)
        self.doa_compass_0 = doa.compass("", 0, 180, 10, 0)
        self.tab_layout_1.addLayout(self.doa_compass_0.this_layout)
        self.doa_compass = doa.compass("", 0, 180, 10, 0)
        self.tab_layout_2.addLayout(self.doa_compass.this_layout)
        self.doa_autocorrelate_0 = doa.autocorrelate(input_variables.NumArrayElements, input_variables.SnapshotSize, input_variables.OverlapSize, 1)
        self.doa_MUSIC_lin_array_0 = doa.MUSIC_lin_array(input_variables.NormSpacing, input_variables.NumTargets, input_variables.NumArrayElements, input_variables.PSpectrumLength)
        self.blocks_vector_to_streams_0 = blocks.vector_to_streams(gr.sizeof_float*1, input_variables.NumTargets)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, input_variables.SampleRate,True)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*input_variables.NumTargets)
        self.blocks_multiply_matrix_xx_0 = blocks.multiply_matrix_cc(array_manifold_matrix, gr.TPP_ALL_TO_ALL)
        self.blocks_add_xx_0_0 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(input_variables.SampleRate, analog.GR_COS_WAVE, input_variables.ToneFreq2, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(input_variables.SampleRate, analog.GR_COS_WAVE, input_variables.ToneFreq1, 1, 0)
        self.analog_noise_source_x_0_0_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0.5, 0)
        self.analog_noise_source_x_0_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0.0005, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0_0, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.analog_noise_source_x_0_0_0, 0), (self.blocks_add_xx_0_0, 1))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 0))    
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_add_xx_0_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_matrix_xx_0, 0))    
        self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_throttle_0_0, 0))    
        self.connect((self.blocks_multiply_matrix_xx_0, 0), (self.doa_autocorrelate_0, 0))    
        self.connect((self.blocks_multiply_matrix_xx_0, 1), (self.doa_autocorrelate_0, 1))    
        self.connect((self.blocks_multiply_matrix_xx_0, 2), (self.doa_autocorrelate_0, 2))    
        self.connect((self.blocks_multiply_matrix_xx_0, 3), (self.doa_autocorrelate_0, 3))    
        self.connect((self.blocks_throttle_0_0, 0), (self.blocks_multiply_matrix_xx_0, 1))    
        self.connect((self.blocks_vector_to_streams_0, 0), (self.doa_compass, 0))    
        self.connect((self.blocks_vector_to_streams_0, 1), (self.doa_compass_0, 0))    
        self.connect((self.doa_MUSIC_lin_array_0, 0), (self.doa_find_local_max_0, 0))    
        self.connect((self.doa_MUSIC_lin_array_0, 0), (self.qtgui_vector_sink_f_0, 0))    
        self.connect((self.doa_autocorrelate_0, 0), (self.doa_MUSIC_lin_array_0, 0))    
        self.connect((self.doa_find_local_max_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.doa_find_local_max_0, 1), (self.blocks_vector_to_streams_0, 0))    
Пример #3
0
    def __init__(self):
        gr.top_block.__init__(self, "Run Music Lin Array Simulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Run Music Lin Array Simulation")
        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", "run_MUSIC_lin_array_simulation")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.theta1_deg = theta1_deg = 123
        self.theta0_deg = theta0_deg = 30
        self.input_variables = input_variables = struct({'SampleRate': 320000, 'ToneFreq1': 10000, 'ToneFreq2': 20000, 'NormSpacing': 0.4, 'NumTargets': 2, 'NumArrayElements': 4, 'PSpectrumLength': 2**10, 'SnapshotSize': 2**11, 'OverlapSize': 2**9, 'distributionFIFO': "distributionFIFO", 'reductionFIFO': "reductionFIFO", 'readFIFO': "readFIFO", 'writeFIFO': "writeFIFO", })
        self.theta1 = theta1 = numpy.pi*theta1_deg/180
        self.theta0 = theta0 = numpy.pi*theta0_deg/180
        self.ant_locs = ant_locs = numpy.dot(input_variables.NormSpacing, numpy.arange(input_variables.NumArrayElements/2, -input_variables.NumArrayElements/2, -1) if (input_variables.NumArrayElements%2==1) else numpy.arange(input_variables.NumArrayElements/2-0.5, -input_variables.NumArrayElements/2-0.5, -1))
        self.amv1 = amv1 = numpy.exp(-1j*ant_locs*2*numpy.pi*numpy.cos(theta1))
        self.amv0 = amv0 = numpy.exp(-1j*ant_locs*2*numpy.pi*numpy.cos(theta0))
        self.array_manifold_matrix = array_manifold_matrix = numpy.array([amv0, amv1]).transpose()

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'Pseudo-Spectrum')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'Direction of Arrival')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'Direction of Arrival')
        self.tab_widget_3 = Qt.QWidget()
        self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_3)
        self.tab_grid_layout_3 = Qt.QGridLayout()
        self.tab_layout_3.addLayout(self.tab_grid_layout_3)
        self.tab.addTab(self.tab_widget_3, 'Time Sink')
        self.top_layout.addWidget(self.tab)
        self._theta1_deg_range = Range(0, 180, 1, 123, 200)
        self._theta1_deg_win = RangeWidget(self._theta1_deg_range, self.set_theta1_deg, 'AoA', "counter_slider", float)
        self.top_layout.addWidget(self._theta1_deg_win)
        self._theta0_deg_range = Range(0, 180, 1, 30, 200)
        self._theta0_deg_win = RangeWidget(self._theta0_deg_range, self.set_theta0_deg, 'AoA', "counter_slider", float)
        self.top_layout.addWidget(self._theta0_deg_win)
        self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f(
            input_variables.PSpectrumLength,
            0,
            180.0/input_variables.PSpectrumLength,
            "angle (in degrees)",
            "Pseudo-Spectrum (dB)",
            "",
            1 # Number of inputs
        )
        self.qtgui_vector_sink_f_0.set_update_time(0.05)
        self.qtgui_vector_sink_f_0.set_y_axis(-50, 0)
        self.qtgui_vector_sink_f_0.enable_autoscale(False)
        self.qtgui_vector_sink_f_0.enable_grid(True)
        self.qtgui_vector_sink_f_0.set_x_axis_units("")
        self.qtgui_vector_sink_f_0.set_y_axis_units("")
        self.qtgui_vector_sink_f_0.set_ref_level(0)

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [2, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        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_vector_sink_f_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_vector_sink_f_0.set_line_label(i, labels[i])
            self.qtgui_vector_sink_f_0.set_line_width(i, widths[i])
            self.qtgui_vector_sink_f_0.set_line_color(i, colors[i])
            self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i])

        self._qtgui_vector_sink_f_0_win = sip.wrapinstance(self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.addWidget(self._qtgui_vector_sink_f_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
        	1024, #size
        	input_variables.SampleRate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0.enable_grid(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
          self.qtgui_time_sink_x_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:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_3.addWidget(self._qtgui_time_sink_x_0_win)
        self.doa_find_local_max_0 = doa.find_local_max(input_variables.NumTargets, input_variables.PSpectrumLength, 0.0, 180.0)
        self.doa_compass_0 = doa.compass("", 0, 180, 10, 0)
        self.tab_layout_1.addLayout(self.doa_compass_0.this_layout)
        self.doa_compass = doa.compass("", 0, 180, 10, 0)
        self.tab_layout_2.addLayout(self.doa_compass.this_layout)
        self.doa_autocorrelate_0 = doa.autocorrelate(input_variables.NumArrayElements, input_variables.SnapshotSize, input_variables.OverlapSize, 1)
        self.doa_MUSIC_lin_array_cnx_0 = Template error: doa.MUSIC_lin_array_cnx($norm_spacing, $num_targets, $num_ant_ele, $pspectrum_len, $distributionFIFO, $reductionFIFO, $writeFIFO, $readFIFO)
            cannot find 'num_ant_ele'
Пример #4
0
    def __init__(self):
        gr.top_block.__init__(self, "Run Music Lin Array X310 Twinrx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Run Music Lin Array X310 Twinrx")
        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",
                                     "run_MUSIC_lin_array_X310_TwinRX")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.input_variables = input_variables = struct({
            'ToneFreq':
            10000,
            'SampleRate':
            1000000,
            'CenterFreq':
            2450000000,
            'RxAddr':
            "addr=192.168.40.2",
            'Gain':
            60,
            'NumArrayElements':
            4,
            'NormSpacing':
            0.5,
            'SnapshotSize':
            2**11,
            'OverlapSize':
            2**9,
            'NumTargets':
            1,
            'PSpectrumLength':
            2**10,
            'DirectoryConfigFiles':
            "/tmp",
            'RelativePhaseOffsets':
            "measure_X310_TwinRX_relative_phase_offsets_245.cfg",
        })
        self.rel_phase_offsets_file_name = rel_phase_offsets_file_name = os.path.join(
            input_variables.DirectoryConfigFiles,
            input_variables.RelativePhaseOffsets)

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'Pseudo-Spectrum')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'Angle of Arrival (MUSIC)')
        self.top_layout.addWidget(self.tab)
        self.twinrx_usrp_source_0 = doa.twinrx_usrp_source(
            samp_rate=input_variables.SampleRate,
            center_freq=input_variables.CenterFreq,
            gain=input_variables.Gain,
            sources=input_variables.NumArrayElements,
            addresses=input_variables.RxAddr)
        self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f(
            input_variables.PSpectrumLength,
            0,
            180.0 / input_variables.PSpectrumLength,
            "angle (in degrees)",
            "Pseudo-Spectrum (dB)",
            "",
            1  # Number of inputs
        )
        self.qtgui_vector_sink_f_0.set_update_time(0.05)
        self.qtgui_vector_sink_f_0.set_y_axis(-20, 0)
        self.qtgui_vector_sink_f_0.enable_autoscale(False)
        self.qtgui_vector_sink_f_0.enable_grid(True)
        self.qtgui_vector_sink_f_0.set_x_axis_units("")
        self.qtgui_vector_sink_f_0.set_y_axis_units("")
        self.qtgui_vector_sink_f_0.set_ref_level(0)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        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_vector_sink_f_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_vector_sink_f_0.set_line_label(i, labels[i])
            self.qtgui_vector_sink_f_0.set_line_width(i, widths[i])
            self.qtgui_vector_sink_f_0.set_line_color(i, colors[i])
            self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i])

        self._qtgui_vector_sink_f_0_win = sip.wrapinstance(
            self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.addWidget(self._qtgui_vector_sink_f_0_win)
        self.phase_correct_hier_1 = doa.phase_correct_hier(
            num_ports=input_variables.NumArrayElements,
            config_filename=rel_phase_offsets_file_name,
        )
        self.doa_find_local_max_0 = doa.find_local_max(
            input_variables.NumTargets, input_variables.PSpectrumLength, 0.0,
            180.0)
        self.doa_compass = doa.compass("", 0, 180, 10, 0)
        self.tab_layout_1.addLayout(self.doa_compass.this_layout)
        self.doa_autocorrelate_0 = doa.autocorrelate(
            input_variables.NumArrayElements, input_variables.SnapshotSize,
            input_variables.OverlapSize, 1)
        self.doa_MUSIC_lin_array_0 = doa.MUSIC_lin_array(
            input_variables.NormSpacing, input_variables.NumTargets,
            input_variables.NumArrayElements, input_variables.PSpectrumLength)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float *
                                                   input_variables.NumTargets)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.doa_MUSIC_lin_array_0, 0),
                     (self.doa_find_local_max_0, 0))
        self.connect((self.doa_MUSIC_lin_array_0, 0),
                     (self.qtgui_vector_sink_f_0, 0))
        self.connect((self.doa_autocorrelate_0, 0),
                     (self.doa_MUSIC_lin_array_0, 0))
        self.connect((self.doa_find_local_max_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.doa_find_local_max_0, 1), (self.doa_compass, 0))
        self.connect((self.phase_correct_hier_1, 0),
                     (self.doa_autocorrelate_0, 0))
        self.connect((self.phase_correct_hier_1, 1),
                     (self.doa_autocorrelate_0, 1))
        self.connect((self.phase_correct_hier_1, 2),
                     (self.doa_autocorrelate_0, 2))
        self.connect((self.phase_correct_hier_1, 3),
                     (self.doa_autocorrelate_0, 3))
        self.connect((self.twinrx_usrp_source_0, 0),
                     (self.phase_correct_hier_1, 0))
        self.connect((self.twinrx_usrp_source_0, 1),
                     (self.phase_correct_hier_1, 1))
        self.connect((self.twinrx_usrp_source_0, 2),
                     (self.phase_correct_hier_1, 2))
        self.connect((self.twinrx_usrp_source_0, 3),
                     (self.phase_correct_hier_1, 3))
Пример #5
0
    def test_001_MUSIC_aoa23(self):
        # length of each snapshot
        len_ss = 256
        # overlap size of each snapshot
        overlap_size = 32
        # apply Forward-Backward Averaging?
        FB = True
        # normalized_spacing
        norm_spacing = 0.4
        # number of sources
        num_srcs = 1
        # expected angle-of-arrival
        expected_aoa = 23.0
        # number of array elements
        num_arr_ele = 8
        # simulate perturbation?
        PERTURB = False

        # Generate auto-correlation vector from octave
        oc = oct2py.Oct2Py()
        oc.addpath(
            os.path.join(os.path.dirname(os.path.dirname(__file__)),
                         'examples'))
        music_linear_input = oc.doa_testbench_create('music_test_input_gen',
                                                     len_ss, overlap_size,
                                                     num_arr_ele, FB, 'linear',
                                                     num_arr_ele, norm_spacing,
                                                     PERTURB, expected_aoa)
        music_linear_input = music_linear_input.flatten().tolist()

        ##################################################
        # Blocks
        ##################################################
        self.doa_MUSIC_0 = doa.MUSIC_lin_array(norm_spacing, num_srcs,
                                               num_arr_ele, self.pspectrum_len)
        self.doa_find_local_max_0 = doa.find_local_max(num_srcs,
                                                       self.pspectrum_len, 0.0,
                                                       180.0)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * num_srcs)
        self.vec_sink = blocks.vector_sink_f(num_srcs)
        self.vec_source = blocks.vector_source_c(music_linear_input, False,
                                                 num_arr_ele * num_arr_ele)

        ##################################################
        # Connections
        ##################################################
        self.tb.connect((self.vec_source, 0), (self.doa_MUSIC_0, 0))
        self.tb.connect((self.doa_MUSIC_0, 0), (self.doa_find_local_max_0, 0))
        self.tb.connect((self.doa_find_local_max_0, 1), (self.vec_sink, 0))
        self.tb.connect((self.doa_find_local_max_0, 0),
                        (self.blocks_null_sink_0, 0))

        # set up fg
        self.tb.run()

        # get data from sink
        aoa_output_23 = self.vec_sink.data()

        # check
        measured_aoa_is_23 = True
        for i in range(len(aoa_output_23)):
            if (abs(aoa_output_23[i] - expected_aoa) > 2.0):
                measured_aoa_is_23 = False

        self.assertTrue(measured_aoa_is_23)
Пример #6
0
    def __init__(self):
        gr.top_block.__init__(self, "Run Music Lin Array X310 Twinrx")

        ##################################################
        # Variables
        ##################################################
        self.input_variables = input_variables = struct({
            "NumArrayElements":
            2,
            "NormSpacing":
            0.33,
            "SnapshotSize":
            2**11,
            "OverlapSize":
            2**9,
            "NumTargets":
            1,
            "PSpectrumLength":
            2**10,
            "DirectoryConfigFiles":
            "/home/donnie",
            "RelativePhaseOffsets":
            "measure_X310_TwinRX_relative_phase_offsets_245.cfg",
        })
        self.rel_phase_offsets_file_name = rel_phase_offsets_file_name = os.path.join(
            input_variables.DirectoryConfigFiles,
            input_variables.RelativePhaseOffsets)

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_pull_source_0_0 = zeromq.pull_source(
            gr.sizeof_gr_complex, 1, "tcp://192.168.1.20:9998", 100, False, -1)
        self.zeromq_pull_source_0 = zeromq.pull_source(
            gr.sizeof_gr_complex, 1, "tcp://192.168.1.20:9999", 100, False, -1)
        self.phase_correct_hier_1 = doa.phase_correct_hier(
            num_ports=input_variables.NumArrayElements,
            config_filename=rel_phase_offsets_file_name,
        )
        self.doa_find_local_max_0 = doa.find_local_max(
            input_variables.NumTargets, input_variables.PSpectrumLength, 0.0,
            180.0)
        self.doa_average_and_save_0 = doa.average_and_save(
            5000, input_variables.NumTargets,
            "/home/donnie/daniel/PyProj/data.cfg")
        self.doa_autocorrelate_0 = doa.autocorrelate(
            input_variables.NumArrayElements, input_variables.SnapshotSize,
            input_variables.OverlapSize, 1)
        self.doa_MUSIC_lin_array_0 = doa.MUSIC_lin_array(
            input_variables.NormSpacing, input_variables.NumTargets,
            input_variables.NumArrayElements, input_variables.PSpectrumLength)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float *
                                                   input_variables.NumTargets)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.doa_MUSIC_lin_array_0, 0),
                     (self.doa_find_local_max_0, 0))
        self.connect((self.doa_autocorrelate_0, 0),
                     (self.doa_MUSIC_lin_array_0, 0))
        self.connect((self.doa_find_local_max_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.doa_find_local_max_0, 1),
                     (self.doa_average_and_save_0, 0))
        self.connect((self.phase_correct_hier_1, 0),
                     (self.doa_autocorrelate_0, 0))
        self.connect((self.phase_correct_hier_1, 1),
                     (self.doa_autocorrelate_0, 1))
        self.connect((self.zeromq_pull_source_0, 0),
                     (self.phase_correct_hier_1, 0))
        self.connect((self.zeromq_pull_source_0_0, 0),
                     (self.phase_correct_hier_1, 1))