예제 #1
0
파일: qa_max.py 프로젝트: 232675/gnuradio
    def test_002(self):
	src_data=(-100,-99,-98,-97,-96,-1)
	expected_result = (float(max(src_data)),)

	src = blocks.vector_source_f(src_data)
	s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data))
	op = blocks.max_ff(len(src_data))
	dst = blocks.vector_sink_f()

	self.tb.connect(src, s2v, op, dst)
	self.tb.run()
	result_data = dst.data()
	self.assertEqual(expected_result, result_data)
    def __init__(self, ts, factor, alpha, samp_rate, freqs):
        gr.hier_block2.__init__(
            self, "freq_timing_estimator_hier",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.ts = ts
        self.factor = factor
        self.alpha = alpha
        self.samp_rate = samp_rate
        self.freqs = freqs
        self.n = n = len(freqs)

        ##################################################
        # Blocks
        ##################################################
        self._filter=[0]*self.n
        self._c2mag2=[0]*self.n
        for i in range(self.n):
          self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, (numpy.conjugate(self.ts[::-1])), self.freqs[i], self.samp_rate)
          self._c2mag2[i] = blocks.complex_to_mag_squared(1)

        self.blocks_max = blocks.max_ff(1)
        self.blocks_peak_detector = blocks.peak_detector_fb(self.factor, self.factor, 0, self.alpha)

        self.blocks_argmax = blocks.argmax_fs(1)
        self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1)
        self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1)
        self.blocks_sample_and_hold = blocks.sample_and_hold_ff()

        ##################################################
        # Connections
        ##################################################
        for i in range(self.n):
          self.connect((self, 0), (self._filter[i], 0))
          self.connect((self._filter[i], 0), (self._c2mag2[i], 0))
          self.connect((self._c2mag2[i], 0), (self.blocks_max, i))
          self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i))
        self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0))
        self.connect((self.blocks_peak_detector, 0), (self, 0))
        self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0))
        self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0))
        self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0))
        self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1))
        self.connect((self.blocks_sample_and_hold, 0), (self, 1))
        self.connect((self.blocks_max, 0), (self, 2))
예제 #3
0
    def test_001(self):
        src_data = [0, 0.2, -0.3, 0, 12, 0]
        expected_result = [
            float(max(src_data)),
        ]

        src = blocks.vector_source_f(src_data)
        s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data))
        op = blocks.max_ff(len(src_data))
        dst = blocks.vector_sink_f()

        self.tb.connect(src, s2v, op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
예제 #4
0
    def stest_002(self):
        src_data = [-100, -99, -98, -97, -96, -1]
        expected_result = [
            float(max(src_data)),
        ]

        src = blocks.vector_source_f(src_data)
        s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data))
        op = blocks.max_ff(len(src_data))
        dst = blocks.vector_sink_f()

        self.tb.connect(src, s2v, op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
예제 #5
0
    def set_window_and_reconnect(self, window):
        '''
        Must be called while the flowgraph is locked already.
        '''
        window = int(window)
        self.disconnect_all()
        self.__sink = blocks.probe_signal_f()
        self.connect(
            self, blocks.complex_to_mag_squared(),
            blocks.stream_to_vector(itemsize=gr.sizeof_float,
                                    nitems_per_block=window),
            blocks.max_ff(window), self.__sink)

        # shortcut method implementation
        self.level = self.__sink.level
예제 #6
0
    def set_window_and_reconnect(self, window):
        """
        Must be called while the flowgraph is locked already.
        """
        # Use a power-of-2 window size to satisfy gnuradio allocation alignment without going overboard.
        window = int(2**math.floor(math.log(window, 2)))
        self.disconnect_all()
        self.__sink = blocks.probe_signal_f()
        self.connect(
            self, blocks.complex_to_mag_squared(),
            blocks.stream_to_vector(itemsize=gr.sizeof_float,
                                    nitems_per_block=window),
            blocks.max_ff(window), self.__sink)

        # shortcut method implementation
        self.level = self.__sink.level
예제 #7
0
파일: top.py 프로젝트: shadown/shinysdr
	def set_window_and_reconnect(self, window):
		'''
		Must be called while the flowgraph is locked already.
		'''
		window = int(window)
		self.disconnect_all()
		self.__sink = blocks.probe_signal_f()
		self.connect(
			self,
			blocks.complex_to_mag_squared(),
			blocks.stream_to_vector(itemsize=gr.sizeof_float, nitems_per_block=window),
			blocks.max_ff(window),
			self.__sink)
		
		# shortcut method implementation
		self.level = self.__sink.level
예제 #8
0
파일: top.py 프로젝트: nunb/shinysdr
 def set_window_and_reconnect(self, window):
     '''
     Must be called while the flowgraph is locked already.
     '''
     # Use a power-of-2 window size to satisfy gnuradio allocation alignment without going overboard.
     window = int(2 ** math.floor(math.log(window, 2)))
     self.disconnect_all()
     self.__sink = blocks.probe_signal_f()
     self.connect(
         self,
         blocks.complex_to_mag_squared(),
         blocks.stream_to_vector(itemsize=gr.sizeof_float, nitems_per_block=window),
         blocks.max_ff(window),
         self.__sink)
     
     # shortcut method implementation
     self.level = self.__sink.level
예제 #9
0
    def stest_003(self):
        src_data0 = (0, 2, -3, 0, 12, 0)
        src_data1 = (1, 1,  1, 1,  1, 1)

        expected_result = [float(max(x,y)) for x,y in zip(src_data0, src_data1)]

        src0 = blocks.vector_source_f(src_data0)
        src1 = blocks.vector_source_f(src_data1)
        op = blocks.max_ff(1)
        dst = blocks.vector_sink_f()

        self.tb.connect(src0, (op, 0))
        self.tb.connect(src1, (op, 1))
        self.tb.connect(op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
예제 #10
0
파일: qa_max.py 프로젝트: danbar/gnuradio
    def stest_003(self):
        src_data0 = (0, 2, -3, 0, 12, 0)
        src_data1 = (1, 1,  1, 1,  1, 1)

        expected_result = [float(max(x,y)) for x,y in zip(src_data0, src_data1)]

        src0 = blocks.vector_source_f(src_data0)
        src1 = blocks.vector_source_f(src_data1)
        op = blocks.max_ff(1)
        dst = blocks.vector_sink_f()

        self.tb.connect(src0, (op, 0))
        self.tb.connect(src1, (op, 1))
        self.tb.connect(op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
예제 #11
0
    def __init__(self, preamble_length):
        gr.hier_block2.__init__(self, "burstsilence_corr",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(2, 2, gr.sizeof_gr_complex))

        half_length = int(preamble_length) / 2

        # Blocks
        self.equiv_delay = blocks.delay(gr.sizeof_gr_complex, preamble_length)

        self.to_power = blocks.complex_to_mag_squared(1)
        self.pw_delay = blocks.delay(gr.sizeof_float, half_length)
        self.sub_sigref = blocks.sub_ff(1)
        self.avg = blocks.moving_average_ff(half_length, 1, 4096)

        self.null_src = blocks.null_source(gr.sizeof_float)
        self.clamp = blocks.max_ff(1, 1)
        self.to_complex = blocks.float_to_complex(1)

        # Connections
        self.connect((self, 0), (self.to_power, 0))
        self.connect((self, 0), (self.equiv_delay, 0))

        self.connect((self.to_power, 0), (self.pw_delay, 0))
        self.connect((self.to_power, 0), (self.sub_sigref, 1))

        self.connect((self.pw_delay, 0), (self.sub_sigref, 0))

        self.connect((self.sub_sigref, 0), (self.avg, 0))

        self.connect((self.avg, 0), (self.clamp, 0))
        self.connect((self.null_src, 0), (self.clamp, 1))

        self.connect((self.clamp, 0), (self.to_complex, 0))
        self.connect((self.null_src, 0), (self.to_complex, 1))

        self.connect((self.equiv_delay, 0), (self, 0))
        self.connect((self.to_complex, 0), (self, 1))
예제 #12
0
파일: qa_max.py 프로젝트: danbar/gnuradio
    def stest_004(self):
        dim = 2
        src_data0 = (0, 2, -3, 0, 12, 0)
        src_data1 = (1, 1,  1, 1,  1, 1)

        expected_data = []
        tmp = [float(max(x,y)) for x,y in zip(src_data0, src_data1)]
        for i in range(len(tmp) / dim):
            expected_data.append(float(max(tmp[i*dim:(i+1)*dim])))

        src0 = blocks.vector_source_f(src_data0)
        s2v0 = blocks.stream_to_vector(gr.sizeof_float,dim)
        src1 = blocks.vector_source_f(src_data1)
        s2v1 = blocks.stream_to_vector(gr.sizeof_float,dim)
        op = blocks.max_ff(dim)
        dst = blocks.vector_sink_f()

        self.tb.connect(src0, s2v0, (op, 0))
        self.tb.connect(src1, s2v1, (op, 1))
        self.tb.connect(op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
예제 #13
0
    def stest_004(self):
        dim = 2
        src_data0 = (0, 2, -3, 0, 12, 0)
        src_data1 = (1, 1, 1, 1, 1, 1)

        expected_data = []
        tmp = [float(max(x, y)) for x, y in zip(src_data0, src_data1)]
        for i in range(len(tmp) / dim):
            expected_data.append(float(max(tmp[i * dim:(i + 1) * dim])))

        src0 = blocks.vector_source_f(src_data0)
        s2v0 = blocks.stream_to_vector(gr.sizeof_float, dim)
        src1 = blocks.vector_source_f(src_data1)
        s2v1 = blocks.stream_to_vector(gr.sizeof_float, dim)
        op = blocks.max_ff(dim)
        dst = blocks.vector_sink_f()

        self.tb.connect(src0, s2v0, (op, 0))
        self.tb.connect(src1, s2v1, (op, 1))
        self.tb.connect(op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
예제 #14
0
    def __init__(self, constellation, frame_type, code_rate):
        gr.top_block.__init__(self, "Dvbs2 Tx")

        ##################################################
        # Parameters
        ##################################################
        # Header is 10 bytes
        try:
            frame_length = 1.0 * BBFRAME_LENGTH[frame_type][code_rate] - 80
        except KeyError:
            raise UnknownFrameLength(frame_type, code_rate)

        #  print("Base frame length: %s" % frame_length)
        frame_length /= 8
        #  print("Base frame length: %s" % frame_length)
        assert int(
            frame_length
        ) == 1.0 * frame_length, "Frame length {0} won't work because {0}/8 = {1}!".format(
            frame_length, frame_length / 8.0)
        frame_length = int(frame_length)
        self.frame_length = frame_length

        bits_per_input, bits_per_output = get_ratio(constellation)

        ##################################################
        # Variables
        ##################################################
        self.symbol_rate = symbol_rate = 5000000
        self.taps = taps = 100
        self.samp_rate = samp_rate = symbol_rate * 2
        self.rolloff = rolloff = 0.2
        self.noise = noise = 0
        self.gain = gain = 1
        self.center_freq = center_freq = 1280e6

        ##################################################
        # Blocks
        ##################################################
        self.ldpc_encoder_input = blocks.file_sink(gr.sizeof_char * 1,
                                                   'ldpc_encoder_input.bin',
                                                   False)
        self.ldpc_encoder_input.set_unbuffered(False)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(
            1, (numpy.conj([
                0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 -
                1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 +
                1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 +
                1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 -
                1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 -
                1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 +
                1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 +
                1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 +
                1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 +
                1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 -
                1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j
            ] + [
                0,
            ] * (89 - 32))))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0 = filter.fir_filter_ccc(1, (numpy.conj([
            0,
        ] * (89 - 25) + [
            0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 +
            1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 +
            1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 +
            1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 +
            1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 -
            1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 -
            1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 +
            1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 +
            1.00000j, 0.00000 + 0.00000j
        ])))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.fft_filter_xxx_0 = filter.fft_filter_ccc(
            1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate / 2,
                                          rolloff, taps)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.dtv_dvbs2_physical_cc_0 = dtv.dvbs2_physical_cc(
            frame_type, code_rate, dtv.MOD_BPSK, dtv.PILOTS_ON, 0)
        self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc(
            frame_type, code_rate, dtv.MOD_BPSK, dtv.INTERPOLATION_OFF)
        self.dtv_dvbs2_interleaver_bb_0 = dtv.dvbs2_interleaver_bb(
            frame_type, code_rate, constellation)
        self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBS2,
                                                 frame_type, code_rate,
                                                 dtv.MOD_OTHER)
        self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb(dtv.STANDARD_DVBS2, frame_type,
                                               code_rate)
        self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb(
            dtv.STANDARD_DVBS2, frame_type, code_rate)
        self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb(
            dtv.STANDARD_DVBS2, frame_type, code_rate, dtv.RO_0_20,
            dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            2, math.pi / 100.0, (firdes.root_raised_cosine(
                2 * 32, 32, 1.0 / float(2), 0.35, 11 * 2 * 32)), 32, 16, 1.5,
            1)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            math.pi / 100.0, 4, False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate / 10, True)
        self.blocks_sub_xx_0 = blocks.sub_cc(1)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            bits_per_input, bits_per_output, "", False, gr.GR_MSB_FIRST)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((gain, ))
        self.blocks_max_xx_0 = blocks.max_ff(1, 1)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1,
                                                   'output.bin', False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_xx_2 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.bit_interleaver_output_packed = blocks.file_sink(
            gr.sizeof_char * 1, 'bit_interleaver_output_packed.bin', False)
        self.bit_interleaver_output_packed.set_unbuffered(False)
        self.bit_interleaver_output = blocks.file_sink(
            gr.sizeof_char * 1, 'bit_interleaver_output.bin', False)
        self.bit_interleaver_output.set_unbuffered(False)
        self.bit_interleaver_input = blocks.file_sink(
            gr.sizeof_char * 1, 'bit_interleaver_input.bin', False)
        self.bit_interleaver_input.set_unbuffered(False)
        self.bch_encoder_input = blocks.file_sink(gr.sizeof_char * 1,
                                                  'bch_encoder_input.bin',
                                                  False)
        self.bch_encoder_input.set_unbuffered(False)
        self.bb_scrambler_input_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                     'bb_scrambler_input.bin',
                                                     False)
        self.bb_scrambler_input_0.set_unbuffered(False)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 255, frame_length)), False)
        self.analog_noise_source_x_1 = analog.noise_source_c(
            analog.GR_GAUSSIAN, noise, 0)
        self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(8192)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.analog_noise_source_x_1, 0),
                     (self.blocks_add_xx_2, 1))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.dtv_dvb_bbheader_bb_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_add_xx_2, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_max_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_0_0, 0),
                     (self.blocks_max_xx_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.fir_filter_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.fir_filter_xxx_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.bit_interleaver_output_packed, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.blocks_complex_to_mag_0_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_1, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.blocks_conjugate_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.dtv_dvb_bbheader_bb_0, 0),
                     (self.bb_scrambler_input_0, 0))
        self.connect((self.dtv_dvb_bbheader_bb_0, 0),
                     (self.dtv_dvb_bbscrambler_bb_0, 0))
        self.connect((self.dtv_dvb_bbscrambler_bb_0, 0),
                     (self.bch_encoder_input, 0))
        self.connect((self.dtv_dvb_bbscrambler_bb_0, 0),
                     (self.dtv_dvb_bch_bb_0, 0))
        self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0))
        self.connect((self.dtv_dvb_bch_bb_0, 0), (self.ldpc_encoder_input, 0))
        self.connect((self.dtv_dvb_ldpc_bb_0, 0),
                     (self.bit_interleaver_input, 0))
        self.connect((self.dtv_dvb_ldpc_bb_0, 0),
                     (self.dtv_dvbs2_interleaver_bb_0, 0))
        self.connect((self.dtv_dvbs2_interleaver_bb_0, 0),
                     (self.bit_interleaver_output, 0))
        self.connect((self.dtv_dvbs2_interleaver_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.dtv_dvbs2_interleaver_bb_0, 0),
                     (self.dtv_dvbs2_modulator_bc_0, 0))
        self.connect((self.dtv_dvbs2_modulator_bc_0, 0),
                     (self.dtv_dvbs2_physical_cc_0, 0))
        self.connect((self.dtv_dvbs2_physical_cc_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.blocks_add_xx_2, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.fir_filter_xxx_0_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.fir_filter_xxx_0_0, 0), (self.blocks_sub_xx_0, 1))
