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))
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'
def __init__(self): gr.top_block.__init__(self, "Run Rootmusic Calib Lin Array Simulation") Qt.QWidget.__init__(self) self.setWindowTitle("Run Rootmusic Calib 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_RootMUSIC_calib_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.44, 'NumTargets': 2, 'NumArrayElements': 4, 'PSpectrumLength': 2**10, 'SnapshotSize': 2**11, 'OverlapSize': 2**9, 'AntGains': numpy.array([0.94984789, 0.4544107, 0.34649469, 0.25083929]), 'AntPhases': numpy.array([0.28647672, 5.27248071, 2.71271102, 1.36970886]), 'DirectoryConfigFiles': "/tmp", 'AntennaCalibration': "calibration_lin_array_simulated.cfg", }) 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.ant_coeffs = ant_coeffs = input_variables.AntGains * numpy.exp( 1j * input_variables.AntPhases) self.amv1_true = amv1_true = numpy.exp(-1j * ant_locs * 2 * numpy.pi * numpy.cos(theta1)) self.amv0_true = amv0_true = numpy.exp(-1j * ant_locs * 2 * numpy.pi * numpy.cos(theta0)) self.amv1 = amv1 = numpy.multiply(ant_coeffs, amv1_true) self.amv0 = amv0 = numpy.multiply(ant_coeffs, amv0_true) self.array_manifold_matrix = array_manifold_matrix = numpy.array( [amv0, amv1]).transpose() self.antenna_calibration_file_name = antenna_calibration_file_name = os.path.join( input_variables.DirectoryConfigFiles, input_variables.AntennaCalibration) ################################################## # 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, 'Direction of Arrival') 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.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.doa_rootMUSIC_linear_array_0 = doa.rootMUSIC_linear_array( input_variables.NormSpacing, input_variables.NumTargets, input_variables.NumArrayElements) 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_0.addLayout(self.doa_compass.this_layout) self.doa_autocorrelate_0 = doa.autocorrelate( input_variables.NumArrayElements, input_variables.SnapshotSize, input_variables.OverlapSize, 1) self.doa_antenna_correction_0 = doa.antenna_correction( input_variables.NumArrayElements, antenna_calibration_file_name) 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_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_antenna_correction_0, 0)) self.connect((self.blocks_multiply_matrix_xx_0, 1), (self.doa_antenna_correction_0, 1)) self.connect((self.blocks_multiply_matrix_xx_0, 2), (self.doa_antenna_correction_0, 2)) self.connect((self.blocks_multiply_matrix_xx_0, 3), (self.doa_antenna_correction_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_antenna_correction_0, 0), (self.doa_autocorrelate_0, 0)) self.connect((self.doa_antenna_correction_0, 1), (self.doa_autocorrelate_0, 1)) self.connect((self.doa_antenna_correction_0, 2), (self.doa_autocorrelate_0, 2)) self.connect((self.doa_antenna_correction_0, 3), (self.doa_autocorrelate_0, 3)) self.connect((self.doa_autocorrelate_0, 0), (self.doa_rootMUSIC_linear_array_0, 0)) self.connect((self.doa_rootMUSIC_linear_array_0, 0), (self.blocks_vector_to_streams_0, 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))