def __init__(self): gr.top_block.__init__(self, "Event Detect") Qt.QWidget.__init__(self) self.setWindowTitle("Event Detect") 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", "detect_log") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.vec_length = vec_length = 512 self.samp_rate = samp_rate = 10e6 self.nsigma = nsigma = 3.9 self.mode = mode = 1 self.freq = freq = 705e6 ################################################## # Blocks ################################################## self._nsigma_range = Range(0.1, 10., .1, 3.9, 100) self._nsigma_win = RangeWidget(self._nsigma_range, self.set_nsigma, 'N Sigma', "counter", float) self.top_grid_layout.addWidget(self._nsigma_win) self._mode_options = ( 0, 1, ) self._mode_labels = ( 'Monitor', 'Detect', ) self._mode_tool_bar = Qt.QToolBar(self) self._mode_tool_bar.addWidget(Qt.QLabel('Mode' + ": ")) self._mode_combo_box = Qt.QComboBox() self._mode_tool_bar.addWidget(self._mode_combo_box) for label in self._mode_labels: self._mode_combo_box.addItem(label) self._mode_callback = lambda i: Qt.QMetaObject.invokeMethod( self._mode_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._mode_options.index(i))) self._mode_callback(self.mode) self._mode_combo_box.currentIndexChanged.connect( lambda i: self.set_mode(self._mode_options[i])) self.top_grid_layout.addWidget(self._mode_tool_bar) self.radio_astro_ra_event_sink_0 = radio_astro.ra_event_sink( 'Watch.not', vec_length, samp_rate, 1) self.radio_astro_ra_event_log_0 = radio_astro.ra_event_log( '', 'Event Detection', vec_length, samp_rate) self.radio_astro_detect_0 = radio_astro.detect(vec_length, nsigma, freq / 1e6, samp_rate / 1e6, 1, mode) self.qtgui_vector_sink_f_0_0_0 = qtgui.vector_sink_f( vec_length, 0, 1.0, "x-Axis", "y-Axis", 'Data Stream', 2 # Number of inputs ) self.qtgui_vector_sink_f_0_0_0.set_update_time(0.2) self.qtgui_vector_sink_f_0_0_0.set_y_axis(-3, 3) self.qtgui_vector_sink_f_0_0_0.enable_autoscale(False) self.qtgui_vector_sink_f_0_0_0.enable_grid(False) self.qtgui_vector_sink_f_0_0_0.set_x_axis_units("") self.qtgui_vector_sink_f_0_0_0.set_y_axis_units("") self.qtgui_vector_sink_f_0_0_0.set_ref_level(0) labels = ['I', 'Q', 'I', 'Q', '', '', '', '', '', ''] widths = [1, 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(2): if len(labels[i]) == 0: self.qtgui_vector_sink_f_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_vector_sink_f_0_0_0.set_line_label(i, labels[i]) self.qtgui_vector_sink_f_0_0_0.set_line_width(i, widths[i]) self.qtgui_vector_sink_f_0_0_0.set_line_color(i, colors[i]) self.qtgui_vector_sink_f_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_vector_sink_f_0_0_0_win = sip.wrapinstance( self.qtgui_vector_sink_f_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_vector_sink_f_0_0_0_win) self.qtgui_vector_sink_f_0_0 = qtgui.vector_sink_f( vec_length, 0, 1.0, "x-Axis", "y-Axis", 'Event', 2 # Number of inputs ) self.qtgui_vector_sink_f_0_0.set_update_time(.2) self.qtgui_vector_sink_f_0_0.set_y_axis(-3, 3) self.qtgui_vector_sink_f_0_0.enable_autoscale(False) self.qtgui_vector_sink_f_0_0.enable_grid(False) self.qtgui_vector_sink_f_0_0.set_x_axis_units("") self.qtgui_vector_sink_f_0_0.set_y_axis_units("") self.qtgui_vector_sink_f_0_0.set_ref_level(0) labels = ['Event I', 'Event Q', 'I', 'Q', '', '', '', '', '', ''] widths = [1, 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(2): if len(labels[i]) == 0: self.qtgui_vector_sink_f_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_vector_sink_f_0_0.set_line_label(i, labels[i]) self.qtgui_vector_sink_f_0_0.set_line_width(i, widths[i]) self.qtgui_vector_sink_f_0_0.set_line_color(i, colors[i]) self.qtgui_vector_sink_f_0_0.set_line_alpha(i, alphas[i]) self._qtgui_vector_sink_f_0_0_win = sip.wrapinstance( self.qtgui_vector_sink_f_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_vector_sink_f_0_0_win) self.blocks_throttle_0 = blocks.throttle( gr.sizeof_gr_complex * vec_length, samp_rate, True) self.blocks_tag_debug_0 = blocks.tag_debug( gr.sizeof_gr_complex * vec_length, '', "") self.blocks_tag_debug_0.set_display(True) self.blocks_stream_to_vector_0_0_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, vec_length) self.blocks_complex_to_float_0_0 = blocks.complex_to_float(vec_length) self.blocks_complex_to_float_0 = blocks.complex_to_float(vec_length) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_stream_to_vector_0_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_vector_sink_f_0_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_vector_sink_f_0_0, 0)) self.connect((self.blocks_complex_to_float_0_0, 1), (self.qtgui_vector_sink_f_0_0_0, 1)) self.connect((self.blocks_complex_to_float_0_0, 0), (self.qtgui_vector_sink_f_0_0_0, 0)) self.connect((self.blocks_stream_to_vector_0_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_float_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.radio_astro_detect_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.radio_astro_ra_event_log_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.radio_astro_ra_event_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Nsf RTLSDR Event Detect: 3MHz") Qt.QWidget.__init__(self) self.setWindowTitle("Nsf RTLSDR Event Detect: 3MHz") 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", "NsfDetectHist60") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.ObsName = ObsName = "Detect60" self.ConfigFile = ConfigFile = ObsName + ".conf" self._telescope_save_config = ConfigParser.ConfigParser() self._telescope_save_config.read(ConfigFile) try: telescope_save = self._telescope_save_config.get( 'main', 'telescope') except: telescope_save = 'My Horn' self.telescope_save = telescope_save self._observer_save_config = ConfigParser.ConfigParser() self._observer_save_config.read(ConfigFile) try: observer_save = self._observer_save_config.get('main', 'observer') except: observer_save = 'Science Aficionado' self.observer_save = observer_save self._fftsize_save_config = ConfigParser.ConfigParser() self._fftsize_save_config.read(ConfigFile) try: fftsize_save = self._fftsize_save_config.getint( 'main', 'samplesize') except: fftsize_save = 2048 self.fftsize_save = fftsize_save self._device_save_config = ConfigParser.ConfigParser() self._device_save_config.read(ConfigFile) try: device_save = self._device_save_config.get('main', 'device') except: device_save = 'airspy,bias=1,pack=1' self.device_save = device_save self._Gain1s_config = ConfigParser.ConfigParser() self._Gain1s_config.read(ConfigFile) try: Gain1s = self._Gain1s_config.getfloat('main', 'gain1') except: Gain1s = 49. self.Gain1s = Gain1s self._Frequencys_config = ConfigParser.ConfigParser() self._Frequencys_config.read(ConfigFile) try: Frequencys = self._Frequencys_config.getfloat('main', 'frequency') except: Frequencys = 1420.4e6 self.Frequencys = Frequencys self._Elevation_save_config = ConfigParser.ConfigParser() self._Elevation_save_config.read(ConfigFile) try: Elevation_save = self._Elevation_save_config.getfloat( 'main', 'elevation') except: Elevation_save = 90. self.Elevation_save = Elevation_save self._Bandwidths_config = ConfigParser.ConfigParser() self._Bandwidths_config.read(ConfigFile) try: Bandwidths = self._Bandwidths_config.getfloat('main', 'bandwidth') except: Bandwidths = 6.e6 self.Bandwidths = Bandwidths self._Azimuth_save_config = ConfigParser.ConfigParser() self._Azimuth_save_config.read(ConfigFile) try: Azimuth_save = self._Azimuth_save_config.getfloat( 'main', 'azimuth') except: Azimuth_save = 180. self.Azimuth_save = Azimuth_save self.nsigma = nsigma = 5.0 self.fftsize = fftsize = fftsize_save self.Telescope = Telescope = telescope_save self.Observer = Observer = observer_save self.Mode = Mode = 2 self.Gain2 = Gain2 = 12. self.Gain1 = Gain1 = Gain1s self.Frequency = Frequency = Frequencys self.EventMode = EventMode = 0 self.Elevation = Elevation = Elevation_save self.Device = Device = device_save self.Bandwidth = Bandwidth = Bandwidths self.Azimuth = Azimuth = Azimuth_save ################################################## # Blocks ################################################## self._nsigma_range = Range(0., 10., .1, 5.0, 100) self._nsigma_win = RangeWidget(self._nsigma_range, self.set_nsigma, 'N Sigma', "counter", float) self.top_grid_layout.addWidget(self._nsigma_win, 7, 0, 1, 2) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._fftsize_tool_bar = Qt.QToolBar(self) self._fftsize_tool_bar.addWidget(Qt.QLabel('Sample_Size' + ": ")) self._fftsize_line_edit = Qt.QLineEdit(str(self.fftsize)) self._fftsize_tool_bar.addWidget(self._fftsize_line_edit) self._fftsize_line_edit.returnPressed.connect(lambda: self.set_fftsize( int(str(self._fftsize_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._fftsize_tool_bar, 1, 2, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._Telescope_tool_bar = Qt.QToolBar(self) self._Telescope_tool_bar.addWidget(Qt.QLabel('Tel' + ": ")) self._Telescope_line_edit = Qt.QLineEdit(str(self.Telescope)) self._Telescope_tool_bar.addWidget(self._Telescope_line_edit) self._Telescope_line_edit.returnPressed.connect( lambda: self.set_Telescope( str(str(self._Telescope_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Telescope_tool_bar, 1, 0, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Observer_tool_bar = Qt.QToolBar(self) self._Observer_tool_bar.addWidget(Qt.QLabel('Who' + ": ")) self._Observer_line_edit = Qt.QLineEdit(str(self.Observer)) self._Observer_tool_bar.addWidget(self._Observer_line_edit) self._Observer_line_edit.returnPressed.connect( lambda: self.set_Observer( str(str(self._Observer_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Observer_tool_bar, 0, 0, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Mode_options = ( 0, 2, ) self._Mode_labels = ( 'Monitor', 'Detect', ) self._Mode_tool_bar = Qt.QToolBar(self) self._Mode_tool_bar.addWidget(Qt.QLabel('Data Mode' + ": ")) self._Mode_combo_box = Qt.QComboBox() self._Mode_tool_bar.addWidget(self._Mode_combo_box) for label in self._Mode_labels: self._Mode_combo_box.addItem(label) self._Mode_callback = lambda i: Qt.QMetaObject.invokeMethod( self._Mode_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._Mode_options.index(i))) self._Mode_callback(self.Mode) self._Mode_combo_box.currentIndexChanged.connect( lambda i: self.set_Mode(self._Mode_options[i])) self.top_grid_layout.addWidget(self._Mode_tool_bar, 6, 0, 1, 2) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Gain1_tool_bar = Qt.QToolBar(self) self._Gain1_tool_bar.addWidget(Qt.QLabel('Gain1' + ": ")) self._Gain1_line_edit = Qt.QLineEdit(str(self.Gain1)) self._Gain1_tool_bar.addWidget(self._Gain1_line_edit) self._Gain1_line_edit.returnPressed.connect(lambda: self.set_Gain1( eng_notation.str_to_num(str(self._Gain1_line_edit.text().toAscii()) ))) self.top_grid_layout.addWidget(self._Gain1_tool_bar, 0, 2, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._Frequency_tool_bar = Qt.QToolBar(self) self._Frequency_tool_bar.addWidget(Qt.QLabel('Freq. Hz' + ": ")) self._Frequency_line_edit = Qt.QLineEdit(str(self.Frequency)) self._Frequency_tool_bar.addWidget(self._Frequency_line_edit) self._Frequency_line_edit.returnPressed.connect( lambda: self.set_Frequency( eng_notation.str_to_num( str(self._Frequency_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Frequency_tool_bar, 0, 5, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 7): self.top_grid_layout.setColumnStretch(c, 1) self._EventMode_options = ( 0, 1, ) self._EventMode_labels = ( 'Wait', 'Write', ) self._EventMode_tool_bar = Qt.QToolBar(self) self._EventMode_tool_bar.addWidget(Qt.QLabel('Write Mode' + ": ")) self._EventMode_combo_box = Qt.QComboBox() self._EventMode_tool_bar.addWidget(self._EventMode_combo_box) for label in self._EventMode_labels: self._EventMode_combo_box.addItem(label) self._EventMode_callback = lambda i: Qt.QMetaObject.invokeMethod( self._EventMode_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._EventMode_options.index(i))) self._EventMode_callback(self.EventMode) self._EventMode_combo_box.currentIndexChanged.connect( lambda i: self.set_EventMode(self._EventMode_options[i])) self.top_grid_layout.addWidget(self._EventMode_tool_bar, 5, 0, 1, 2) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Elevation_tool_bar = Qt.QToolBar(self) self._Elevation_tool_bar.addWidget(Qt.QLabel('Elevation' + ": ")) self._Elevation_line_edit = Qt.QLineEdit(str(self.Elevation)) self._Elevation_tool_bar.addWidget(self._Elevation_line_edit) self._Elevation_line_edit.returnPressed.connect( lambda: self.set_Elevation( eng_notation.str_to_num( str(self._Elevation_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Elevation_tool_bar, 1, 7, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 9): self.top_grid_layout.setColumnStretch(c, 1) self._Device_tool_bar = Qt.QToolBar(self) self._Device_tool_bar.addWidget(Qt.QLabel('Dev' + ": ")) self._Device_line_edit = Qt.QLineEdit(str(self.Device)) self._Device_tool_bar.addWidget(self._Device_line_edit) self._Device_line_edit.returnPressed.connect(lambda: self.set_Device( str(str(self._Device_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Device_tool_bar, 2, 0, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Bandwidth_tool_bar = Qt.QToolBar(self) self._Bandwidth_tool_bar.addWidget(Qt.QLabel('Bandwidth' + ": ")) self._Bandwidth_line_edit = Qt.QLineEdit(str(self.Bandwidth)) self._Bandwidth_tool_bar.addWidget(self._Bandwidth_line_edit) self._Bandwidth_line_edit.returnPressed.connect( lambda: self.set_Bandwidth( eng_notation.str_to_num( str(self._Bandwidth_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Bandwidth_tool_bar, 1, 5, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 7): self.top_grid_layout.setColumnStretch(c, 1) self._Azimuth_tool_bar = Qt.QToolBar(self) self._Azimuth_tool_bar.addWidget(Qt.QLabel('Azimuth' + ": ")) self._Azimuth_line_edit = Qt.QLineEdit(str(self.Azimuth)) self._Azimuth_tool_bar.addWidget(self._Azimuth_line_edit) self._Azimuth_line_edit.returnPressed.connect(lambda: self.set_Azimuth( eng_notation.str_to_num( str(self._Azimuth_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Azimuth_tool_bar, 0, 7, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 9): self.top_grid_layout.setColumnStretch(c, 1) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + Device) self.rtlsdr_source_0.set_sample_rate(Bandwidth) self.rtlsdr_source_0.set_center_freq(Frequency, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(Gain1, 0) self.rtlsdr_source_0.set_if_gain(float(Gain2), 0) self.rtlsdr_source_0.set_bb_gain(float(Gain2), 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(Bandwidth, 0) (self.rtlsdr_source_0).set_processor_affinity([3]) self.radio_astro_ra_event_sink_0 = radio_astro.ra_event_sink( ObsName + ".not", fftsize, Frequency * 1.E-6, Bandwidth * 1.E-6, EventMode, 'Event Detection', Observer, Telescope, Device, Gain1, Azimuth, Elevation) self.radio_astro_detect_0 = radio_astro.detect( fftsize, nsigma, Frequency, Bandwidth, fftsize * 1.e-6 / Bandwidth, Mode) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( fftsize, 100, -.5, .5, "", 2) self.qtgui_histogram_sink_x_0.set_update_time(1) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(False) self.qtgui_histogram_sink_x_0.enable_grid(False) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_histogram_sink_x_0.disable_legend() labels = ['I', 'Q', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark 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_histogram_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance( self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win, 3, 0, 2, 2) for r in range(3, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, fftsize) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_histogram_sink_x_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.radio_astro_detect_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.radio_astro_ra_event_sink_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0, 0))
def __init__(self): gr.top_block.__init__(self, "NSF Watch for Events whille recording spectra") Qt.QWidget.__init__(self) self.setWindowTitle("NSF Watch for Events whille recording spectra") 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", "NsfWatch45") self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.ObsName = ObsName = "Integrate45" self.ConfigFile = ConfigFile = ObsName+".conf" self._Frequencys_config = ConfigParser.ConfigParser() self._Frequencys_config.read(ConfigFile) try: Frequencys = self._Frequencys_config.getfloat('main', 'Frequency') except: Frequencys = 1420.4e6 self.Frequencys = Frequencys self._Bandwidths_config = ConfigParser.ConfigParser() self._Bandwidths_config.read(ConfigFile) try: Bandwidths = self._Bandwidths_config.getfloat('main', 'Bandwidth') except: Bandwidths = 6.e6 self.Bandwidths = Bandwidths self._telescope_save_config = ConfigParser.ConfigParser() self._telescope_save_config.read(ConfigFile) try: telescope_save = self._telescope_save_config.get('main', 'telescope') except: telescope_save = 'Bubble Wrap Horn' self.telescope_save = telescope_save self._observers_save_config = ConfigParser.ConfigParser() self._observers_save_config.read(ConfigFile) try: observers_save = self._observers_save_config.get('main', 'observers') except: observers_save = 'Science Aficionado' self.observers_save = observers_save self._nAves_config = ConfigParser.ConfigParser() self._nAves_config.read(ConfigFile) try: nAves = self._nAves_config.getint('main', 'nave') except: nAves = 20 self.nAves = nAves self._fftsize_save_config = ConfigParser.ConfigParser() self._fftsize_save_config.read(ConfigFile) try: fftsize_save = self._fftsize_save_config.getint('main', 'fftsize') except: fftsize_save = 1024 self.fftsize_save = fftsize_save self._device_save_config = ConfigParser.ConfigParser() self._device_save_config.read(ConfigFile) try: device_save = self._device_save_config.get('main', 'device') except: device_save = 'airspy,bias=1,pack=1' self.device_save = device_save self._Gain1s_config = ConfigParser.ConfigParser() self._Gain1s_config.read(ConfigFile) try: Gain1s = self._Gain1s_config.getfloat('main', 'gain1') except: Gain1s = 49. self.Gain1s = Gain1s self.Frequency = Frequency = Frequencys self._Elevation_save_config = ConfigParser.ConfigParser() self._Elevation_save_config.read(ConfigFile) try: Elevation_save = self._Elevation_save_config.getfloat('main', 'elevation') except: Elevation_save = 90. self.Elevation_save = Elevation_save self.Bandwidth = Bandwidth = Bandwidths self._Azimuth_save_config = ConfigParser.ConfigParser() self._Azimuth_save_config.read(ConfigFile) try: Azimuth_save = self._Azimuth_save_config.getfloat('main', 'azimuth') except: Azimuth_save = 90. self.Azimuth_save = Azimuth_save self.observer = observer = observers_save self.numin = numin = (Frequency - (Bandwidth/2.)) self.nsigma = nsigma = 5.0 self.nAve = nAve = nAves self.fftsize = fftsize = fftsize_save self.Telescope = Telescope = telescope_save self.Record = Record = 0 self.H1 = H1 = 1420.406E6 self.Gain2 = Gain2 = 12. self.Gain1 = Gain1 = Gain1s self.EventMode = EventMode = 0 self.Elevation = Elevation = Elevation_save self.Device = Device = device_save self.Azimuth = Azimuth = Azimuth_save ################################################## # Blocks ################################################## self._observer_tool_bar = Qt.QToolBar(self) self._observer_tool_bar.addWidget(Qt.QLabel('Who'+": ")) self._observer_line_edit = Qt.QLineEdit(str(self.observer)) self._observer_tool_bar.addWidget(self._observer_line_edit) self._observer_line_edit.returnPressed.connect( lambda: self.set_observer(str(str(self._observer_line_edit.text())))) self.top_grid_layout.addWidget(self._observer_tool_bar, 0, 0, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._nsigma_range = Range(0., 10., .1, 5.0, 100) self._nsigma_win = RangeWidget(self._nsigma_range, self.set_nsigma, 'N Sigma', "counter", float) self.top_grid_layout.addWidget(self._nsigma_win, 2, 5, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 7): self.top_grid_layout.setColumnStretch(c, 1) self._nAve_tool_bar = Qt.QToolBar(self) self._nAve_tool_bar.addWidget(Qt.QLabel('N_Ave.'+": ")) self._nAve_line_edit = Qt.QLineEdit(str(self.nAve)) self._nAve_tool_bar.addWidget(self._nAve_line_edit) self._nAve_line_edit.returnPressed.connect( lambda: self.set_nAve(int(str(self._nAve_line_edit.text())))) self.top_grid_layout.addWidget(self._nAve_tool_bar, 0, 2, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._fftsize_tool_bar = Qt.QToolBar(self) self._fftsize_tool_bar.addWidget(Qt.QLabel('FFT_size'+": ")) self._fftsize_line_edit = Qt.QLineEdit(str(self.fftsize)) self._fftsize_tool_bar.addWidget(self._fftsize_line_edit) self._fftsize_line_edit.returnPressed.connect( lambda: self.set_fftsize(int(str(self._fftsize_line_edit.text())))) self.top_grid_layout.addWidget(self._fftsize_tool_bar, 1, 2, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._Telescope_tool_bar = Qt.QToolBar(self) self._Telescope_tool_bar.addWidget(Qt.QLabel('Tel'+": ")) self._Telescope_line_edit = Qt.QLineEdit(str(self.Telescope)) self._Telescope_tool_bar.addWidget(self._Telescope_line_edit) self._Telescope_line_edit.returnPressed.connect( lambda: self.set_Telescope(str(str(self._Telescope_line_edit.text())))) self.top_grid_layout.addWidget(self._Telescope_tool_bar, 1, 0, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Record_options = (0, 1, ) self._Record_labels = ('! ! Wait ! !', 'AVERAGE', ) self._Record_tool_bar = Qt.QToolBar(self) self._Record_tool_bar.addWidget(Qt.QLabel('Spec. Mode'+": ")) self._Record_combo_box = Qt.QComboBox() self._Record_tool_bar.addWidget(self._Record_combo_box) for label in self._Record_labels: self._Record_combo_box.addItem(label) self._Record_callback = lambda i: Qt.QMetaObject.invokeMethod(self._Record_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._Record_options.index(i))) self._Record_callback(self.Record) self._Record_combo_box.currentIndexChanged.connect( lambda i: self.set_Record(self._Record_options[i])) self.top_grid_layout.addWidget(self._Record_tool_bar, 3, 2, 1, 3) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 5): self.top_grid_layout.setColumnStretch(c, 1) self._Gain1_tool_bar = Qt.QToolBar(self) self._Gain1_tool_bar.addWidget(Qt.QLabel('Gain1'+": ")) self._Gain1_line_edit = Qt.QLineEdit(str(self.Gain1)) self._Gain1_tool_bar.addWidget(self._Gain1_line_edit) self._Gain1_line_edit.returnPressed.connect( lambda: self.set_Gain1(eng_notation.str_to_num(str(self._Gain1_line_edit.text())))) self.top_grid_layout.addWidget(self._Gain1_tool_bar, 3, 0, 1, 2) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Frequency_tool_bar = Qt.QToolBar(self) self._Frequency_tool_bar.addWidget(Qt.QLabel('Freq. Hz'+": ")) self._Frequency_line_edit = Qt.QLineEdit(str(self.Frequency)) self._Frequency_tool_bar.addWidget(self._Frequency_line_edit) self._Frequency_line_edit.returnPressed.connect( lambda: self.set_Frequency(eng_notation.str_to_num(str(self._Frequency_line_edit.text())))) self.top_grid_layout.addWidget(self._Frequency_tool_bar, 0, 5, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 7): self.top_grid_layout.setColumnStretch(c, 1) self._EventMode_options = (0, 1, ) self._EventMode_labels = ('! ! Wait ! !', 'Write', ) self._EventMode_tool_bar = Qt.QToolBar(self) self._EventMode_tool_bar.addWidget(Qt.QLabel('Event Mode'+": ")) self._EventMode_combo_box = Qt.QComboBox() self._EventMode_tool_bar.addWidget(self._EventMode_combo_box) for label in self._EventMode_labels: self._EventMode_combo_box.addItem(label) self._EventMode_callback = lambda i: Qt.QMetaObject.invokeMethod(self._EventMode_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._EventMode_options.index(i))) self._EventMode_callback(self.EventMode) self._EventMode_combo_box.currentIndexChanged.connect( lambda i: self.set_EventMode(self._EventMode_options[i])) self.top_grid_layout.addWidget(self._EventMode_tool_bar, 2, 2, 1, 3) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 5): self.top_grid_layout.setColumnStretch(c, 1) self._Elevation_tool_bar = Qt.QToolBar(self) self._Elevation_tool_bar.addWidget(Qt.QLabel('Elevation'+": ")) self._Elevation_line_edit = Qt.QLineEdit(str(self.Elevation)) self._Elevation_tool_bar.addWidget(self._Elevation_line_edit) self._Elevation_line_edit.returnPressed.connect( lambda: self.set_Elevation(eng_notation.str_to_num(str(self._Elevation_line_edit.text())))) self.top_grid_layout.addWidget(self._Elevation_tool_bar, 1, 7, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 9): self.top_grid_layout.setColumnStretch(c, 1) self._Device_tool_bar = Qt.QToolBar(self) self._Device_tool_bar.addWidget(Qt.QLabel('Dev'+": ")) self._Device_line_edit = Qt.QLineEdit(str(self.Device)) self._Device_tool_bar.addWidget(self._Device_line_edit) self._Device_line_edit.returnPressed.connect( lambda: self.set_Device(str(str(self._Device_line_edit.text())))) self.top_grid_layout.addWidget(self._Device_tool_bar, 2, 0, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Bandwidth_tool_bar = Qt.QToolBar(self) self._Bandwidth_tool_bar.addWidget(Qt.QLabel('Bandwidth'+": ")) self._Bandwidth_line_edit = Qt.QLineEdit(str(self.Bandwidth)) self._Bandwidth_tool_bar.addWidget(self._Bandwidth_line_edit) self._Bandwidth_line_edit.returnPressed.connect( lambda: self.set_Bandwidth(eng_notation.str_to_num(str(self._Bandwidth_line_edit.text())))) self.top_grid_layout.addWidget(self._Bandwidth_tool_bar, 1, 5, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 7): self.top_grid_layout.setColumnStretch(c, 1) self._Azimuth_tool_bar = Qt.QToolBar(self) self._Azimuth_tool_bar.addWidget(Qt.QLabel('Azimuth'+": ")) self._Azimuth_line_edit = Qt.QLineEdit(str(self.Azimuth)) self._Azimuth_tool_bar.addWidget(self._Azimuth_line_edit) self._Azimuth_line_edit.returnPressed.connect( lambda: self.set_Azimuth(eng_notation.str_to_num(str(self._Azimuth_line_edit.text())))) self.top_grid_layout.addWidget(self._Azimuth_tool_bar, 0, 7, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 9): self.top_grid_layout.setColumnStretch(c, 1) self.radio_astro_ra_vmedian_0_1_0 = radio_astro.ra_vmedian(fftsize, 4) self.radio_astro_ra_vmedian_0_1 = radio_astro.ra_vmedian(fftsize, 4) self.radio_astro_ra_vmedian_0_0_0 = radio_astro.ra_vmedian(fftsize, 4) self.radio_astro_ra_vmedian_0_0 = radio_astro.ra_vmedian(fftsize, 4) self.radio_astro_ra_vmedian_0 = radio_astro.ra_vmedian(fftsize, 4) self.radio_astro_ra_event_sink_0 = radio_astro.ra_event_sink(ObsName+"Event.not", fftsize, Frequency*1.E-6, Bandwidth*1.E-6, EventMode, 'Event Detection', 'Observer', Telescope, Device, float(Gain1), Azimuth, Elevation) self.radio_astro_ra_ascii_sink_0 = radio_astro.ra_ascii_sink(ObsName+".not", observer, fftsize, Frequency, Bandwidth, Azimuth, Elevation, Record, 0, 4**5, nAve, telescope_save, device_save, float(Gain1), float(Gain2), float(Gain2)) self.radio_astro_detect_0 = radio_astro.detect(fftsize, nsigma, Frequency, Bandwidth, fftsize*1.e-6/Bandwidth, 2) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_0.set_update_time(1.) self.qtgui_number_sink_0.set_title("") labels = ['T Remains:', '', '', '', '', '', '', '', '', ''] units = ['(s)', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0.) self.qtgui_number_sink_0.set_max(i, nAve * fftsize * 1024. / Bandwidth) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 3, 5, 1, 3) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( fftsize, 100, -.4, .4, "", 2 ) self.qtgui_histogram_sink_x_0.set_update_time(1.) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(False) self.qtgui_histogram_sink_x_0.enable_grid(False) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_histogram_sink_x_0.disable_legend() labels = ['I', 'Q', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark 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_histogram_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win, 4, 0, 1, 5) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 5): self.top_grid_layout.setColumnStretch(c, 1) self.pluto_source_0 = iio.pluto_source('192.168.2.1', int(int(Frequency)), int(int(Bandwidth)), int(20000000), 0x8000, False, False, True, "manual", float(Gain1), '', True) self.fft_vxx_0 = fft.fft_vcc(fftsize, True, (window.hamming(fftsize)), True, 1) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fftsize) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fftsize) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_histogram_sink_x_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.radio_astro_ra_vmedian_0, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.radio_astro_detect_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.pluto_source_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.pluto_source_0, 0), (self.blocks_stream_to_vector_0_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.radio_astro_ra_event_sink_0, 0)) self.connect((self.radio_astro_ra_ascii_sink_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.radio_astro_ra_vmedian_0, 0), (self.radio_astro_ra_vmedian_0_0, 0)) self.connect((self.radio_astro_ra_vmedian_0_0, 0), (self.radio_astro_ra_vmedian_0_1, 0)) self.connect((self.radio_astro_ra_vmedian_0_0_0, 0), (self.radio_astro_ra_vmedian_0_1_0, 0)) self.connect((self.radio_astro_ra_vmedian_0_1, 0), (self.radio_astro_ra_vmedian_0_0_0, 0)) self.connect((self.radio_astro_ra_vmedian_0_1_0, 0), (self.radio_astro_ra_ascii_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Test Signal. Adds a Short pulse in a narrow Band") Qt.QWidget.__init__(self) self.setWindowTitle("Test Signal. Adds a Short pulse in a narrow Band") 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", "NsfPing") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.OffsetMHz = OffsetMHz = 0.111 self.FreqMHz = FreqMHz = 1398 self.samp_rate = samp_rate = 1000 self.nsigma = nsigma = 4.5 self.fftsize = fftsize = 1024 self.Offset = Offset = OffsetMHz*1.E6 self.Mode = Mode = 2 self.H1 = H1 = 1420.406E6 self.Gain1 = Gain1 = 40 self.Frequency = Frequency = FreqMHz*1.E6 self.EventMode = EventMode = 0 self.Bandwidth = Bandwidth = 2e6 self.Attn1 = Attn1 = 80 ################################################## # Blocks ################################################## self._nsigma_range = Range(0., 10., .1, 4.5, 100) self._nsigma_win = RangeWidget(self._nsigma_range, self.set_nsigma, 'N Sigma', "counter", float) self.top_grid_layout.addWidget(self._nsigma_win, 6, 2, 1, 1) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._Mode_options = (0, 2, ) self._Mode_labels = ('Monitor', 'Detect', ) self._Mode_tool_bar = Qt.QToolBar(self) self._Mode_tool_bar.addWidget(Qt.QLabel('Data Mode'+": ")) self._Mode_combo_box = Qt.QComboBox() self._Mode_tool_bar.addWidget(self._Mode_combo_box) for label in self._Mode_labels: self._Mode_combo_box.addItem(label) self._Mode_callback = lambda i: Qt.QMetaObject.invokeMethod(self._Mode_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._Mode_options.index(i))) self._Mode_callback(self.Mode) self._Mode_combo_box.currentIndexChanged.connect( lambda i: self.set_Mode(self._Mode_options[i])) self.top_grid_layout.addWidget(self._Mode_tool_bar, 6, 0, 1, 2) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Gain1_tool_bar = Qt.QToolBar(self) self._Gain1_tool_bar.addWidget(Qt.QLabel('Gain1'+": ")) self._Gain1_line_edit = Qt.QLineEdit(str(self.Gain1)) self._Gain1_tool_bar.addWidget(self._Gain1_line_edit) self._Gain1_line_edit.returnPressed.connect( lambda: self.set_Gain1(eng_notation.str_to_num(str(self._Gain1_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Gain1_tool_bar, 0, 0, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._EventMode_options = (0, 1, ) self._EventMode_labels = ('Wait', 'Write', ) self._EventMode_tool_bar = Qt.QToolBar(self) self._EventMode_tool_bar.addWidget(Qt.QLabel('Write Mode'+": ")) self._EventMode_combo_box = Qt.QComboBox() self._EventMode_tool_bar.addWidget(self._EventMode_combo_box) for label in self._EventMode_labels: self._EventMode_combo_box.addItem(label) self._EventMode_callback = lambda i: Qt.QMetaObject.invokeMethod(self._EventMode_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._EventMode_options.index(i))) self._EventMode_callback(self.EventMode) self._EventMode_combo_box.currentIndexChanged.connect( lambda i: self.set_EventMode(self._EventMode_options[i])) self.top_grid_layout.addWidget(self._EventMode_tool_bar, 5, 0, 1, 2) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Attn1_tool_bar = Qt.QToolBar(self) self._Attn1_tool_bar.addWidget(Qt.QLabel('Attn1'+": ")) self._Attn1_line_edit = Qt.QLineEdit(str(self.Attn1)) self._Attn1_tool_bar.addWidget(self._Attn1_line_edit) self._Attn1_line_edit.returnPressed.connect( lambda: self.set_Attn1(eng_notation.str_to_num(str(self._Attn1_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Attn1_tool_bar, 1, 0, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.radio_astro_ra_event_sink_0 = radio_astro.ra_event_sink('Detect40.not', fftsize, Frequency*1.E-6, Bandwidth, EventMode, 'Event Detection', 'Science Aficionados', 'My Horn', '', Gain1, 0., 90.) self.radio_astro_ra_event_log_0 = radio_astro.ra_event_log('', 'Event Detection', fftsize, Bandwidth) self.radio_astro_detect_0 = radio_astro.detect(fftsize, nsigma, Frequency, Bandwidth, fftsize*1.e-6/Bandwidth, Mode) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( fftsize, #size Bandwidth, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(1) self.qtgui_time_sink_x_0_0.set_y_axis(-.3, .3) self.qtgui_time_sink_x_0_0.set_y_label('Event', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['I', 'Q', '', '', '', '', '', '', '', ''] 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_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 2, 3, 5, 6) for r in range(2, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 9): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( fftsize, 100, -.4, .4, "", 2 ) self.qtgui_histogram_sink_x_0.set_update_time(1.) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(False) self.qtgui_histogram_sink_x_0.enable_grid(False) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_histogram_sink_x_0.disable_legend() labels = ['I', 'Q', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark 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_histogram_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win, 2, 0, 3, 2) for r in range(2, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.pluto_sink_0 = iio.pluto_sink('', int(float(Frequency+Offset)), int(float(Bandwidth)), int(20000000), 0x8000, False, float(Attn1), '', True) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, fftsize) self.blocks_threshold_ff_0 = blocks.threshold_ff(.999999, 1., 1.) (self.blocks_threshold_ff_0).set_max_output_buffer(1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fftsize) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vff((10, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.2, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_SAW_WAVE, .0002, 1.00001, 0) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, .15, 0) self.Ping = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.Ping.set_update_time(0.5) self.Ping.set_title("Ramp") labels = ['Ping', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.Ping.set_min(i, 0.) self.Ping.set_max(i, 1) self.Ping.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.Ping.set_label(i, "Data {0}".format(i)) else: self.Ping.set_label(i, labels[i]) self.Ping.set_unit(i, units[i]) self.Ping.set_factor(i, factor[i]) self.Ping.enable_autoscale(False) self._Ping_win = sip.wrapinstance(self.Ping.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._Ping_win, 0, 4, 2, 5) for r in range(0, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 9): self.top_grid_layout.setColumnStretch(c, 1) self._OffsetMHz_tool_bar = Qt.QToolBar(self) self._OffsetMHz_tool_bar.addWidget(Qt.QLabel('OffsetMHz)'+": ")) self._OffsetMHz_line_edit = Qt.QLineEdit(str(self.OffsetMHz)) self._OffsetMHz_tool_bar.addWidget(self._OffsetMHz_line_edit) self._OffsetMHz_line_edit.returnPressed.connect( lambda: self.set_OffsetMHz(eng_notation.str_to_num(str(self._OffsetMHz_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._OffsetMHz_tool_bar, 1, 2, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._FreqMHz_tool_bar = Qt.QToolBar(self) self._FreqMHz_tool_bar.addWidget(Qt.QLabel('Freq (MHz)'+": ")) self._FreqMHz_line_edit = Qt.QLineEdit(str(self.FreqMHz)) self._FreqMHz_tool_bar.addWidget(self._FreqMHz_line_edit) self._FreqMHz_line_edit.returnPressed.connect( lambda: self.set_FreqMHz(eng_notation.str_to_num(str(self._FreqMHz_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._FreqMHz_tool_bar, 0, 2, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.Ping, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_histogram_sink_x_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.pluto_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.radio_astro_detect_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_multiply_const_vxx_0_1, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.radio_astro_ra_event_log_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.radio_astro_ra_event_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Nsf Airspy Event Detect: 6MHz") Qt.QWidget.__init__(self) self.setWindowTitle("Nsf Airspy Event Detect: 6MHz") 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", "NsfDetect60airspy") 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.observer = observer = 'observers_save' self.nsigma = nsigma = 5.0 self.fftsize = fftsize = 8192 self.Telescope = Telescope = 'telescope_save' self.Mode = Mode = 2 self.Gain1 = Gain1 = 14.0 self.Frequency = Frequency = 1420.4 self.EventMode = EventMode = 0 self.Elevation = Elevation = -90 self.Device = Device = 'airspy,bias=1,pack=1' self.Bandwidth = Bandwidth = 6. self.Azimuth = Azimuth = 0 ################################################## # Blocks ################################################## self._nsigma_range = Range(0., 10., .1, 5.0, 100) self._nsigma_win = RangeWidget(self._nsigma_range, self.set_nsigma, 'N Sigma', "counter", float) self.top_grid_layout.addWidget(self._nsigma_win, 0, 3, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(3, 4)] self._fftsize_tool_bar = Qt.QToolBar(self) self._fftsize_tool_bar.addWidget(Qt.QLabel('Window_size' + ": ")) self._fftsize_line_edit = Qt.QLineEdit(str(self.fftsize)) self._fftsize_tool_bar.addWidget(self._fftsize_line_edit) self._fftsize_line_edit.returnPressed.connect(lambda: self.set_fftsize( int(str(self._fftsize_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._fftsize_tool_bar, 1, 3, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(3, 4)] self._Mode_options = ( 1, 2, ) self._Mode_labels = ( 'Monitor', 'Detect', ) self._Mode_tool_bar = Qt.QToolBar(self) self._Mode_tool_bar.addWidget(Qt.QLabel('Mode' + ": ")) self._Mode_combo_box = Qt.QComboBox() self._Mode_tool_bar.addWidget(self._Mode_combo_box) for label in self._Mode_labels: self._Mode_combo_box.addItem(label) self._Mode_callback = lambda i: Qt.QMetaObject.invokeMethod( self._Mode_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._Mode_options.index(i))) self._Mode_callback(self.Mode) self._Mode_combo_box.currentIndexChanged.connect( lambda i: self.set_Mode(self._Mode_options[i])) self.top_grid_layout.addWidget(self._Mode_tool_bar, 7, 0, 2, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(7, 9)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)] self._Gain1_tool_bar = Qt.QToolBar(self) self._Gain1_tool_bar.addWidget(Qt.QLabel('Gain1' + ": ")) self._Gain1_line_edit = Qt.QLineEdit(str(self.Gain1)) self._Gain1_tool_bar.addWidget(self._Gain1_line_edit) self._Gain1_line_edit.returnPressed.connect(lambda: self.set_Gain1( eng_notation.str_to_num(str(self._Gain1_line_edit.text().toAscii()) ))) self.top_grid_layout.addWidget(self._Gain1_tool_bar, 3, 0, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(3, 4)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)] self._Frequency_tool_bar = Qt.QToolBar(self) self._Frequency_tool_bar.addWidget(Qt.QLabel('Freq. (MHz)' + ": ")) self._Frequency_line_edit = Qt.QLineEdit(str(self.Frequency)) self._Frequency_tool_bar.addWidget(self._Frequency_line_edit) self._Frequency_line_edit.returnPressed.connect( lambda: self.set_Frequency( eng_notation.str_to_num( str(self._Frequency_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Frequency_tool_bar, 1, 5, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(5, 6)] self._EventMode_options = ( 0, 1, ) self._EventMode_labels = ( 'Wait', 'Write', ) self._EventMode_tool_bar = Qt.QToolBar(self) self._EventMode_tool_bar.addWidget(Qt.QLabel('Event Mode' + ": ")) self._EventMode_combo_box = Qt.QComboBox() self._EventMode_tool_bar.addWidget(self._EventMode_combo_box) for label in self._EventMode_labels: self._EventMode_combo_box.addItem(label) self._EventMode_callback = lambda i: Qt.QMetaObject.invokeMethod( self._EventMode_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._EventMode_options.index(i))) self._EventMode_callback(self.EventMode) self._EventMode_combo_box.currentIndexChanged.connect( lambda i: self.set_EventMode(self._EventMode_options[i])) self.top_grid_layout.addWidget(self._EventMode_tool_bar, 5, 0, 2, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(5, 7)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)] self._Device_tool_bar = Qt.QToolBar(self) self._Device_tool_bar.addWidget(Qt.QLabel('Dev' + ": ")) self._Device_line_edit = Qt.QLineEdit(str(self.Device)) self._Device_tool_bar.addWidget(self._Device_line_edit) self._Device_line_edit.returnPressed.connect(lambda: self.set_Device( str(str(self._Device_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Device_tool_bar, 2, 0, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)] self._Bandwidth_tool_bar = Qt.QToolBar(self) self._Bandwidth_tool_bar.addWidget(Qt.QLabel('Band. (MHz)' + ": ")) self._Bandwidth_line_edit = Qt.QLineEdit(str(self.Bandwidth)) self._Bandwidth_tool_bar.addWidget(self._Bandwidth_line_edit) self._Bandwidth_line_edit.returnPressed.connect( lambda: self.set_Bandwidth( eng_notation.str_to_num( str(self._Bandwidth_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Bandwidth_tool_bar, 1, 6, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(6, 7)] self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + Device) self.rtlsdr_source_0.set_sample_rate(Bandwidth * 1e6) self.rtlsdr_source_0.set_center_freq(Frequency * 1e6, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(Gain1, 0) self.rtlsdr_source_0.set_if_gain(12, 0) self.rtlsdr_source_0.set_bb_gain(12, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(Bandwidth, 0) (self.rtlsdr_source_0).set_processor_affinity([3]) self.radio_astro_detect_0 = radio_astro.detect( fftsize, nsigma, Frequency, Bandwidth, fftsize * 1.e-6 / Bandwidth, Mode) self.ra_event_sink_0 = ra_event_sink.ra_event_sink( 'Watch.not', fftsize, Bandwidth, EventMode) self.ra_event_log_0 = ra_event_log.ra_event_log( '', 'First Airspy Overnight event test', fftsize, Bandwidth) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( fftsize, #size Bandwidth, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(1) self.qtgui_time_sink_x_0_0.set_y_axis(-.3, .3) self.qtgui_time_sink_x_0_0.set_y_label('Event', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['I', 'Q', '', '', '', '', '', '', '', ''] 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_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 2, 3, 10, 5) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 12)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(3, 8)] self._observer_tool_bar = Qt.QToolBar(self) self._observer_tool_bar.addWidget(Qt.QLabel('Who' + ": ")) self._observer_line_edit = Qt.QLineEdit(str(self.observer)) self._observer_tool_bar.addWidget(self._observer_line_edit) self._observer_line_edit.returnPressed.connect( lambda: self.set_observer( str(str(self._observer_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._observer_tool_bar, 0, 0, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)] self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, fftsize) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, fftsize) self._Telescope_tool_bar = Qt.QToolBar(self) self._Telescope_tool_bar.addWidget(Qt.QLabel('Tel' + ": ")) self._Telescope_line_edit = Qt.QLineEdit(str(self.Telescope)) self._Telescope_tool_bar.addWidget(self._Telescope_line_edit) self._Telescope_line_edit.returnPressed.connect( lambda: self.set_Telescope( str(str(self._Telescope_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Telescope_tool_bar, 1, 0, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)] self._Elevation_tool_bar = Qt.QToolBar(self) self._Elevation_tool_bar.addWidget(Qt.QLabel('Elevation' + ": ")) self._Elevation_line_edit = Qt.QLineEdit(str(self.Elevation)) self._Elevation_tool_bar.addWidget(self._Elevation_line_edit) self._Elevation_line_edit.returnPressed.connect( lambda: self.set_Elevation( eng_notation.str_to_num( str(self._Elevation_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Elevation_tool_bar, 0, 6, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(6, 7)] self._Azimuth_tool_bar = Qt.QToolBar(self) self._Azimuth_tool_bar.addWidget(Qt.QLabel('Azimuth' + ": ")) self._Azimuth_line_edit = Qt.QLineEdit(str(self.Azimuth)) self._Azimuth_tool_bar.addWidget(self._Azimuth_line_edit) self._Azimuth_line_edit.returnPressed.connect(lambda: self.set_Azimuth( eng_notation.str_to_num( str(self._Azimuth_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Azimuth_tool_bar, 0, 5, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(5, 6)] ################################################## # Connections ################################################## self.connect((self.blocks_stream_to_vector_0, 0), (self.radio_astro_detect_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.ra_event_log_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.ra_event_sink_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0, 0))
def __init__(self): gr.top_block.__init__(self, "Nsf PlutoSdr Event Detect: 4.5MHz") Qt.QWidget.__init__(self) self.setWindowTitle("Nsf PlutoSdr Event Detect: 4.5MHz") 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", "NsfDetect45") 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.ObsName = ObsName = "Detect45" self.ConfigFile = ConfigFile = ObsName+".conf" self._telescope_save_config = ConfigParser.ConfigParser() self._telescope_save_config.read(ConfigFile) try: telescope_save = self._telescope_save_config.get('main', 'telescope') except: telescope_save = 'My Horn' self.telescope_save = telescope_save self._observer_save_config = ConfigParser.ConfigParser() self._observer_save_config.read(ConfigFile) try: observer_save = self._observer_save_config.get('main', 'observer') except: observer_save = 'Science Aficionado' self.observer_save = observer_save self._fftsize_save_config = ConfigParser.ConfigParser() self._fftsize_save_config.read(ConfigFile) try: fftsize_save = self._fftsize_save_config.getint('main', 'samplesize') except: fftsize_save = 1024 self.fftsize_save = fftsize_save self._device_save_config = ConfigParser.ConfigParser() self._device_save_config.read(ConfigFile) try: device_save = self._device_save_config.get('main', 'device') except: device_save = '192.168.2.1' self.device_save = device_save self._Gain1s_config = ConfigParser.ConfigParser() self._Gain1s_config.read(ConfigFile) try: Gain1s = self._Gain1s_config.getfloat('main', 'gain1') except: Gain1s = 49. self.Gain1s = Gain1s self._Frequencys_config = ConfigParser.ConfigParser() self._Frequencys_config.read(ConfigFile) try: Frequencys = self._Frequencys_config.getfloat('main', 'frequency') except: Frequencys = 1420.4e6 self.Frequencys = Frequencys self._Elevation_save_config = ConfigParser.ConfigParser() self._Elevation_save_config.read(ConfigFile) try: Elevation_save = self._Elevation_save_config.getfloat('main', 'elevation') except: Elevation_save = 90. self.Elevation_save = Elevation_save self._Bandwidths_config = ConfigParser.ConfigParser() self._Bandwidths_config.read(ConfigFile) try: Bandwidths = self._Bandwidths_config.getfloat('main', 'bandwidth') except: Bandwidths = 4.5e6 self.Bandwidths = Bandwidths self._Azimuth_save_config = ConfigParser.ConfigParser() self._Azimuth_save_config.read(ConfigFile) try: Azimuth_save = self._Azimuth_save_config.getfloat('main', 'azimuth') except: Azimuth_save = 180. self.Azimuth_save = Azimuth_save self.nsigma = nsigma = 5.0 self.fftsize = fftsize = fftsize_save self.Telescope = Telescope = telescope_save self.Observer = Observer = observer_save self.Mode = Mode = 2 self.Gain1 = Gain1 = Gain1s self.Frequency = Frequency = Frequencys self.EventMode = EventMode = 0 self.Elevation = Elevation = Elevation_save self.Device = Device = device_save self.Bandwidth = Bandwidth = Bandwidths self.Azimuth = Azimuth = Azimuth_save ################################################## # Blocks ################################################## self._nsigma_range = Range(0., 10., .1, 5.0, 100) self._nsigma_win = RangeWidget(self._nsigma_range, self.set_nsigma, 'N Sigma', "counter", float) self.top_grid_layout.addWidget(self._nsigma_win, 7, 0, 1, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(7,8)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,2)] self._fftsize_tool_bar = Qt.QToolBar(self) self._fftsize_tool_bar.addWidget(Qt.QLabel('Sample_Size'+": ")) self._fftsize_line_edit = Qt.QLineEdit(str(self.fftsize)) self._fftsize_tool_bar.addWidget(self._fftsize_line_edit) self._fftsize_line_edit.returnPressed.connect( lambda: self.set_fftsize(int(str(self._fftsize_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._fftsize_tool_bar, 1, 2, 1, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(1,2)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(2,4)] self._Telescope_tool_bar = Qt.QToolBar(self) self._Telescope_tool_bar.addWidget(Qt.QLabel('Tel'+": ")) self._Telescope_line_edit = Qt.QLineEdit(str(self.Telescope)) self._Telescope_tool_bar.addWidget(self._Telescope_line_edit) self._Telescope_line_edit.returnPressed.connect( lambda: self.set_Telescope(str(str(self._Telescope_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Telescope_tool_bar, 1, 0, 1, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(1,2)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,2)] self._Observer_tool_bar = Qt.QToolBar(self) self._Observer_tool_bar.addWidget(Qt.QLabel('Who'+": ")) self._Observer_line_edit = Qt.QLineEdit(str(self.Observer)) self._Observer_tool_bar.addWidget(self._Observer_line_edit) self._Observer_line_edit.returnPressed.connect( lambda: self.set_Observer(str(str(self._Observer_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Observer_tool_bar, 0, 0, 1, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(0,1)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,2)] self._Mode_options = (0, 2, ) self._Mode_labels = ('Monitor', 'Detect', ) self._Mode_tool_bar = Qt.QToolBar(self) self._Mode_tool_bar.addWidget(Qt.QLabel('Data Mode'+": ")) self._Mode_combo_box = Qt.QComboBox() self._Mode_tool_bar.addWidget(self._Mode_combo_box) for label in self._Mode_labels: self._Mode_combo_box.addItem(label) self._Mode_callback = lambda i: Qt.QMetaObject.invokeMethod(self._Mode_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._Mode_options.index(i))) self._Mode_callback(self.Mode) self._Mode_combo_box.currentIndexChanged.connect( lambda i: self.set_Mode(self._Mode_options[i])) self.top_grid_layout.addWidget(self._Mode_tool_bar, 6, 0, 1, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(6,7)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,2)] self._Gain1_tool_bar = Qt.QToolBar(self) self._Gain1_tool_bar.addWidget(Qt.QLabel('Gain1'+": ")) self._Gain1_line_edit = Qt.QLineEdit(str(self.Gain1)) self._Gain1_tool_bar.addWidget(self._Gain1_line_edit) self._Gain1_line_edit.returnPressed.connect( lambda: self.set_Gain1(eng_notation.str_to_num(str(self._Gain1_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Gain1_tool_bar, 0, 2, 1, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(0,1)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(2,4)] self._Frequency_tool_bar = Qt.QToolBar(self) self._Frequency_tool_bar.addWidget(Qt.QLabel('Freq. Hz'+": ")) self._Frequency_line_edit = Qt.QLineEdit(str(self.Frequency)) self._Frequency_tool_bar.addWidget(self._Frequency_line_edit) self._Frequency_line_edit.returnPressed.connect( lambda: self.set_Frequency(eng_notation.str_to_num(str(self._Frequency_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Frequency_tool_bar, 0, 5, 1, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(0,1)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(5,7)] self._EventMode_options = (0, 1, ) self._EventMode_labels = ('Wait', 'Write', ) self._EventMode_tool_bar = Qt.QToolBar(self) self._EventMode_tool_bar.addWidget(Qt.QLabel('Write Mode'+": ")) self._EventMode_combo_box = Qt.QComboBox() self._EventMode_tool_bar.addWidget(self._EventMode_combo_box) for label in self._EventMode_labels: self._EventMode_combo_box.addItem(label) self._EventMode_callback = lambda i: Qt.QMetaObject.invokeMethod(self._EventMode_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._EventMode_options.index(i))) self._EventMode_callback(self.EventMode) self._EventMode_combo_box.currentIndexChanged.connect( lambda i: self.set_EventMode(self._EventMode_options[i])) self.top_grid_layout.addWidget(self._EventMode_tool_bar, 5, 0, 1, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(5,6)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,2)] self._Elevation_tool_bar = Qt.QToolBar(self) self._Elevation_tool_bar.addWidget(Qt.QLabel('Elevation'+": ")) self._Elevation_line_edit = Qt.QLineEdit(str(self.Elevation)) self._Elevation_tool_bar.addWidget(self._Elevation_line_edit) self._Elevation_line_edit.returnPressed.connect( lambda: self.set_Elevation(eng_notation.str_to_num(str(self._Elevation_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Elevation_tool_bar, 1, 7, 1, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(1,2)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(7,9)] self._Device_tool_bar = Qt.QToolBar(self) self._Device_tool_bar.addWidget(Qt.QLabel('Dev'+": ")) self._Device_line_edit = Qt.QLineEdit(str(self.Device)) self._Device_tool_bar.addWidget(self._Device_line_edit) self._Device_line_edit.returnPressed.connect( lambda: self.set_Device(str(str(self._Device_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Device_tool_bar, 2, 0, 1, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(2,3)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,2)] self._Bandwidth_tool_bar = Qt.QToolBar(self) self._Bandwidth_tool_bar.addWidget(Qt.QLabel('Bandwidth'+": ")) self._Bandwidth_line_edit = Qt.QLineEdit(str(self.Bandwidth)) self._Bandwidth_tool_bar.addWidget(self._Bandwidth_line_edit) self._Bandwidth_line_edit.returnPressed.connect( lambda: self.set_Bandwidth(eng_notation.str_to_num(str(self._Bandwidth_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Bandwidth_tool_bar, 1, 5, 1, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(1,2)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(5,7)] self._Azimuth_tool_bar = Qt.QToolBar(self) self._Azimuth_tool_bar.addWidget(Qt.QLabel('Azimuth'+": ")) self._Azimuth_line_edit = Qt.QLineEdit(str(self.Azimuth)) self._Azimuth_tool_bar.addWidget(self._Azimuth_line_edit) self._Azimuth_line_edit.returnPressed.connect( lambda: self.set_Azimuth(eng_notation.str_to_num(str(self._Azimuth_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Azimuth_tool_bar, 0, 7, 1, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(0,1)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(7,9)] self.radio_astro_ra_event_sink_0 = radio_astro.ra_event_sink(ObsName+".not", fftsize, Frequency*1.E-6, Bandwidth*1.E-6, EventMode, 'Event Detection', Observer, Telescope, Device, float(Gain1), Azimuth, Elevation) self.radio_astro_detect_0 = radio_astro.detect(fftsize, nsigma, Frequency, Bandwidth, fftsize*1.e-6/Bandwidth, Mode) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( fftsize, #size Bandwidth, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(1) self.qtgui_time_sink_x_0_0.set_y_axis(-.3, .3) self.qtgui_time_sink_x_0_0.set_y_label('Event', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['I', 'Q', '', '', '', '', '', '', '', ''] 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_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 3, 2, 5, 7) [self.top_grid_layout.setRowStretch(r,1) for r in range(3,8)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(2,9)] self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( fftsize, 100, -.5, .5, "", 2 ) self.qtgui_histogram_sink_x_0.set_update_time(1) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(False) self.qtgui_histogram_sink_x_0.enable_grid(False) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_histogram_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", "dark 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_histogram_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win, 3, 0, 2, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(3,5)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,2)] self.pluto_source_0 = iio.pluto_source('192.168.2.1', int(int(Frequency)), int(int(Bandwidth)), int(20000000), 0x8000, False, False, True, "manual", float(Gain1), '', True) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, fftsize) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fftsize) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_histogram_sink_x_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.radio_astro_detect_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.pluto_source_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.pluto_source_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.radio_astro_ra_event_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "NSF Airspy 10 MHz - No Gui") ################################################## # Variables ################################################## self.ObsName = ObsName = "Integrate100" self.ConfigFile = ConfigFile = ObsName+".conf" self._telescope_save_config = ConfigParser.ConfigParser() self._telescope_save_config.read(ConfigFile) try: telescope_save = self._telescope_save_config.get('main', 'telescope') except: telescope_save = 'Bubble Wrap Horn' self.telescope_save = telescope_save self._observers_save_config = ConfigParser.ConfigParser() self._observers_save_config.read(ConfigFile) try: observers_save = self._observers_save_config.get('main', 'observers') except: observers_save = 'Science Aficionado' self.observers_save = observers_save self._nsigmas_config = ConfigParser.ConfigParser() self._nsigmas_config.read(ConfigFile) try: nsigmas = self._nsigmas_config.getfloat('main', 'nsigma') except: nsigmas = 5.5 self.nsigmas = nsigmas self._nAves_config = ConfigParser.ConfigParser() self._nAves_config.read(ConfigFile) try: nAves = self._nAves_config.getint('main', 'nave') except: nAves = 20 self.nAves = nAves self._fftsize_save_config = ConfigParser.ConfigParser() self._fftsize_save_config.read(ConfigFile) try: fftsize_save = self._fftsize_save_config.getint('main', 'fftsize') except: fftsize_save = 1024 self.fftsize_save = fftsize_save self._device_save_config = ConfigParser.ConfigParser() self._device_save_config.read(ConfigFile) try: device_save = self._device_save_config.get('main', 'device') except: device_save = 'airspy,bias=1,pack=1' self.device_save = device_save self._Gain3s_config = ConfigParser.ConfigParser() self._Gain3s_config.read(ConfigFile) try: Gain3s = self._Gain3s_config.getfloat('main', 'gain3') except: Gain3s = 13 self.Gain3s = Gain3s self._Gain2s_config = ConfigParser.ConfigParser() self._Gain2s_config.read(ConfigFile) try: Gain2s = self._Gain2s_config.getfloat('main', 'gain2') except: Gain2s = 12 self.Gain2s = Gain2s self._Gain1s_config = ConfigParser.ConfigParser() self._Gain1s_config.read(ConfigFile) try: Gain1s = self._Gain1s_config.getfloat('main', 'gain1') except: Gain1s = 14. self.Gain1s = Gain1s self._Frequencys_config = ConfigParser.ConfigParser() self._Frequencys_config.read(ConfigFile) try: Frequencys = self._Frequencys_config.getfloat('main', 'Frequency') except: Frequencys = 1420.4e6 self.Frequencys = Frequencys self._Elevation_save_config = ConfigParser.ConfigParser() self._Elevation_save_config.read(ConfigFile) try: Elevation_save = self._Elevation_save_config.getfloat('main', 'elevation') except: Elevation_save = 90. self.Elevation_save = Elevation_save self._Bandwidths_config = ConfigParser.ConfigParser() self._Bandwidths_config.read(ConfigFile) try: Bandwidths = self._Bandwidths_config.getfloat('main', 'Bandwidth') except: Bandwidths = 10.e6 self.Bandwidths = Bandwidths self._Azimuth_save_config = ConfigParser.ConfigParser() self._Azimuth_save_config.read(ConfigFile) try: Azimuth_save = self._Azimuth_save_config.getfloat('main', 'azimuth') except: Azimuth_save = 90. self.Azimuth_save = Azimuth_save self.observer = observer = observers_save self.nsigma = nsigma = nsigmas self.nAve = nAve = nAves self.fftsize = fftsize = fftsize_save self.Telescope = Telescope = telescope_save self.Record = Record = 1 self.Gain3 = Gain3 = Gain3s self.Gain2 = Gain2 = Gain2s self.Gain1 = Gain1 = Gain1s self.Frequency = Frequency = Frequencys self.EventMode = EventMode = 1 self.Elevation = Elevation = Elevation_save self.Device = Device = device_save self.Bandwidth = Bandwidth = Bandwidths self.Azimuth = Azimuth = Azimuth_save ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + Device ) self.rtlsdr_source_0.set_sample_rate(Bandwidth) self.rtlsdr_source_0.set_center_freq(Frequency, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(float(Gain1), 0) self.rtlsdr_source_0.set_if_gain(float(Gain2), 0) self.rtlsdr_source_0.set_bb_gain(float(Gain2), 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(Bandwidth, 0) (self.rtlsdr_source_0).set_processor_affinity([3]) self.radio_astro_vmedian_0_0_1_0 = radio_astro.vmedian(fftsize, 4) self.radio_astro_vmedian_0_0_1 = radio_astro.vmedian(fftsize, 4) self.radio_astro_vmedian_0_0_0 = radio_astro.vmedian(fftsize, 4) self.radio_astro_vmedian_0_0 = radio_astro.vmedian(fftsize, 4) self.radio_astro_vmedian_0 = radio_astro.vmedian(fftsize, 4) self.radio_astro_ra_event_sink_0 = radio_astro.ra_event_sink(ObsName+"Event.not", 2*fftsize, Frequency*1.E-6, Bandwidth*1.E-6, EventMode, 'Event Detection', 'Observer', Telescope, Device, float(Gain1), Azimuth, Elevation) self.radio_astro_ra_event_log_0 = radio_astro.ra_event_log('', 'Event Detection', 2*fftsize, Bandwidth*1.e-6) self.radio_astro_ra_ascii_sink_0 = radio_astro.ra_ascii_sink(ObsName+".not", observer, fftsize, Frequency, Bandwidth, Azimuth, Elevation, Record, 0, 4**5, nAve, telescope_save, device_save, float(Gain1), float(Gain2), float(Gain3)) self.radio_astro_detect_0 = radio_astro.detect(2*fftsize, nsigma, Frequency, Bandwidth, fftsize*1.e-6/Bandwidth, 2) self.fft_vxx_0 = fft.fft_vcc(fftsize, True, (window.hamming(fftsize)), True, 1) self.blocks_stream_to_vector_0_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 2*fftsize) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fftsize) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fftsize) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.radio_astro_vmedian_0_0_1, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_0_0_0, 0), (self.radio_astro_detect_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.radio_astro_ra_event_log_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.radio_astro_ra_event_sink_0, 0)) self.connect((self.radio_astro_ra_ascii_sink_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.radio_astro_vmedian_0, 0), (self.radio_astro_ra_ascii_sink_0, 0)) self.connect((self.radio_astro_vmedian_0_0, 0), (self.radio_astro_vmedian_0, 0)) self.connect((self.radio_astro_vmedian_0_0_0, 0), (self.radio_astro_vmedian_0_0, 0)) self.connect((self.radio_astro_vmedian_0_0_1, 0), (self.radio_astro_vmedian_0_0_1_0, 0)) self.connect((self.radio_astro_vmedian_0_0_1_0, 0), (self.radio_astro_vmedian_0_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0_0_0, 0))