예제 #15
0
    def __init__(self, seq1, seq2, factor, lookahead, alpha, freqs):
        """
        Description:
frequency timing estimator class does frequency/timing acquisition from scratch.It uses a bank of parallel correlators at each specified frequency. It then takes the max abs value of all these and passes it through a peak detector to find timing.


        Args:
	     seq1: sequence1 of kronecker filter, which is the given training sequence. 
	     seq2: sequence2 of kronecker filter, which is the pulse for each training symbol.
             factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended.  In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak.
             alpha: the smoothing factor of a moving average filter used in the peak detector taking values in (0,1).
             freqs: the vector of normalized center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt).
        """

        gr.hier_block2.__init__(self,
            "freq_timing_estimator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.seq1 = seq1
        self.seq2 = seq2
        self.factor = factor
        self.lookahead = lookahead
        self.alpha = alpha
        self.freqs = freqs
        self.n = n = len(freqs)
        self.on = 1

        ##################################################
        # Blocks
        ##################################################
        self._filter=[0]*self.n
        self._c2mag2=[0]*self.n
        for i in range(self.n):
          #self._filter[i]= cdma.kronecker_filter(seq1,seq2,1,self.freqs[i])
          #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1)
          self._filter[i]= filter.freq_xlating_fft_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1)
          self._c2mag2[i] = blocks.complex_to_mag_squared(1)

        self.blocks_max = blocks.max_ff(1)
        self.blocks_peak_detector = cdma.switched_peak_detector_fb(self.factor, self.factor, self.lookahead, self.alpha, self.on)

        self.blocks_argmax = blocks.argmax_fs(1)
        self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1)
        self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1)
        self.blocks_sample_and_hold = blocks.sample_and_hold_ff()

        ##################################################
        # Connections
        ##################################################
        for i in range(self.n):
          self.connect((self, 0), (self._filter[i], 0))
          self.connect((self._filter[i], 0), (self._c2mag2[i], 0))
          self.connect((self._c2mag2[i], 0), (self.blocks_max, i))
          self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i))
        self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0))
        self.connect((self.blocks_peak_detector, 0), (self, 0))
        self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0))
        self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0))
        self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0))
        self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1))
        self.connect((self.blocks_sample_and_hold, 0), (self, 1))
        self.connect((self.blocks_max, 0), (self, 2))
예제 #16
0
    def __init__(self, ts, factor, alpha, samp_rate, freqs):
        """
	Description:
        This block is designed to perform frequency and timing acquisition for a known training sequence in the presense of frequency and timing offset and noise. Its input is a complex stream.  It has three outputs: 
 1)  a stream of flags (bytes) indicating the begining of the training sequence (to be used from subsequent blocks to "chop" the incoming stream,
 2)  a stream with the current acquired frequency offset, and
 3)  a stream with the current acquired peak of the matched filter 

	Internally, it consists of a user defined number of parallel matched filters (as many as the size of the freqs vector), each consistng of a frequency Xlating FIR filter with sample rate samp_rate, filter taps matched to the training sequence ts, and center frequency freqs[i]. The filter outputs are magnitude squared and passed through a max block and then through a peak detector. 
 
	Args:
	     ts: the training sequence. For example, in DSSS system, it's the chip-based spread training sequence. 
	     factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended.  In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak. factor takes values in (0,1). 
	     alpha: the smoothing factor of a moving average filter used in the peak detector takeng values in (0,1).
	     samp_rate: the sample rate of the system, which is used in the freq_xlating_fir_filter.
	     freqs: the vector of center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt).
        """

        gr.hier_block2.__init__(
            self, "freq_timing_estimator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.ts = ts
        self.factor = factor
        self.alpha = alpha
        self.samp_rate = samp_rate
        self.freqs = freqs
        self.n = n = len(freqs)
        ##################################################
        # Blocks
        ##################################################
        self._filter=[0]*self.n
        self._c2mag2=[0]*self.n
        for i in range(self.n):
          self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, (numpy.conjugate(self.ts[::-1])), self.freqs[i], self.samp_rate)
          self._c2mag2[i] = blocks.complex_to_mag_squared(1)

        self.blocks_max = blocks.max_ff(1)
        self.blocks_peak_detector = blocks.peak_detector_fb(self.factor, self.factor, 0, self.alpha)

        self.blocks_argmax = blocks.argmax_fs(1)
        self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1)
        self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1)
        self.blocks_sample_and_hold = blocks.sample_and_hold_ff()

        ##################################################
        # Connections
        ##################################################
        for i in range(self.n):
          self.connect((self, 0), (self._filter[i], 0))
          self.connect((self._filter[i], 0), (self._c2mag2[i], 0))
          self.connect((self._c2mag2[i], 0), (self.blocks_max, i))
          self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i))
        self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0))
        self.connect((self.blocks_peak_detector, 0), (self, 0))
        self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0))
        self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0))
        self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0))
        self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1))
        self.connect((self.blocks_sample_and_hold, 0), (self, 1))
        self.connect((self.blocks_max, 0), (self, 2))
예제 #17
0
    def __init__(self):
        gr.top_block.__init__(self, "AM")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("AM")
        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", "am")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.signal_offset = signal_offset = 1
        self.samp_rate = samp_rate = 288000
        self.in_gain = in_gain = 0.5

        ##################################################
        # Blocks
        ##################################################
        self._signal_offset_range = Range(0, 2, 0.1, 1, 200)
        self._signal_offset_win = RangeWidget(self._signal_offset_range, self.set_signal_offset, 'Signal Offset', "counter_slider", float)
        self.top_grid_layout.addWidget(self._signal_offset_win)
        self._in_gain_range = Range(0, 2, 0.1, 0.5, 200)
        self._in_gain_win = RangeWidget(self._in_gain_range, self.set_in_gain, 'Input gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._in_gain_win)
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            2048, #size
            samp_rate, #samp_rate
            'Wave Form', #name
            2 #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1.set_y_axis(-0.5, 0.5)

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

        self.qtgui_time_sink_x_0_1.enable_tags(True)
        self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_1.enable_autoscale(False)
        self.qtgui_time_sink_x_0_1.enable_grid(False)
        self.qtgui_time_sink_x_0_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_1.enable_control_panel(False)
        self.qtgui_time_sink_x_0_1.enable_stem_plot(False)


        labels = ['Original', 'Demodulated', 'Signal 3', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10']
        widths = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        colors = ['blue', 'black', '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]
        styles = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
            -1, -1, -1, -1, -1]


        for i in range(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            2048, #size
            samp_rate, #samp_rate
            'Modulated', #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(-4, 4)

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

        self.qtgui_time_sink_x_0.enable_tags(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(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)


        labels = ['Modulated', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10']
        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]
        styles = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
            -1, -1, -1, -1, -1]


        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            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.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(
                1,
                samp_rate,
                22000,
                100,
                firdes.WIN_HAMMING,
                6.76))
        self.blocks_wavfile_source_0 = blocks.wavfile_source('/home/irodrigu/Proyectos/sc-clases/2020-2021/P1/src/songs/Lofi.wav', True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_ff(in_gain)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(1)
        self.blocks_max_xx_0 = blocks.max_ff(1, 1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.band_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.band_pass(
                1,
                samp_rate,
                85000,
                115000,
                100,
                firdes.WIN_HAMMING,
                6.76))
        self.audio_sink_0 = audio.sink(48000, 'pulse', True)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 100000, 3, 0, 0)
        self.analog_const_source_x_0_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, signal_offset)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, signal_offset)
        self.analog_agc_xx_0 = analog.agc_ff(6e-8, 0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.qtgui_time_sink_x_0_1, 1))
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.analog_const_source_x_0_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.band_pass_filter_0, 0), (self.blocks_max_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_null_source_0, 0), (self.blocks_max_xx_0, 1))
        self.connect((self.blocks_sub_xx_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_multiply_const_vxx_0_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_sub_xx_0, 0))
예제 #18
0
    def __init__(self):
        gr.top_block.__init__(self, "Peak Detect Freq Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Peak Detect Freq Test")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "peak_detect_freq_test")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(
                self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            500,  #fc
            samp_rate,  #bw
            "Normal",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_1.enable_grid(False)
        self.qtgui_freq_sink_x_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_1.set_plot_pos_half(not True)

        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"
        ]
        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_freq_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_1_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
            2048,  #size
            firdes.WIN_FLATTOP,  #wintype
            500,  #fc
            samp_rate,  #bw
            "Max",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        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"
        ]
        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_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 2048)
        self.blocks_max_xx_0 = blocks.max_ff(4096, 1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1000, 100, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, 2500, 100, 0)
        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_add_xx_0, 2))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0),
                     (self.blocks_max_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
예제 #19
0
    def __init__(self):
        gr.top_block.__init__(self, "Cross Correlation Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Cross Correlation Test")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "xcorr_test_opencl")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.delay_0 = delay_0 = 0
        self.samp_rate = samp_rate = 2.4e6
        self.max_search = max_search = 500
        self.lag = lag = 10
        self.gain = gain = 32
        self.delay_label = delay_label = delay_0
        self.corr_frame_size = corr_frame_size = 8192
        self.corr_frame_decim = corr_frame_decim = 6
        self.center_freq = center_freq = 162.425e6

        ##################################################
        # Blocks
        ##################################################
        self._lag_range = Range(0, 20, 1, 10, 200)
        self._lag_win = RangeWidget(self._lag_range, self.set_lag, 'lag',
                                    "counter_slider", int)
        self.top_grid_layout.addWidget(self._lag_win, 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._gain_range = Range(0, 60, 2, 32, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'Gain',
                                     "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_win, 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.xcorrelate_ExtractDelay_0 = xcorrelate.ExtractDelay(
            0, self.set_delay_0, False)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "num_recv_frames=128")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
        )
        self.uhd_usrp_source_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        # No synchronization enforced.
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            64,  #size
            samp_rate,  #samp_rate
            "",  #name
            3  #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(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(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        labels = [
            'Reference', 'Signal 1', 'Correlated', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'
        ]
        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]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(3):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            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.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 4, 0, 2,
                                       4)
        for r in range(4, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0_0.set_title("Improvement")

        labels = ['', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("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 range(1):
            self.qtgui_number_sink_0_0_0.set_min(i, -10)
            self.qtgui_number_sink_0_0_0.set_max(i, 10)
            self.qtgui_number_sink_0_0_0.set_color(i, colors[i][0],
                                                   colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0_0_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0_0_0.set_label(i, labels[i])
            self.qtgui_number_sink_0_0_0.set_unit(i, units[i])
            self.qtgui_number_sink_0_0_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_win, 7, 0,
                                       1, 3)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 2)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title('Max Power')

        labels = ['Ref Signal', 'Correlated', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("blue", "red"), ("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 range(2):
            self.qtgui_number_sink_0.set_min(i, -100)
            self.qtgui_number_sink_0.set_max(i, -10)
            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, 6, 0, 1,
                                       3)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            center_freq,  #fc
            samp_rate,  #bw
            "",  #name
            3)
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        labels = [
            'Reference', 'Delayed', 'Correlated', '', '', '', '', '', '', ''
        ]
        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 range(3):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 1, 0, 2,
                                       4)
        for r in range(1, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.logpwrfft_x_0_0 = logpwrfft.logpwrfft_c(sample_rate=samp_rate,
                                                     fft_size=1024,
                                                     ref_scale=2,
                                                     frame_rate=30,
                                                     avg_alpha=1.0,
                                                     average=False)
        self.logpwrfft_x_0 = logpwrfft.logpwrfft_c(sample_rate=samp_rate,
                                                   fft_size=1024,
                                                   ref_scale=2,
                                                   frame_rate=30,
                                                   avg_alpha=1.0,
                                                   average=False)
        self._delay_label_tool_bar = Qt.QToolBar(self)

        if None:
            self._delay_label_formatter = None
        else:
            self._delay_label_formatter = lambda x: str(x)

        self._delay_label_tool_bar.addWidget(
            Qt.QLabel('Correcting Delay' + ": "))
        self._delay_label_label = Qt.QLabel(
            str(self._delay_label_formatter(self.delay_label)))
        self._delay_label_tool_bar.addWidget(self._delay_label_label)
        self.top_grid_layout.addWidget(self._delay_label_tool_bar, 0, 4, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.clenabled_XCorrelate_0 = clenabled.clXCorrelate(
            1, 1, 0, 0, False, 2, 8192, 2, gr.sizeof_float, 600, 6)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(-1)
        self.blocks_max_xx_0_0 = blocks.max_ff(1024, 1)
        self.blocks_max_xx_0 = blocks.max_ff(1024, 1)
        self.blocks_delay_0_0_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                               delay_0)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, lag)
        self.blocks_complex_to_mag_0_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.clenabled_XCorrelate_0, 'corr'),
                         (self.xcorrelate_ExtractDelay_0, 'corr'))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_complex_to_mag_0_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.logpwrfft_x_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_freq_sink_x_0, 2))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.clenabled_XCorrelate_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_complex_to_mag_0_0, 0),
                     (self.clenabled_XCorrelate_0, 1))
        self.connect((self.blocks_complex_to_mag_0_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_complex_to_mag_0_0_0, 0),
                     (self.qtgui_time_sink_x_0, 2))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_complex_to_mag_0_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_delay_0_0_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.blocks_delay_0_0_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_max_xx_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_max_xx_0_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_max_xx_0_0, 0),
                     (self.qtgui_number_sink_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_number_sink_0_0_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.logpwrfft_x_0, 0), (self.blocks_max_xx_0, 0))
        self.connect((self.logpwrfft_x_0_0, 0), (self.blocks_max_xx_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.logpwrfft_x_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
예제 #20
0
    def __init__(self):
        gr.top_block.__init__(self, "ORBCOMM UHF Beacon RX")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("ORBCOMM UHF Beacon RX")
        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", "uhf_rx_exp")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 50e3

        self.xlate_taps = xlate_taps = firdes.low_pass(1.0, samp_rate,
                                                       samp_rate / 2, 1000,
                                                       firdes.WIN_HAMMING,
                                                       6.76)

        self.ts_str = ts_str = dt.strftime(dt.utcnow(),
                                           "%Y%m%d_%H%M%S.%f") + '_UTC'
        self.rx_gain = rx_gain = 30
        self.rx_freq = rx_freq = 400.2e6
        self.offset = offset = 0
        self.fft_size = fft_size = 4096 * 1
        self.delay = delay = 10

        ##################################################
        # Blocks
        ##################################################
        self._offset_tool_bar = Qt.QToolBar(self)
        self._offset_tool_bar.addWidget(Qt.QLabel('OFFSET' + ": "))
        self._offset_line_edit = Qt.QLineEdit(str(self.offset))
        self._offset_tool_bar.addWidget(self._offset_line_edit)
        self._offset_line_edit.returnPressed.connect(lambda: self.set_offset(
            eng_notation.str_to_num(
                str(self._offset_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._offset_tool_bar, 1, 6, 1, 2)
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(
            .005, 1)
        self._rx_gain_tool_bar = Qt.QToolBar(self)
        self._rx_gain_tool_bar.addWidget(Qt.QLabel('GAIN' + ": "))
        self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain))
        self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit)
        self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain(
            eng_notation.str_to_num(
                str(self._rx_gain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_gain_tool_bar, 2, 6, 1, 2)
        self._rx_freq_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ' + ": "))
        self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit)
        self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq(
            eng_notation.str_to_num(
                str(self._rx_freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 0, 6, 1, 2)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(True)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        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_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-120, -80)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 10,
                                       0, 2, 6)
        self.qtgui_number_sink_0_0_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_0_0_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0_0_0_0.set_title("")

        labels = ['SNR', '', '', '', '', '', '', '', '', '']
        units = ['dB', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("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_0_0_0_0.set_min(i, 0)
            self.qtgui_number_sink_0_0_0_0_0.set_max(i, 80)
            self.qtgui_number_sink_0_0_0_0_0.set_color(i, colors[i][0],
                                                       colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0_0_0_0_0.set_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0_0_0_0_0.set_label(i, labels[i])
            self.qtgui_number_sink_0_0_0_0_0.set_unit(i, units[i])
            self.qtgui_number_sink_0_0_0_0_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0_0_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_0_win,
                                       3, 6, 1, 1)
        self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_0_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0_0_0.set_title("")

        labels = ['Noise', '', '', '', '', '', '', '', '', '']
        units = ['dBFS', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("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_0_0_0.set_min(i, 0)
            self.qtgui_number_sink_0_0_0_0.set_max(i, 80)
            self.qtgui_number_sink_0_0_0_0.set_color(i, colors[i][0],
                                                     colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0_0_0_0.set_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0_0_0_0.set_label(i, labels[i])
            self.qtgui_number_sink_0_0_0_0.set_unit(i, units[i])
            self.qtgui_number_sink_0_0_0_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 4,
                                       7, 1, 1)
        self.qtgui_number_sink_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0_0.set_title("")

        labels = ['Signal Power', '', '', '', '', '', '', '', '', '']
        units = ['dBFS', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("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_0_0.set_min(i, 0)
            self.qtgui_number_sink_0_0_0.set_max(i, 80)
            self.qtgui_number_sink_0_0_0.set_color(i, colors[i][0],
                                                   colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0_0_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0_0_0.set_label(i, labels[i])
            self.qtgui_number_sink_0_0_0.set_unit(i, units[i])
            self.qtgui_number_sink_0_0_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_win, 3, 7,
                                       1, 1)
        self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                       qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0.set_title("")

        labels = ['Doppler', '', '', '', '', '', '', '', '', '']
        units = ['Hz', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("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_0.set_min(i, 0)
            self.qtgui_number_sink_0_0.set_max(i, 80)
            self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0_0.set_label(i, labels[i])
            self.qtgui_number_sink_0_0.set_unit(i, units[i])
            self.qtgui_number_sink_0_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_win, 4, 6,
                                       1, 1)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_VERT, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = ['Doppler Rate', '', '', '', '', '', '', '', '', '']
        units = ['Hz/s', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("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, 80)
            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, 5, 6, 4,
                                       1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0.set_y_axis(-130, -90)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.05)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        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"
        ]
        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_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 10,
                                       6)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (xlate_taps), offset, samp_rate)
        self.fft_vxx_0 = fft.fft_vcc(fft_size, True,
                                     (window.flattop(fft_size)), True, 2)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_size)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate * 4, True)
        self.blocks_sub_xx_0_0 = blocks.sub_ff(1)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fft_size)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short * 1)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(
            10, fft_size, -10 * math.log10(fft_size**2))
        self.blocks_multiply_const_vxx_1_0_0 = blocks.multiply_const_vff(
            ((samp_rate / fft_size) / delay, ))
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff(
            (samp_rate / fft_size, ))
        self.blocks_moving_average_xx_1 = blocks.moving_average_ff(
            fft_size, float(1.0 / fft_size), 4000, 1)
        self.blocks_max_xx_0 = blocks.max_ff(fft_size, 1)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, fft_size)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/zleffke/captures/orbcomm/ORBCOMM_FMXX_USRP_20171203_013912.497704_UTC_50k.fc32',
            True)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, delay)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            fft_size)
        self.blocks_argmax_xx_0 = blocks.argmax_fs(fft_size)
        self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((5.76, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-samp_rate / 2, ))
        self.blocks_abs_xx_0 = blocks.abs_ff(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_abs_xx_0, 0),
                     (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_sub_xx_0_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.qtgui_number_sink_0_0, 0))
        self.connect((self.blocks_add_const_vxx_0_0, 0),
                     (self.blocks_moving_average_xx_1, 0))
        self.connect((self.blocks_argmax_xx_0, 1),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_argmax_xx_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_0_0, 1))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.qtgui_number_sink_0_0_0_0, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_max_xx_0, 0),
                     (self.qtgui_number_sink_0_0_0, 0))
        self.connect((self.blocks_moving_average_xx_1, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0_0, 0),
                     (self.blocks_abs_xx_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_argmax_xx_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_max_xx_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.qtgui_number_sink_0_0_0_0_0, 0))
        self.connect((self.blocks_sub_xx_0_0, 0),
                     (self.blocks_multiply_const_vxx_1_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.qtgui_number_sink_0, 0))
예제 #21
0
    def __init__(self, avg_len=256, nfft=2048):
        gr.top_block.__init__(self, "FFT Power Measure")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("FFT Power Measure")
        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", "fft_power_meas")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.avg_len = avg_len
        self.nfft = nfft

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 4e6
        self.rx_gain = rx_gain = 16
        self.rx_freq = rx_freq = 1089.74e6

        ##################################################
        # Blocks
        ##################################################
        self._rx_gain_range = Range(0, 90, 1, 16, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_gain_win, 4, 0, 1, 4)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_freq_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel("rx_freq" + ": "))
        self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit)
        self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq(
            eng_notation.str_to_num(
                str(self._rx_freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 5, 0, 1, 1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_source_1 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_1.set_samp_rate(samp_rate)
        self.uhd_usrp_source_1.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_1.set_center_freq(
            uhd.tune_request(rx_freq, samp_rate / 2), 0)
        self.uhd_usrp_source_1.set_gain(rx_gain, 0)
        self.uhd_usrp_source_1.set_antenna('RX2', 0)
        self.uhd_usrp_source_1.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_1.set_auto_iq_balance(True, 0)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_NONE, 2)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = ['', '', '', '', '', '', '', '', '', '']
        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(2):
            self.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            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, 5, 2, 1,
                                       2)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            rx_freq,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.001)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, -10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "red", "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_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 2,
                                       4)
        for r in range(0, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.fft_vxx_0 = fft.fft_vcc(nfft, True, (window.blackmanharris(nfft)),
                                     True, 4)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, nfft)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short * 1)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, nfft,
                                                   -10 * math.log10(nfft))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            int(avg_len), 1.0 / (avg_len) / nfft, 4000, nfft)
        self.blocks_max_xx_0 = blocks.max_ff(nfft, 1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            nfft)
        self.blocks_argmax_xx_0 = blocks.argmax_fs(nfft)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_argmax_xx_0, 1),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_argmax_xx_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.qtgui_number_sink_0, 1))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_argmax_xx_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_max_xx_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.uhd_usrp_source_1, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.uhd_usrp_source_1, 0),
                     (self.qtgui_freq_sink_x_0, 0))
    def __init__(self, seq1, seq2, factor, alpha, freqs, debug_onoff, debug_port, prefix):
        """
        Description:
frequency timing estimator class does frequency/timing acquisition from scratch.It uses a bank of parallel correlators at each specified frequency. It then takes the max abs value of all these and passes it through a peak detector to find timing.


        Args:
	     seq1: sequence1 of kronecker filter, which is the given training sequence. 
	     seq2: sequence2 of kronecker filter, which is the pulse for each training symbol.
             factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended.  In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak.
             alpha: the smoothing factor of a moving average filter used in the peak detector taking values in (0,1).
             freqs: the vector of normalized center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt).
        """

        gr.hier_block2.__init__(self,
            "freq_timing_estimator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.seq1 = seq1
        self.seq2 = seq2
        self.factor = factor
        self.alpha = alpha
        self.freqs = freqs
        self.n = n = len(freqs)
        self.on = 1
        self.debug_onoff = debug_onoff # 1: dump ports info to file 0: no debug output
        self.debug_port = debug_port # 0-n_filt-1 is the output of each filter branck; n_filter is the output of maximum
        self.prefix = prefix

        ##################################################
        # Blocks
        ##################################################
        self._filter=[0]*self.n
        self._c2mag2=[0]*self.n
        for i in range(self.n):
          #self._filter[i]= cdma.kronecker_filter(seq1,seq2,1,self.freqs[i])
          #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1)
          self._filter[i]= filter.freq_xlating_fft_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1)
          self._c2mag2[i] = blocks.complex_to_mag_squared(1)

        self.blocks_max = blocks.max_ff(1)
        self.blocks_peak_detector = cdma.switched_peak_detector_fb(self.factor, self.factor, 0, self.alpha, self.on)

        self.blocks_argmax = blocks.argmax_fs(1)
        self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1)
        self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1)
        self.blocks_sample_and_hold = blocks.sample_and_hold_ff()
	    
        if self.debug_onoff == True:
            num_of_file_sinks = len(self.debug_port)
            self._filesink = [0]*num_of_file_sinks
            for i in range(num_of_file_sinks):
                if self.debug_port[i] == self.n:
                    filename = prefix+"max.dat"
                    
                else:
                    filename = prefix+"filter"+str(i)+".dat"
                print filename
                self._filesink[i] = blocks.file_sink(gr.sizeof_float*1, filename, False)
                self._filesink[i].set_unbuffered(False)

    	# this is the block for bundling the outputs of each branch of filters and the input of peak detector	
        ##################################################
        # Connections
        ##################################################
        for i in range(self.n):
          self.connect((self, 0), (self._filter[i], 0))
          self.connect((self._filter[i], 0), (self._c2mag2[i], 0))
          self.connect((self._c2mag2[i], 0), (self.blocks_max, i))
          self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i))
        self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0))
        self.connect((self.blocks_peak_detector, 0), (self, 0))
        self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0))
        self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0))
        self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0))
        self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1))
        self.connect((self.blocks_sample_and_hold, 0), (self, 1))
        self.connect((self.blocks_max, 0), (self, 2))
        if self.debug_onoff == True:
            for i in range(num_of_file_sinks):
                port_index = self.debug_port[i]
                if port_index == self.n:
                    self.connect((self.blocks_max, 0), (self._filesink[i], 0))
                else:
                    self.connect((self._c2mag2[port_index], 0), (self._filesink[i], 0))
예제 #23
0
    def __init__(self):
        gr.top_block.__init__(self, "Mpsk Stage3")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Mpsk Stage3")
        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", "mpsk_stage3")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 2
        self.nfilts = nfilts = 32
        self.timing_loop_bw = timing_loop_bw = 6.28 / 100.0
        self.time_offset = time_offset = 1.00
        self.taps = taps = [
            1.0 + 0.0j,
        ]
        self.samp_rate = samp_rate = 32000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts)
        self.qpsk = qpsk = digital.constellation_rect(([0, 1]), ([0, 1]), 4, 2,
                                                      2, 1, 1).base()
        self.noise_volt = noise_volt = 0.0001
        self.freq_offset = freq_offset = 0
        self.excess_bw = excess_bw = 0.35

        self.encoder_variable = encoder_variable = fec.ldpc_encoder_make(
            '/usr/share/gnuradio/fec/ldpc/n_0512_k_0130_gap_21.alist')

        self.decoder_variable = decoder_variable = fec.ldpc_decoder.make(
            '/usr/share/gnuradio/fec/ldpc/n_0512_k_0130_gap_21.alist', 0.5, 50)

        self.dbpsk = dbpsk = digital.constellation_bpsk().base()

        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28 / 100.0, 200)
        self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range,
                                               self.set_timing_loop_bw,
                                               'Time: BW', "slider", float)
        self.top_grid_layout.addWidget(self._timing_loop_bw_win, 0, 3, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200)
        self._time_offset_win = RangeWidget(self._time_offset_range,
                                            self.set_time_offset,
                                            'Timing Offset', "counter_slider",
                                            float)
        self.top_grid_layout.addWidget(self._time_offset_win, 0, 2, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200)
        self._noise_volt_win = RangeWidget(self._noise_volt_range,
                                           self.set_noise_volt,
                                           'Noise Voltage', "counter_slider",
                                           float)
        self.top_grid_layout.addWidget(self._noise_volt_win, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range,
                                            self.set_freq_offset,
                                            'Frequency Offset',
                                            "counter_slider", float)
        self.top_grid_layout.addWidget(self._freq_offset_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_VERT, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = ['', '', '', '', '', '', '', '', '', '']
        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.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            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(True)
        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)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
            2048,  #size
            '',  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0.disable_legend()

        labels = ['Timing Recov.', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [0.5, 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_const_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 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.fft_vxx_0 = fft.fft_vcc(1024, True, (window.blackmanharris(1024)),
                                     True, 1)
        self.fec_extended_encoder_0_0_0 = fec.extended_encoder(
            encoder_obj_list=encoder_variable, threading=None, puncpat="11")
        self.fec_extended_decoder_0_1_0 = fec.extended_decoder(
            decoder_obj_list=decoder_variable,
            threading='ordinary',
            ann=None,
            puncpat="11",
            integration_period=10000)
        self.epy_block_0 = epy_block_0.barker_sync()
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps * 1.000, timing_loop_bw, (rrc_taps), nfilts, nfilts / 2, 1.5,
            1)
        self.digital_map_bb_0_0_0_0 = digital.map_bb(([-1, 1]))
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(
            dbpsk, timing_loop_bw, -100, 100)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=dbpsk,
            differential=True,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=excess_bw,
            verbose=False,
            log=False,
        )
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=noise_volt,
            frequency_offset=freq_offset,
            epsilon=time_offset,
            taps=(taps),
            noise_seed=0,
            block_tags=False)
        self.blocks_unpacked_to_packed_xx_1_0 = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_unpacked_to_packed_xx_0_0 = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 1024)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_max_xx_0 = blocks.max_ff(1024, 1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1, '/home/gdreyfus/sagan.jpg', False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_1 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/gdreyfus/sentsagan.jpg', False)
        self.blocks_file_sink_1.set_unbuffered(True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   'zappppp', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            1024)
        self.blocks_char_to_float_0_2_0 = blocks.char_to_float(1, 1)
        self.Add_Barking_Code = Add_Barking_Code.blk()

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Add_Barking_Code, 0),
                     (self.blocks_unpacked_to_packed_xx_1_0, 0))
        self.connect((self.blocks_char_to_float_0_2_0, 0),
                     (self.fec_extended_decoder_0_1_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_max_xx_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.fec_extended_encoder_0_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_1_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.epy_block_0, 0))
        self.connect((self.digital_map_bb_0_0_0_0, 0),
                     (self.blocks_char_to_float_0_2_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_constellation_receiver_cb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.epy_block_0, 0), (self.digital_map_bb_0_0_0_0, 0))
        self.connect((self.fec_extended_decoder_0_1_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0_0, 0))
        self.connect((self.fec_extended_encoder_0_0_0, 0),
                     (self.Add_Barking_Code, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "onedimension_simulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("onedimension_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", "onedimension_simulation")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.maxtheta = maxtheta = 150
        self.columns = columns = 100
        self.shiftarrL = shiftarrL = np.radians(np.linspace(start=maxtheta, stop=0, num=int(columns/2), endpoint=False))
        self.variable_function_probe_0_0 = variable_function_probe_0_0 = 0
        self.variable_function_probe_0 = variable_function_probe_0 = 1
        self.left = left = np.pad(shiftarrL, (0, int(columns/2)), 'constant')
        self.degreesTXR = degreesTXR = 0
        self.degreesTXL = degreesTXL = 0
        self.variable_qtgui_label_0_0_0 = variable_qtgui_label_0_0_0 = variable_function_probe_0_0
        self.variable_qtgui_label_0_0 = variable_qtgui_label_0_0 = variable_function_probe_0
        self.scale = scale = 55
        self.samp_rate = samp_rate = 64000
        self.rows = rows = 100
        self.right = right = np.flip(left, axis=0)
        self.angle_radiansStartR = angle_radiansStartR = (math.pi/180) * degreesTXR
        self.angle_radiansStartL = angle_radiansStartL = (math.pi/180) * degreesTXL

        ##################################################
        # Blocks
        ##################################################
        self._scale_range = Range(0, 100, 5, 55, 200)
        self._scale_win = RangeWidget(self._scale_range, self.set_scale, 'scale', "counter_slider", float)
        self.top_grid_layout.addWidget(self._scale_win)
        self.blocks_probe_signal_x_0_0 = blocks.probe_signal_f()
        self.blocks_probe_signal_x_0 = blocks.probe_signal_f()
        self.video_sdl_sink_1 = video_sdl.sink_s(0, columns, rows, 0, columns*6, rows*6)
        self._variable_qtgui_label_0_0_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_0_0_formatter = None
        else:
            self._variable_qtgui_label_0_0_0_formatter = lambda x: str(x)

        self._variable_qtgui_label_0_0_0_tool_bar.addWidget(Qt.QLabel('Probe Signal Min' + ": "))
        self._variable_qtgui_label_0_0_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_0_0_formatter(self.variable_qtgui_label_0_0_0)))
        self._variable_qtgui_label_0_0_0_tool_bar.addWidget(self._variable_qtgui_label_0_0_0_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_0_0_tool_bar)
        self._variable_qtgui_label_0_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_0_formatter = None
        else:
            self._variable_qtgui_label_0_0_formatter = lambda x: str(x)

        self._variable_qtgui_label_0_0_tool_bar.addWidget(Qt.QLabel('Probe Signal Max' + ": "))
        self._variable_qtgui_label_0_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_0_formatter(self.variable_qtgui_label_0_0)))
        self._variable_qtgui_label_0_0_tool_bar.addWidget(self._variable_qtgui_label_0_0_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_0_tool_bar)
        def _variable_function_probe_0_0_probe():
            while True:

                val = self.blocks_probe_signal_x_0_0.level()
                try:
                    self.set_variable_function_probe_0_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1))
        _variable_function_probe_0_0_thread = threading.Thread(target=_variable_function_probe_0_0_probe)
        _variable_function_probe_0_0_thread.daemon = True
        _variable_function_probe_0_0_thread.start()

        def _variable_function_probe_0_probe():
            while True:

                val = self.blocks_probe_signal_x_0.level()
                try:
                    self.set_variable_function_probe_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1))
        _variable_function_probe_0_thread = threading.Thread(target=_variable_function_probe_0_probe)
        _variable_function_probe_0_thread.daemon = True
        _variable_function_probe_0_thread.start()

        self.qtgui_time_raster_sink_x_0 = qtgui.time_raster_sink_f(
            samp_rate,
            columns,
            rows,
            [],
            [],
            "",
            1
        )

        self.qtgui_time_raster_sink_x_0.set_update_time(0.01)
        self.qtgui_time_raster_sink_x_0.set_intensity_range(0, 5)
        self.qtgui_time_raster_sink_x_0.enable_grid(False)
        self.qtgui_time_raster_sink_x_0.enable_axis_labels(True)

        labels = ['', '', '', '', '',
            '', '', '', '', '']
        colors = [1, 1, 0, 0, 0,
            0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
            1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_time_raster_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_raster_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_raster_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_time_raster_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_raster_sink_x_0_win = sip.wrapinstance(self.qtgui_time_raster_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_raster_sink_x_0_win)
        self._degreesTXR_range = Range(0, maxtheta/2, 5, 0, 200)
        self._degreesTXR_win = RangeWidget(self._degreesTXR_range, self.set_degreesTXR, 'degreesTXR', "counter_slider", float)
        self.top_grid_layout.addWidget(self._degreesTXR_win)
        self._degreesTXL_range = Range(0, maxtheta/2, 5, 0, 200)
        self._degreesTXL_win = RangeWidget(self._degreesTXL_range, self.set_degreesTXL, 'degreesTXL', "counter_slider", float)
        self.top_grid_layout.addWidget(self._degreesTXL_win)
        self.blocks_vector_source_x_0_0_0_0 = blocks.vector_source_f(right, True, 1, [])
        self.blocks_vector_source_x_0_0_0 = blocks.vector_source_f(left, True, 1, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_sub_xx_0_0_0 = blocks.sub_ff(1)
        self.blocks_sub_xx_0_0 = blocks.sub_ff(1)
        self.blocks_stream_to_vector_0_1 = blocks.stream_to_vector(gr.sizeof_float*1, samp_rate)
        self.blocks_repeat_0_0_0_0_1 = blocks.repeat(gr.sizeof_float*1, columns)
        self.blocks_repeat_0_0_0_0_0_1 = blocks.repeat(gr.sizeof_float*1, columns)
        self.blocks_repeat_0_0_0_0_0 = blocks.repeat(gr.sizeof_float*1, columns)
        self.blocks_repeat_0_0_0_0 = blocks.repeat(gr.sizeof_float*1, columns)
        self.blocks_multiply_const_vxx_0_0_1 = blocks.multiply_const_cc(complex(math.cos(angle_radiansStartR),math.sin(angle_radiansStartR)))
        self.blocks_multiply_const_vxx_0_0_0_0 = blocks.multiply_const_cc(complex(math.cos(angle_radiansStartL),math.sin(angle_radiansStartL)))
        self.blocks_min_xx_0 = blocks.min_ff(samp_rate,1)
        self.blocks_max_xx_0 = blocks.max_ff(samp_rate, 1)
        self.blocks_magphase_to_complex_0_0_0_0_0 = blocks.magphase_to_complex(1)
        self.blocks_magphase_to_complex_0_0_0_0 = blocks.magphase_to_complex(1)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, scale)
        self.blocks_complex_to_magphase_0_0_0_0 = blocks.complex_to_magphase(1)
        self.blocks_complex_to_magphase_0_0_0 = blocks.complex_to_magphase(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1e3, 1, 0, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_float_to_short_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_stream_to_vector_0_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_raster_sink_x_0, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0, 0), (self.blocks_repeat_0_0_0_0, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0, 1), (self.blocks_repeat_0_0_0_0_0, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0_0, 1), (self.blocks_repeat_0_0_0_0_0_1, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0_0, 0), (self.blocks_repeat_0_0_0_0_1, 0))
        self.connect((self.blocks_float_to_short_0, 0), (self.video_sdl_sink_1, 0))
        self.connect((self.blocks_magphase_to_complex_0_0_0_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_magphase_to_complex_0_0_0_0_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_max_xx_0, 0), (self.blocks_probe_signal_x_0, 0))
        self.connect((self.blocks_min_xx_0, 0), (self.blocks_probe_signal_x_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0_0_0, 0), (self.blocks_complex_to_magphase_0_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0_1, 0), (self.blocks_complex_to_magphase_0_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0, 0), (self.blocks_magphase_to_complex_0_0_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0_0, 0), (self.blocks_sub_xx_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0_0_1, 0), (self.blocks_sub_xx_0_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0_1, 0), (self.blocks_magphase_to_complex_0_0_0_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0_1, 0), (self.blocks_max_xx_0, 0))
        self.connect((self.blocks_stream_to_vector_0_1, 0), (self.blocks_min_xx_0, 0))
        self.connect((self.blocks_sub_xx_0_0, 0), (self.blocks_magphase_to_complex_0_0_0_0, 1))
        self.connect((self.blocks_sub_xx_0_0_0, 0), (self.blocks_magphase_to_complex_0_0_0_0_0, 1))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0_0_0_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0_0_1, 0))
        self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_sub_xx_0_0, 1))
        self.connect((self.blocks_vector_source_x_0_0_0_0, 0), (self.blocks_sub_xx_0_0_0, 1))
예제 #25
0
    def __init__(self):
        gr.top_block.__init__(self, "Wwv X310 Corr 1")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Wwv X310 Corr 1")
        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", "wwv_x310_corr_1")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y-%m-%dT%H:%M:%S.%fZ")
        self.y_min = y_min = -60
        self.y_max = y_max = 0
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = ts_str
        self.samp_rate = samp_rate = 500e3
        self.rx_freq = rx_freq = 4.51e6
        self.nfft = nfft = 1024*32
        self.lpf_cutoff = lpf_cutoff = 50e3
        self.delay = delay = 0
        self.decim = decim = 1
        self.decay_rate = decay_rate = 20e-3
        self.c_ms = c_ms = 299792458

        ##################################################
        # Blocks
        ##################################################
        self.main_tab = Qt.QTabWidget()
        self.main_tab_widget_0 = Qt.QWidget()
        self.main_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_0)
        self.main_tab_grid_layout_0 = Qt.QGridLayout()
        self.main_tab_layout_0.addLayout(self.main_tab_grid_layout_0)
        self.main_tab.addTab(self.main_tab_widget_0, 'Main')
        self.main_tab_widget_1 = Qt.QWidget()
        self.main_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_1)
        self.main_tab_grid_layout_1 = Qt.QGridLayout()
        self.main_tab_layout_1.addLayout(self.main_tab_grid_layout_1)
        self.main_tab.addTab(self.main_tab_widget_1, 'Corr')
        self.top_grid_layout.addWidget(self.main_tab, 1, 0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._y_min_tool_bar = Qt.QToolBar(self)
        self._y_min_tool_bar.addWidget(Qt.QLabel('FREQ'+": "))
        self._y_min_line_edit = Qt.QLineEdit(str(self.y_min))
        self._y_min_tool_bar.addWidget(self._y_min_line_edit)
        self._y_min_line_edit.returnPressed.connect(
        	lambda: self.set_y_min(eng_notation.str_to_num(str(self._y_min_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_0.addWidget(self._y_min_tool_bar, 8, 4, 1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(4, 5):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self._y_max_tool_bar = Qt.QToolBar(self)
        self._y_max_tool_bar.addWidget(Qt.QLabel('FREQ'+": "))
        self._y_max_line_edit = Qt.QLineEdit(str(self.y_max))
        self._y_max_tool_bar.addWidget(self._y_max_line_edit)
        self._y_max_line_edit.returnPressed.connect(
        	lambda: self.set_y_max(eng_notation.str_to_num(str(self._y_max_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_0.addWidget(self._y_max_tool_bar, 8, 5, 1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(5, 6):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel('SAMP_RATE'+": "))
        self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate))
        self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit)
        self._samp_rate_line_edit.returnPressed.connect(
        	lambda: self.set_samp_rate(eng_notation.str_to_num(str(self._samp_rate_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_0.addWidget(self._samp_rate_tool_bar, 8, 0, 1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 1):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self._rx_freq_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ'+": "))
        self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit)
        self._rx_freq_line_edit.returnPressed.connect(
        	lambda: self.set_rx_freq(eng_notation.str_to_num(str(self._rx_freq_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_0.addWidget(self._rx_freq_tool_bar, 8, 1, 1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(1, 2):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self._lpf_cutoff_tool_bar = Qt.QToolBar(self)
        self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel("lpf_cutoff"+": "))
        self._lpf_cutoff_line_edit = Qt.QLineEdit(str(self.lpf_cutoff))
        self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_line_edit)
        self._lpf_cutoff_line_edit.returnPressed.connect(
        	lambda: self.set_lpf_cutoff(eng_notation.str_to_num(str(self._lpf_cutoff_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_0.addWidget(self._lpf_cutoff_tool_bar, 8, 3, 1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(3, 4):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self._delay_tool_bar = Qt.QToolBar(self)
        self._delay_tool_bar.addWidget(Qt.QLabel('corr_delay'+": "))
        self._delay_line_edit = Qt.QLineEdit(str(self.delay))
        self._delay_tool_bar.addWidget(self._delay_line_edit)
        self._delay_line_edit.returnPressed.connect(
        	lambda: self.set_delay(eng_notation.str_to_num(str(self._delay_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_1.addWidget(self._delay_tool_bar, 8, 0, 1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 1):
            self.main_tab_grid_layout_1.setColumnStretch(c, 1)
        self._decay_rate_options = (100e-6, 65e-3, 20e-3, )
        self._decay_rate_labels = ('Fast', 'Medium', 'Slow', )
        self._decay_rate_group_box = Qt.QGroupBox("decay_rate")
        self._decay_rate_box = Qt.QHBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._decay_rate_button_group = variable_chooser_button_group()
        self._decay_rate_group_box.setLayout(self._decay_rate_box)
        for i, label in enumerate(self._decay_rate_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._decay_rate_box.addWidget(radio_button)
        	self._decay_rate_button_group.addButton(radio_button, i)
        self._decay_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._decay_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._decay_rate_options.index(i)))
        self._decay_rate_callback(self.decay_rate)
        self._decay_rate_button_group.buttonClicked[int].connect(
        	lambda i: self.set_decay_rate(self._decay_rate_options[i]))
        self.main_tab_grid_layout_0.addWidget(self._decay_rate_group_box, 8, 2, 1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(2, 3):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self)

        if None:
          self._variable_qtgui_label_0_formatter = None
        else:
          self._variable_qtgui_label_0_formatter = lambda x: str(x)

        self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel('Start Time [UTC]'+": "))
        self._variable_qtgui_label_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_formatter(self.variable_qtgui_label_0)))
        self._variable_qtgui_label_0_tool_bar.addWidget(self._variable_qtgui_label_0_label)
        self.main_tab_grid_layout_0.addWidget(self._variable_qtgui_label_0_tool_bar, 8, 6, 1, 2)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(6, 8):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.uhd_usrp_source_1 = uhd.usrp_source(
        	",".join(("addr=192.168.10.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(2),
        	),
        )
        self.uhd_usrp_source_1.set_clock_source('gpsdo', 0)
        self.uhd_usrp_source_1.set_time_source('gpsdo', 0)
        self.uhd_usrp_source_1.set_subdev_spec('A:AB B:AB', 0)
        self.uhd_usrp_source_1.set_samp_rate(samp_rate)
        self.uhd_usrp_source_1.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 0)
        self.uhd_usrp_source_1.set_gain(0, 0)
        self.uhd_usrp_source_1.set_antenna('A', 0)
        self.uhd_usrp_source_1.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_1.set_auto_iq_balance(True, 0)
        self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 1)
        self.uhd_usrp_source_1.set_gain(0, 1)
        self.uhd_usrp_source_1.set_antenna('A', 1)
        self.uhd_usrp_source_1.set_auto_dc_offset(True, 1)
        self.uhd_usrp_source_1.set_auto_iq_balance(True, 1)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=decim,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=decim,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	rx_freq, #fc
        	samp_rate / decim, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True)

        if not True:
          self.qtgui_waterfall_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        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_waterfall_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, -40)

        self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 4, 4, 4, 4)
        for r in range(4, 8):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(4, 8):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	rx_freq, #fc
        	samp_rate / decim, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        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_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, -40)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 4, 0, 4, 4)
        for r in range(4, 8):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 4):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
        	10, #size
        	samp_rate/decim, #samp_rate
        	"", #name
        	2 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.010)
        self.qtgui_time_sink_x_0_0.set_y_axis(-20, 20)

        self.qtgui_time_sink_x_0_0.set_y_label('Range Delta [km]', "")

        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(False)
        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 = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            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.main_tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win, 4, 0, 2, 4)
        for r in range(4, 6):
            self.main_tab_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 4):
            self.main_tab_grid_layout_1.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	nfft, #size
        	samp_rate/decim, #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('Correlation', "")

        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(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(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(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            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.main_tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 4, 4, 4)
        for r in range(0, 4):
            self.main_tab_grid_layout_1.setRowStretch(r, 1)
        for c in range(4, 8):
            self.main_tab_grid_layout_1.setColumnStretch(c, 1)
        self.qtgui_number_sink_0 = qtgui.number_sink(
            gr.sizeof_float,
            0,
            qtgui.NUM_GRAPH_NONE,
            3
        )
        self.qtgui_number_sink_0.set_update_time(0.010)
        self.qtgui_number_sink_0.set_title("")

        labels = ['Delay', '', 'Range Delta', '', '',
                  '', '', '', '', '']
        units = ['[usec]', '', '[km]', '', '',
                 '', '', '', '', '']
        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(3):
            self.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            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(True)
        self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_1.addWidget(self._qtgui_number_sink_0_win, 6, 0, 1, 2)
        for r in range(6, 7):
            self.main_tab_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 2):
            self.main_tab_grid_layout_1.setColumnStretch(c, 1)
        self.qtgui_histogram_sink_x_0_0 = qtgui.histogram_sink_f(
        	20,
        	1000,
                0,
                100e4,
        	"",
        	1
        )

        self.qtgui_histogram_sink_x_0_0.set_update_time(0.010)
        self.qtgui_histogram_sink_x_0_0.enable_autoscale(True)
        self.qtgui_histogram_sink_x_0_0.enable_accumulate(True)
        self.qtgui_histogram_sink_x_0_0.enable_grid(False)
        self.qtgui_histogram_sink_x_0_0.enable_axis_labels(True)

        if not True:
          self.qtgui_histogram_sink_x_0_0.disable_legend()

        labels = ['Correlation Magnitude', 'Corr Mag', '', '', '',
                  '', '', '', '', '']
        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(1):
            if len(labels[i]) == 0:
                self.qtgui_histogram_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_histogram_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_histogram_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_histogram_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_histogram_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_histogram_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_histogram_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_histogram_sink_x_0_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_1.addWidget(self._qtgui_histogram_sink_x_0_0_win, 0, 0, 4, 4)
        for r in range(0, 4):
            self.main_tab_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 4):
            self.main_tab_grid_layout_1.setColumnStretch(c, 1)
        self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f(
        	20,
        	2000,
                -25*1/(samp_rate/decim) *c_ms / 1000.0,
                25*1/(samp_rate/decim) *c_ms / 1000.0,
        	"",
        	1
        )

        self.qtgui_histogram_sink_x_0.set_update_time(0.010)
        self.qtgui_histogram_sink_x_0.enable_autoscale(True)
        self.qtgui_histogram_sink_x_0.enable_accumulate(True)
        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 = ['Range Delta [km]', 'Corr Mag', '', '', '',
                  '', '', '', '', '']
        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(1):
            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.main_tab_grid_layout_1.addWidget(self._qtgui_histogram_sink_x_0_win, 4, 4, 2, 4)
        for r in range(4, 6):
            self.main_tab_grid_layout_1.setRowStretch(r, 1)
        for c in range(4, 8):
            self.main_tab_grid_layout_1.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	rx_freq, #fc
        	samp_rate /decim, #bw
        	"E/W Dipole", #name
        	2 #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0_0.set_y_axis(y_min, y_max)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True)

        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"]
        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_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 4, 4, 4)
        for r in range(0, 4):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(4, 8):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	rx_freq, #fc
        	samp_rate / decim, #bw
        	"N/S Dipole", #name
        	2 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0.set_y_axis(y_min, y_max)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        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"]
        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_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4)
        for r in range(0, 4):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 4):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.low_pass_filter_1 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate/decim, lpf_cutoff, 1e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate/decim, lpf_cutoff, 1e3, firdes.WIN_HAMMING, 6.76))
        self.fft_vxx_2 = fft.fft_vcc(nfft, True, (window.blackmanharris(nfft)), True, 4)
        self.fft_vxx_1 = fft.fft_vcc(nfft, False, (window.blackmanharris(nfft)), False, 4)
        self.fft_vxx_0 = fft.fft_vcc(nfft, False, (window.blackmanharris(nfft)), False, 4)
        self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_float*1, nfft)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, nfft)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, nfft)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short*1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((1/(samp_rate/decim) *c_ms / 1000.0, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1/(samp_rate/decim) * 1e6, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(nfft)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10, .1, 4000, 1)
        self.blocks_max_xx_0 = blocks.max_ff(nfft,1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(delay))
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(nfft)
        self.blocks_argmax_xx_0 = blocks.argmax_fs(nfft)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-nfft/2.0, ))
        self.analog_agc2_xx_0_0 = analog.agc2_cc(decay_rate, decay_rate, 1.0, .5)
        self.analog_agc2_xx_0_0.set_max_gain(65536)
        self.analog_agc2_xx_0 = analog.agc2_cc(decay_rate, decay_rate, 1.0, .5)
        self.analog_agc2_xx_0.set_max_gain(65536)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.analog_agc2_xx_0_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_short_to_float_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_argmax_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_max_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_vector_to_stream_1, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_stream_to_vector_1, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.qtgui_histogram_sink_x_0_0, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.qtgui_number_sink_0, 1))
        self.connect((self.blocks_max_xx_0, 0), (self.qtgui_time_sink_x_0_0, 1))
        self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_histogram_sink_x_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_number_sink_0, 2))
        self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.fft_vxx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_short_to_float_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_1, 0), (self.fft_vxx_1, 0))
        self.connect((self.blocks_vector_to_stream_1, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.fft_vxx_1, 0), (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.fft_vxx_2, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.low_pass_filter_1, 0), (self.blocks_delay_0, 0))
        self.connect((self.low_pass_filter_1, 0), (self.qtgui_freq_sink_x_0_0, 1))
        self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_1, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.uhd_usrp_source_1, 1), (self.analog_agc2_xx_0_0, 0))
예제 #26
0
    def __init__(self, seq1, seq2, factor, alpha, freqs):
        """
        Description:
frequency timing estimator class does frequency/timing acquisition from scratch.It uses a bank of parallel correlators at each specified frequency. It then takes the max abs value of all these and passes it through a peak detector to find timing.


        Args:
	     seq1: sequence1 of kronecker filter, which is the given training sequence. 
	     seq2: sequence2 of kronecker filter, which is the pulse for each training symbol.
             factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended.  In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak.
             alpha: the smoothing factor of a moving average filter used in the peak detector taking values in (0,1).
             freqs: the vector of normalized center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt).
        """

        gr.hier_block2.__init__(
            self,
            "freq_timing_estimator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signaturev(
                3, 3,
                [gr.sizeof_char * 1, gr.sizeof_float * 1, gr.sizeof_float * 1
                 ]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.seq1 = seq1
        self.seq2 = seq2
        self.factor = factor
        self.alpha = alpha
        self.freqs = freqs
        self.n = n = len(freqs)
        self.on = 1

        ##################################################
        # Blocks
        ##################################################
        self._filter = [0] * self.n
        self._c2mag2 = [0] * self.n
        for i in range(self.n):
            #self._filter[i]= cdma.kronecker_filter(seq1,seq2,1,self.freqs[i])
            #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1)
            self._filter[i] = filter.freq_xlating_fft_filter_ccc(
                1, numpy.kron(seq1, seq2), self.freqs[i], 1)
            self._c2mag2[i] = blocks.complex_to_mag_squared(1)

        self.blocks_max = blocks.max_ff(1)
        self.blocks_peak_detector = cdma.switched_peak_detector_fb(
            self.factor, self.factor, 0, self.alpha, self.on)

        self.blocks_argmax = blocks.argmax_fs(1)
        self.blocks_null_sink = blocks.null_sink(gr.sizeof_short * 1)
        self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs),
                                                                      1)
        self.blocks_sample_and_hold = blocks.sample_and_hold_ff()

        ##################################################
        # Connections
        ##################################################
        for i in range(self.n):
            self.connect((self, 0), (self._filter[i], 0))
            self.connect((self._filter[i], 0), (self._c2mag2[i], 0))
            self.connect((self._c2mag2[i], 0), (self.blocks_max, i))
            self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i))
        self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0))
        self.connect((self.blocks_peak_detector, 0), (self, 0))
        self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0))
        self.connect((self.blocks_argmax, 1),
                     (self.digital_chunks_to_symbols, 0))
        self.connect((self.digital_chunks_to_symbols, 0),
                     (self.blocks_sample_and_hold, 0))
        self.connect((self.blocks_peak_detector, 0),
                     (self.blocks_sample_and_hold, 1))
        self.connect((self.blocks_sample_and_hold, 0), (self, 1))
        self.connect((self.blocks_max, 0), (self, 2))
예제 #27
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Grc Receiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.value = value = -55
        self.station_frequency = station_frequency = 88000000
        self.samp_rate = samp_rate = 2000000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f(
            self.GetWin(),
            unit='Units',
            minval=-100,
            maxval=100,
            factor=1.0,
            decimal_places=10,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=2000000,
            average=False,
            avg_alpha=None,
            label='Number Plot',
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=88000000,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rtlsdr_source_1 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              '')
        self.rtlsdr_source_1.set_sample_rate(samp_rate)
        self.rtlsdr_source_1.set_center_freq(100e6, 0)
        self.rtlsdr_source_1.set_freq_corr(0, 0)
        self.rtlsdr_source_1.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_1.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_1.set_gain_mode(False, 0)
        self.rtlsdr_source_1.set_gain(10, 0)
        self.rtlsdr_source_1.set_if_gain(20, 0)
        self.rtlsdr_source_1.set_bb_gain(20, 0)
        self.rtlsdr_source_1.set_antenna('', 0)
        self.rtlsdr_source_1.set_bandwidth(0, 0)

        self.module1_comparator_py_f_0 = module1.comparator_py_f(value)
        self.logpwrfft_x_0 = logpwrfft.logpwrfft_c(
            sample_rate=samp_rate,
            fft_size=512,
            ref_scale=2,
            frame_rate=30,
            avg_alpha=1.0,
            average=False,
        )
        self.blocks_max_xx_0 = blocks.max_ff(512, 1)
        self.band_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.band_pass(1, samp_rate, 1000, 10000, 10000,
                             firdes.WIN_HAMMING, 6.76))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.band_pass_filter_0, 0), (self.logpwrfft_x_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.blocks_max_xx_0, 0),
                     (self.module1_comparator_py_f_0, 0))
        self.connect((self.blocks_max_xx_0, 0),
                     (self.wxgui_numbersink2_0_0, 0))
        self.connect((self.logpwrfft_x_0, 0), (self.blocks_max_xx_0, 0))
        self.connect((self.rtlsdr_source_1, 0), (self.band_pass_filter_0, 0))
예제 #28
0
    def __init__(self, avg_len=256, nfft=2048, path="/captures/20200329", record_hz=10):
        gr.top_block.__init__(self, "/captures/20200329/LRO_RHCP_2020-03-29T20:34:45Z.sigmf-data")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("/captures/20200329/LRO_RHCP_2020-03-29T20:34:45Z.sigmf-data")
        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", "lro_playback")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Parameters
        ##################################################
        self.avg_len = avg_len
        self.nfft = nfft
        self.path = path
        self.record_hz = record_hz

        ##################################################
        # Variables
        ##################################################
        self.probe_snr_func = probe_snr_func = 0
        self.probe_signal_func = probe_signal_func = 0
        self.probe_offset_func = probe_offset_func = 0
        self.probe_noise_func = probe_noise_func = 0
        self.filename = filename = "LRO_RHCP_2020-03-29T20:34:45Z.sigmf-data"
        self.snr_var = snr_var = "{:3.3f}".format(probe_snr_func)
        self.signal_var = signal_var = "{:3.3f}".format(probe_signal_func)
        self.samp_rate = samp_rate = 250e3
        self.offset_var = offset_var = "{:3.3f}".format(probe_offset_func)
        self.offset_file = offset_file = "{:s}_{:s}".format(filename.split(".")[0], "offset")
        self.noise_var = noise_var = "{:3.3f}".format(probe_noise_func)
        self.variable_tag_object_0 = variable_tag_object_0 = gr.tag_utils.python_to_tag((0, pmt.intern("key"), pmt.intern("value"), pmt.intern("src")))
        self.throttle_factor = throttle_factor = 10
        self.snr_label = snr_label = snr_var
        self.signal_label = signal_label = signal_var
        self.rx_freq = rx_freq = 2271.2e6
        self.offset_label = offset_label = offset_var
        self.offset_fp = offset_fp = "/".join([path,offset_file])
        self.noise_label = noise_label = noise_var
        self.keep_n = keep_n = samp_rate/record_hz
        self.fp = fp = "/".join([path,filename])
        self.file_l = file_l = filename.split(".")[0].split("_")
        self.fft_min = fft_min = -120
        self.fft_max = fft_max = -80
        self.decim = decim = 8
        self.alpha = alpha = 1.0/(samp_rate/record_hz)

        ##################################################
        # Blocks
        ##################################################
        self.probe_offset = blocks.probe_signal_f()
        self._throttle_factor_tool_bar = Qt.QToolBar(self)
        self._throttle_factor_tool_bar.addWidget(Qt.QLabel('Throttle'+": "))
        self._throttle_factor_line_edit = Qt.QLineEdit(str(self.throttle_factor))
        self._throttle_factor_tool_bar.addWidget(self._throttle_factor_line_edit)
        self._throttle_factor_line_edit.returnPressed.connect(
        	lambda: self.set_throttle_factor(eng_notation.str_to_num(str(self._throttle_factor_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._throttle_factor_tool_bar, 10, 2, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel('SAMP_RATE'+": "))
        self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate))
        self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit)
        self._samp_rate_line_edit.returnPressed.connect(
        	lambda: self.set_samp_rate(eng_notation.str_to_num(str(self._samp_rate_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 9, 0, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.probe_snr = blocks.probe_signal_f()
        self.probe_signal = blocks.probe_signal_f()

        def _probe_offset_func_probe():
            while True:
                val = self.probe_offset.level()
                try:
                    self.set_probe_offset_func(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))
        _probe_offset_func_thread = threading.Thread(target=_probe_offset_func_probe)
        _probe_offset_func_thread.daemon = True
        _probe_offset_func_thread.start()

        self.probe_noise = blocks.probe_signal_f()
        self._fft_min_tool_bar = Qt.QToolBar(self)
        self._fft_min_tool_bar.addWidget(Qt.QLabel('fft_min'+": "))
        self._fft_min_line_edit = Qt.QLineEdit(str(self.fft_min))
        self._fft_min_tool_bar.addWidget(self._fft_min_line_edit)
        self._fft_min_line_edit.returnPressed.connect(
        	lambda: self.set_fft_min(eng_notation.str_to_num(str(self._fft_min_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._fft_min_tool_bar, 9, 2, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._fft_max_tool_bar = Qt.QToolBar(self)
        self._fft_max_tool_bar.addWidget(Qt.QLabel('fft_max'+": "))
        self._fft_max_line_edit = Qt.QLineEdit(str(self.fft_max))
        self._fft_max_tool_bar.addWidget(self._fft_max_line_edit)
        self._fft_max_line_edit.returnPressed.connect(
        	lambda: self.set_fft_max(eng_notation.str_to_num(str(self._fft_max_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._fft_max_tool_bar, 9, 3, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._snr_label_tool_bar = Qt.QToolBar(self)

        if None:
          self._snr_label_formatter = None
        else:
          self._snr_label_formatter = lambda x: str(x)

        self._snr_label_tool_bar.addWidget(Qt.QLabel('SNR [dB]'+": "))
        self._snr_label_label = Qt.QLabel(str(self._snr_label_formatter(self.snr_label)))
        self._snr_label_tool_bar.addWidget(self._snr_label_label)
        self.top_grid_layout.addWidget(self._snr_label_tool_bar, 3, 4, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._signal_label_tool_bar = Qt.QToolBar(self)

        if None:
          self._signal_label_formatter = None
        else:
          self._signal_label_formatter = lambda x: str(x)

        self._signal_label_tool_bar.addWidget(Qt.QLabel('Signal [dBFS]'+": "))
        self._signal_label_label = Qt.QLabel(str(self._signal_label_formatter(self.signal_label)))
        self._signal_label_tool_bar.addWidget(self._signal_label_label)
        self.top_grid_layout.addWidget(self._signal_label_tool_bar, 1, 4, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.sigmf_source_0 = gr_sigmf.source(fp, "cf32" + ("_le" if sys.byteorder == "little" else "_be"), False)
        self._rx_freq_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ'+": "))
        self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit)
        self._rx_freq_line_edit.returnPressed.connect(
        	lambda: self.set_rx_freq(eng_notation.str_to_num(str(self._rx_freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 9, 1, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=decim,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        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_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(fft_min, fft_max)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 4, 0, 4, 4)
        for r in range(4, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"RHCP", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0.set_y_axis(fft_min, fft_max)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.05)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        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"]
        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_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)

        def _probe_snr_func_probe():
            while True:
                val = self.probe_snr.level()
                try:
                    self.set_probe_snr_func(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))
        _probe_snr_func_thread = threading.Thread(target=_probe_snr_func_probe)
        _probe_snr_func_thread.daemon = True
        _probe_snr_func_thread.start()


        def _probe_signal_func_probe():
            while True:
                val = self.probe_signal.level()
                try:
                    self.set_probe_signal_func(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))
        _probe_signal_func_thread = threading.Thread(target=_probe_signal_func_probe)
        _probe_signal_func_thread.daemon = True
        _probe_signal_func_thread.start()


        def _probe_noise_func_probe():
            while True:
                val = self.probe_noise.level()
                try:
                    self.set_probe_noise_func(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))
        _probe_noise_func_thread = threading.Thread(target=_probe_noise_func_probe)
        _probe_noise_func_thread.daemon = True
        _probe_noise_func_thread.start()

        self._offset_label_tool_bar = Qt.QToolBar(self)

        if None:
          self._offset_label_formatter = None
        else:
          self._offset_label_formatter = lambda x: str(x)

        self._offset_label_tool_bar.addWidget(Qt.QLabel('Offset [Hz]'+": "))
        self._offset_label_label = Qt.QLabel(str(self._offset_label_formatter(self.offset_label)))
        self._offset_label_tool_bar.addWidget(self._offset_label_label)
        self.top_grid_layout.addWidget(self._offset_label_tool_bar, 0, 4, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._noise_label_tool_bar = Qt.QToolBar(self)

        if None:
          self._noise_label_formatter = None
        else:
          self._noise_label_formatter = lambda x: str(x)

        self._noise_label_tool_bar.addWidget(Qt.QLabel('Noise [dBFS]'+": "))
        self._noise_label_label = Qt.QLabel(str(self._noise_label_formatter(self.noise_label)))
        self._noise_label_tool_bar.addWidget(self._noise_label_label)
        self.top_grid_layout.addWidget(self._noise_label_tool_bar, 2, 4, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._keep_n_tool_bar = Qt.QToolBar(self)
        self._keep_n_tool_bar.addWidget(Qt.QLabel('keep_n'+": "))
        self._keep_n_line_edit = Qt.QLineEdit(str(self.keep_n))
        self._keep_n_tool_bar.addWidget(self._keep_n_line_edit)
        self._keep_n_line_edit.returnPressed.connect(
        	lambda: self.set_keep_n(eng_notation.str_to_num(str(self._keep_n_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._keep_n_tool_bar, 10, 1, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.fft_vxx_0_0 = fft.fft_vcc(nfft/decim, True, (window.blackmanharris(nfft/decim)), True, 4)
        self.fft_vxx_0 = fft.fft_vcc(nfft, True, (window.blackmanharris(nfft)), True, 4)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate*throttle_factor,True)
        self.blocks_tag_share_0 = blocks.tag_share(gr.sizeof_float, gr.sizeof_gr_complex, 1)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, nfft/decim)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, nfft)
        self.blocks_nlog10_ff_0_0_0 = blocks.nlog10_ff(10, nfft/decim, -10*math.log10(nfft/decim))
        self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, nfft, -10*math.log10(nfft))
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((samp_rate/(2*math.pi), ))
        self.blocks_moving_average_xx_0_1 = blocks.moving_average_ff(int(samp_rate/record_hz), 1.0/(samp_rate/record_hz), 4000, 1)
        self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff(int(avg_len), 1.0/(avg_len)/(nfft/decim*2), 4000, nfft/decim)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int(avg_len), 1.0/(avg_len)/nfft, 4000, nfft)
        self.blocks_max_xx_0_0 = blocks.max_ff(nfft/decim,1)
        self.blocks_max_xx_0 = blocks.max_ff(nfft,1)
        self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n(gr.sizeof_float*1, int(samp_rate/record_hz))
        self.blocks_complex_to_mag_squared_0_0_0 = blocks.complex_to_mag_squared(nfft/decim)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(nfft)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, probe_offset_func+samp_rate/4, 1, 0)
        self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf(math.pi/200, math.pi/10, -math.pi/10)
        self._alpha_tool_bar = Qt.QToolBar(self)
        self._alpha_tool_bar.addWidget(Qt.QLabel('alpha'+": "))
        self._alpha_line_edit = Qt.QLineEdit(str(self.alpha))
        self._alpha_tool_bar.addWidget(self._alpha_line_edit)
        self._alpha_line_edit.returnPressed.connect(
        	lambda: self.set_alpha(eng_notation.str_to_num(str(self._alpha_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._alpha_tool_bar, 10, 0, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_pll_freqdet_cf_0, 0), (self.blocks_tag_share_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0_0, 0), (self.blocks_moving_average_xx_0_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.probe_offset, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.probe_signal, 0))
        self.connect((self.blocks_max_xx_0_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_max_xx_0_0, 0), (self.probe_noise, 0))
        self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_nlog10_ff_0_0, 0))
        self.connect((self.blocks_moving_average_xx_0_0, 0), (self.blocks_nlog10_ff_0_0_0, 0))
        self.connect((self.blocks_moving_average_xx_0_1, 0), (self.blocks_keep_one_in_n_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_moving_average_xx_0_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_nlog10_ff_0_0, 0), (self.blocks_max_xx_0, 0))
        self.connect((self.blocks_nlog10_ff_0_0_0, 0), (self.blocks_max_xx_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_0_0, 0), (self.fft_vxx_0_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.probe_snr, 0))
        self.connect((self.blocks_tag_share_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.analog_pll_freqdet_cf_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_tag_share_0, 1))
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.fft_vxx_0_0, 0), (self.blocks_complex_to_mag_squared_0_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_stream_to_vector_0_0, 0))
        self.connect((self.sigmf_source_0, 0), (self.blocks_throttle_0, 0))
예제 #29
0
    def __init__(self, seq1, seq2, factor, alpha, samp_rate, freqs):
        """
        Description:

        This block is functionally equivalent to the frequency_timing_estimator block, except from the fact that each filter is matched to a sequence that can be written as the kronecker product of seq1 and seq2.

        Args:
	     seq1: sequence1 of kronecker filter, which is the given training sequence. 
	     seq2: sequence2 of kronecker filter, which is the pulse for each training symbol.
             factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended.  In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak. factor takes values in (0,1). 
             alpha: the smoothing factor of a moving average filter used in the peak detector takeng values in (0,1).
             samp_rate: the sample rate of the system, which is used in the kronecker_filter.
             freqs: the vector of center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt).
        """

        gr.hier_block2.__init__(self,
            "freq_timing_estimator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.seq1 = seq1
        self.seq2 = seq2
        self.factor = factor
        self.alpha = alpha
        self.samp_rate = samp_rate
        self.freqs = freqs
        self.n = n = len(freqs)

        ##################################################
        # Blocks
        ##################################################
        self._filter=[0]*self.n
        self._c2mag2=[0]*self.n
        for i in range(self.n):
          self._filter[i]= cdma.kronecker_filter(seq1,seq2,samp_rate,self.freqs[i])
          #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, (numpy.conjugate(self.ts[::-1])), self.freqs[i], self.samp_rate)
          self._c2mag2[i] = blocks.complex_to_mag_squared(1)

        self.blocks_max = blocks.max_ff(1)
        self.blocks_peak_detector = blocks.peak_detector_fb(self.factor, self.factor, 0, self.alpha)

        self.blocks_argmax = blocks.argmax_fs(1)
        self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1)
        self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1)
        self.blocks_sample_and_hold = blocks.sample_and_hold_ff()

        ##################################################
        # Connections
        ##################################################
        for i in range(self.n):
          self.connect((self, 0), (self._filter[i], 0))
          self.connect((self._filter[i], 0), (self._c2mag2[i], 0))
          self.connect((self._c2mag2[i], 0), (self.blocks_max, i))
          self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i))
        self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0))
        self.connect((self.blocks_peak_detector, 0), (self, 0))
        self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0))
        self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0))
        self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0))
        self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1))
        self.connect((self.blocks_sample_and_hold, 0), (self, 1))
        self.connect((self.blocks_max, 0), (self, 2))
예제 #30
0
    def __init__(self):
        gr.top_block.__init__(self, "twodimension_usrp_b210s")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("twodimension_usrp_b210s")
        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", "twodimension_usrp_b210s")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.maxtheta = maxtheta = 150
        self.columns = columns = 100
        self.shiftarrL = shiftarrL = np.radians(
            np.linspace(start=maxtheta,
                        stop=0,
                        num=int(columns / 2),
                        endpoint=False))
        self.left = left = np.pad(shiftarrL, (0, int(columns / 2)), 'constant')
        self.variable_function_probe_0_0 = variable_function_probe_0_0 = 0
        self.variable_function_probe_0 = variable_function_probe_0 = 1
        self.right = right = np.flip(left, axis=0)
        self.variable_qtgui_label_0_0_0_0 = variable_qtgui_label_0_0_0_0 = variable_function_probe_0_0
        self.variable_qtgui_label_0_0_0 = variable_qtgui_label_0_0_0 = variable_function_probe_0
        self.variable_qtgui_label_0_0 = variable_qtgui_label_0_0 = left
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = right
        self.threshold = threshold = -60
        self.scale = scale = 20000
        self.samp_rate = samp_rate = 100e3
        self.minmag = minmag = 0
        self.maxmag = maxmag = .0035
        self.keep = keep = 50
        self.gain = gain = 20
        self.freq = freq = 422e6
        self.displayscale = displayscale = 5

        ##################################################
        # 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, 'Time rasters')
        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, 'Steering vectors')
        self.top_grid_layout.addWidget(self.tab)
        self._scale_range = Range(0, 60000, 1000, 20000, 200)
        self._scale_win = RangeWidget(self._scale_range, self.set_scale,
                                      'scale', "counter_slider", float)
        self.top_grid_layout.addWidget(self._scale_win)
        self.blocks_probe_signal_x_0_0 = blocks.probe_signal_f()
        self.blocks_probe_signal_x_0 = blocks.probe_signal_f()
        self.video_sdl_sink_1_1_0 = video_sdl.sink_s(0, columns, columns, 0,
                                                     columns * displayscale,
                                                     columns * displayscale)
        self._variable_qtgui_label_0_0_0_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_0_0_0_formatter = None
        else:
            self._variable_qtgui_label_0_0_0_0_formatter = lambda x: str(x)

        self._variable_qtgui_label_0_0_0_0_tool_bar.addWidget(
            Qt.QLabel('Probe Signal Min' + ": "))
        self._variable_qtgui_label_0_0_0_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_0_0_0_formatter(
                    self.variable_qtgui_label_0_0_0_0)))
        self._variable_qtgui_label_0_0_0_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_0_0_0_label)
        self.top_grid_layout.addWidget(
            self._variable_qtgui_label_0_0_0_0_tool_bar)
        self._variable_qtgui_label_0_0_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_0_0_formatter = None
        else:
            self._variable_qtgui_label_0_0_0_formatter = lambda x: str(x)

        self._variable_qtgui_label_0_0_0_tool_bar.addWidget(
            Qt.QLabel('Probe Signal Max' + ": "))
        self._variable_qtgui_label_0_0_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_0_0_formatter(
                    self.variable_qtgui_label_0_0_0)))
        self._variable_qtgui_label_0_0_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_0_0_label)
        self.top_grid_layout.addWidget(
            self._variable_qtgui_label_0_0_0_tool_bar)
        self._variable_qtgui_label_0_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_0_formatter = None
        else:
            self._variable_qtgui_label_0_0_formatter = lambda x: repr(x)

        self._variable_qtgui_label_0_0_tool_bar.addWidget(
            Qt.QLabel('variable_qtgui_label_0_0' + ": "))
        self._variable_qtgui_label_0_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_0_formatter(
                    self.variable_qtgui_label_0_0)))
        self._variable_qtgui_label_0_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_0_label)
        self.tab_layout_1.addWidget(self._variable_qtgui_label_0_0_tool_bar)
        self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_formatter = None
        else:
            self._variable_qtgui_label_0_formatter = lambda x: repr(x)

        self._variable_qtgui_label_0_tool_bar.addWidget(
            Qt.QLabel('variable_qtgui_label_0' + ": "))
        self._variable_qtgui_label_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_formatter(
                    self.variable_qtgui_label_0)))
        self._variable_qtgui_label_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_label)
        self.tab_layout_1.addWidget(self._variable_qtgui_label_0_tool_bar)

        def _variable_function_probe_0_0_probe():
            while True:

                val = self.blocks_probe_signal_x_0_0.level()
                try:
                    self.set_variable_function_probe_0_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1))

        _variable_function_probe_0_0_thread = threading.Thread(
            target=_variable_function_probe_0_0_probe)
        _variable_function_probe_0_0_thread.daemon = True
        _variable_function_probe_0_0_thread.start()

        def _variable_function_probe_0_probe():
            while True:

                val = self.blocks_probe_signal_x_0.level()
                try:
                    self.set_variable_function_probe_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1))

        _variable_function_probe_0_thread = threading.Thread(
            target=_variable_function_probe_0_probe)
        _variable_function_probe_0_thread.daemon = True
        _variable_function_probe_0_thread.start()

        self.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join(("", "type=b200, name=origb210")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 2)),
            ),
        )
        self.uhd_usrp_source_0_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0_0.set_gain(gain, 0)
        self.uhd_usrp_source_0_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0_0.set_center_freq(freq, 1)
        self.uhd_usrp_source_0_0.set_gain(gain, 1)
        self.uhd_usrp_source_0_0.set_antenna('RX2', 1)
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "type=b200, name=newb210")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 2)),
            ),
        )
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_center_freq(freq, 1)
        self.uhd_usrp_source_0.set_gain(gain, 1)
        self.uhd_usrp_source_0.set_antenna('RX2', 1)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec())
        self._threshold_range = Range(-160, -10, 5, -60, 200)
        self._threshold_win = RangeWidget(self._threshold_range,
                                          self.set_threshold,
                                          'squelch threshold',
                                          "counter_slider", int)
        self.top_grid_layout.addWidget(self._threshold_win)
        self.qtgui_time_raster_sink_x_0_0 = qtgui.time_raster_sink_f(
            samp_rate / keep, columns, columns, [], [], "Elevation", 1)

        self.qtgui_time_raster_sink_x_0_0.set_update_time(0.01)
        self.qtgui_time_raster_sink_x_0_0.set_intensity_range(minmag, maxmag)
        self.qtgui_time_raster_sink_x_0_0.enable_grid(False)
        self.qtgui_time_raster_sink_x_0_0.enable_axis_labels(True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_time_raster_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_raster_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_raster_sink_x_0_0.set_color_map(i, colors[i])
            self.qtgui_time_raster_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_raster_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_raster_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.addWidget(self._qtgui_time_raster_sink_x_0_0_win)
        self.qtgui_time_raster_sink_x_0 = qtgui.time_raster_sink_f(
            samp_rate / keep, columns, columns, [], [], "Azimuth", 1)

        self.qtgui_time_raster_sink_x_0.set_update_time(0.01)
        self.qtgui_time_raster_sink_x_0.set_intensity_range(minmag, maxmag)
        self.qtgui_time_raster_sink_x_0.enable_grid(False)
        self.qtgui_time_raster_sink_x_0.enable_axis_labels(True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_time_raster_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_raster_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_raster_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_time_raster_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_raster_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_raster_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.addWidget(self._qtgui_time_raster_sink_x_0_win)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, columns)
        self.blocks_vector_source_x_0_0_0_1 = blocks.vector_source_f(
            left, True, 1, [])
        self.blocks_vector_source_x_0_0_0_0_0 = blocks.vector_source_f(
            right, True, 1, [])
        self.blocks_vector_source_x_0_0_0_0 = blocks.vector_source_f(
            right, True, 1, [])
        self.blocks_vector_source_x_0_0_0 = blocks.vector_source_f(
            left, True, 1, [])
        self.blocks_sub_xx_0_0_1 = blocks.sub_ff(1)
        self.blocks_sub_xx_0_0_0_0 = blocks.sub_ff(1)
        self.blocks_sub_xx_0_0_0 = blocks.sub_ff(1)
        self.blocks_sub_xx_0_0 = blocks.sub_ff(1)
        self.blocks_stream_to_vector_0_1 = blocks.stream_to_vector(
            gr.sizeof_float * 1, int(samp_rate / keep))
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, columns)
        self.blocks_repeat_0_0_0_0_2 = blocks.repeat(gr.sizeof_float * 1,
                                                     columns)
        self.blocks_repeat_0_0_0_0_1_0 = blocks.repeat(gr.sizeof_float * 1,
                                                       columns)
        self.blocks_repeat_0_0_0_0_1 = blocks.repeat(gr.sizeof_float * 1,
                                                     columns)
        self.blocks_repeat_0_0_0_0_0_1_0 = blocks.repeat(
            gr.sizeof_float * 1, columns)
        self.blocks_repeat_0_0_0_0_0_1 = blocks.repeat(gr.sizeof_float * 1,
                                                       columns)
        self.blocks_repeat_0_0_0_0_0_0 = blocks.repeat(gr.sizeof_float * 1,
                                                       columns)
        self.blocks_repeat_0_0_0_0_0 = blocks.repeat(gr.sizeof_float * 1,
                                                     columns)
        self.blocks_repeat_0_0_0_0 = blocks.repeat(gr.sizeof_float * 1,
                                                   columns)
        self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_gr_complex * columns,
                                               columns)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, columns)
        self.blocks_min_xx_0 = blocks.min_ff(int(samp_rate / keep), 1)
        self.blocks_max_xx_0 = blocks.max_ff(int(samp_rate / keep), 1)
        self.blocks_magphase_to_complex_0_0_0_0_1 = blocks.magphase_to_complex(
            1)
        self.blocks_magphase_to_complex_0_0_0_0_0_0 = blocks.magphase_to_complex(
            1)
        self.blocks_magphase_to_complex_0_0_0_0_0 = blocks.magphase_to_complex(
            1)
        self.blocks_magphase_to_complex_0_0_0_0 = blocks.magphase_to_complex(1)
        self.blocks_keep_one_in_n_0_2 = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * 1, keep)
        self.blocks_keep_one_in_n_0_1 = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * 1, keep)
        self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * 1, keep)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * 1, keep)
        self.blocks_float_to_short_0_1_0 = blocks.float_to_short(1, scale)
        self.blocks_complex_to_magphase_0_0_0_1 = blocks.complex_to_magphase(1)
        self.blocks_complex_to_magphase_0_0_0_0_0 = blocks.complex_to_magphase(
            1)
        self.blocks_complex_to_magphase_0_0_0_0 = blocks.complex_to_magphase(1)
        self.blocks_complex_to_magphase_0_0_0 = blocks.complex_to_magphase(1)
        self.blocks_complex_to_mag_squared_0_1 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0_0 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_pwr_squelch_xx_0_1 = analog.pwr_squelch_cc(
            -60, 1e-4, 0, False)
        self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc(
            -60, 1e-4, 0, False)
        self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(
            -60, 1e-4, 0, False)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(
            -60, 1e-4, 0, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_pwr_squelch_xx_0, 0),
                     (self.blocks_keep_one_in_n_0_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0_0_0, 0),
                     (self.blocks_keep_one_in_n_0_1, 0))
        self.connect((self.analog_pwr_squelch_xx_0_1, 0),
                     (self.blocks_keep_one_in_n_0_2, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.blocks_complex_to_mag_squared_0_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.qtgui_time_raster_sink_x_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0),
                     (self.qtgui_time_raster_sink_x_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_1, 0),
                     (self.blocks_float_to_short_0_1_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_1, 0),
                     (self.blocks_stream_to_vector_0_1, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0, 0),
                     (self.blocks_repeat_0_0_0_0, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0, 1),
                     (self.blocks_repeat_0_0_0_0_0, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0_0, 1),
                     (self.blocks_repeat_0_0_0_0_0_1, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0_0, 0),
                     (self.blocks_repeat_0_0_0_0_1, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0_0_0, 1),
                     (self.blocks_repeat_0_0_0_0_0_1_0, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0_0_0, 0),
                     (self.blocks_repeat_0_0_0_0_1_0, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0_1, 1),
                     (self.blocks_repeat_0_0_0_0_0_0, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0_1, 0),
                     (self.blocks_repeat_0_0_0_0_2, 0))
        self.connect((self.blocks_float_to_short_0_1_0, 0),
                     (self.video_sdl_sink_1_1_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.blocks_complex_to_magphase_0_0_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_0, 0),
                     (self.blocks_complex_to_magphase_0_0_0_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_1, 0),
                     (self.blocks_complex_to_magphase_0_0_0_1, 0))
        self.connect((self.blocks_keep_one_in_n_0_2, 0),
                     (self.blocks_complex_to_magphase_0_0_0_0_0, 0))
        self.connect((self.blocks_magphase_to_complex_0_0_0_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_magphase_to_complex_0_0_0_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_magphase_to_complex_0_0_0_0_0_0, 0),
                     (self.blocks_add_xx_0_0, 1))
        self.connect((self.blocks_magphase_to_complex_0_0_0_0_1, 0),
                     (self.blocks_add_xx_0_0, 0))
        self.connect((self.blocks_max_xx_0, 0),
                     (self.blocks_probe_signal_x_0, 0))
        self.connect((self.blocks_min_xx_0, 0),
                     (self.blocks_probe_signal_x_0_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_repeat_0_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0_0, 0),
                     (self.blocks_sub_xx_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0_0_0, 0),
                     (self.blocks_sub_xx_0_0_1, 0))
        self.connect((self.blocks_repeat_0_0_0_0_0_1, 0),
                     (self.blocks_sub_xx_0_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0_0_1_0, 0),
                     (self.blocks_sub_xx_0_0_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0_1, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0_1_0, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0_2, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0_1, 0))
        self.connect((self.blocks_stream_to_vector_0, 0),
                     (self.blocks_repeat_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0_1, 0),
                     (self.blocks_max_xx_0, 0))
        self.connect((self.blocks_stream_to_vector_0_1, 0),
                     (self.blocks_min_xx_0, 0))
        self.connect((self.blocks_sub_xx_0_0, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0, 1))
        self.connect((self.blocks_sub_xx_0_0_0, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0_0, 1))
        self.connect((self.blocks_sub_xx_0_0_0_0, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0_0_0, 1))
        self.connect((self.blocks_sub_xx_0_0_1, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0_1, 1))
        self.connect((self.blocks_vector_source_x_0_0_0, 0),
                     (self.blocks_sub_xx_0_0, 1))
        self.connect((self.blocks_vector_source_x_0_0_0_0, 0),
                     (self.blocks_sub_xx_0_0_0, 1))
        self.connect((self.blocks_vector_source_x_0_0_0_0_0, 0),
                     (self.blocks_sub_xx_0_0_0_0, 1))
        self.connect((self.blocks_vector_source_x_0_0_0_1, 0),
                     (self.blocks_sub_xx_0_0_1, 1))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_add_xx_1, 0))
        self.connect((self.uhd_usrp_source_0, 1),
                     (self.analog_pwr_squelch_xx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.analog_pwr_squelch_xx_0_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.analog_pwr_squelch_xx_0_0_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 1),
                     (self.analog_pwr_squelch_xx_0_1, 0))