Пример #1
0
    def test_001(self):
        self.maxDiff = None;
        tb = gr.top_block()
        src = gr.vector_source_b( range(0,100) )

        # itemsize, M, N, offset
        km2 = gr.keep_m_in_n( 1, 1, 2, 0 );
        km3 = gr.keep_m_in_n( 1, 1, 3, 1 );
        km7 = gr.keep_m_in_n( 1, 1, 7, 2 );
        snk2 = gr.vector_sink_b();
        snk3 = gr.vector_sink_b();
        snk7 = gr.vector_sink_b();
        tb.connect(src,km2,snk2);
        tb.connect(src,km3,snk3);
        tb.connect(src,km7,snk7);
        tb.run();

        self.assertEqual(range(0,100,2), list(snk2.data()));
        self.assertEqual(range(1,100,3), list(snk3.data()));
        self.assertEqual(range(2,100,7), list(snk7.data()));
    def test_001(self):
        self.maxDiff = None
        tb = gr.top_block()
        src1 = gr.vector_source_i(range(0, 100))
        src2 = gr.vector_source_i(range(0, 100))
        src3 = gr.vector_source_i(range(0, 100))

        # itemsize, M, N, offset
        km2 = gr.keep_m_in_n(gr.sizeof_int, 4, 1, 2, 0)
        km3 = gr.keep_m_in_n(gr.sizeof_int, 4, 1, 3, 1)
        km7 = gr.keep_m_in_n(gr.sizeof_int, 4, 1, 7, 2)
        snk2 = gr.vector_sink_i()
        snk3 = gr.vector_sink_i()
        snk7 = gr.vector_sink_i()
        tb.connect(src1, km2, snk2)
        tb.connect(src2, km3, snk3)
        tb.connect(src3, km7, snk7)
        tb.run()

        self.assertEqual(range(0, 100, 2), list(snk2.data()))
        self.assertEqual(range(1, 100, 3), list(snk3.data()))
        self.assertEqual(range(2, 100, 7), list(snk7.data()))
Пример #3
0
	def __init__(self, decim=16):
		grc_wxgui.top_block_gui.__init__(self, title="File Fft")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.decim = decim

		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 32000
		self.fft_size = fft_size = 2048/decim
		self.N_re = N_re = 62

		##################################################
		# Blocks
		##################################################
		self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
			self.GetWin(),
			title="Scope Plot",
			sample_rate=samp_rate,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.Add(self.wxgui_scopesink2_0.win)
		self.gr_vector_to_stream_0 = gr.vector_to_stream(gr.sizeof_gr_complex*1, fft_size)
		self.gr_stream_to_vector_0 = gr.stream_to_vector(gr.sizeof_gr_complex*1, fft_size)
		self.gr_keep_m_in_n_0 = gr.keep_m_in_n(gr.sizeof_gr_complex, N_re, fft_size, (fft_size-N_re)/2)
		self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/home/user/git/gr-lte/gr-lte/test/foo_pss0_sss_in.cfile", True)
		self.gr_fft_vxx_0 = gr.fft_vcc(fft_size, True, (window.blackmanharris(1024)), True, 1)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_stream_to_vector_0, 0), (self.gr_fft_vxx_0, 0))
		self.connect((self.gr_file_source_0, 0), (self.gr_stream_to_vector_0, 0))
		self.connect((self.gr_vector_to_stream_0, 0), (self.gr_keep_m_in_n_0, 0))
		self.connect((self.gr_fft_vxx_0, 0), (self.gr_vector_to_stream_0, 0))
		self.connect((self.gr_keep_m_in_n_0, 0), (self.wxgui_scopesink2_0, 0))
Пример #4
0
    def __init__(
        self,
        decim=16,
        fft_size=2048 / 16,
        N_re=62,
        avg_frames=8,
        dump=None,
        N_id_1s=range(0, 168),
        slot_0_10s=range(0, 2),
    ):
        self.logger = logging.getLogger("sss_corr2")

        # store parameters
        self.decim = decim
        self.fft_size = fft_size
        self.N_re = N_re
        self.avg_frames = avg_frames
        self.dump = dump
        self.N_id_1s = N_id_1s
        self.slot_0_10s = slot_0_10s

        # calculate statics
        self.symbol_mask = numpy.zeros(20 * 7)
        self.symbol_mask[5:7] = 1
        self.symbol_mask[75:77] = 1

        # generate PSS sequences
        self.pss_fd_vec = []
        for N_id_2 in range(0, 3):
            self.pss_fd_vec.append(gen_pss_fd(N_id_2, self.N_re, False).get_data())

        # generate SSS sequences
        self.sss_fd_vec = []
        for N_id_2 in range(0, 3):
            self.sss_fd_vec.append([])
            for N_id_1 in range(0, 168):
                self.sss_fd_vec[N_id_2].append([])
                for slot_0_10 in range(0, 2):
                    self.sss_fd_vec[N_id_2][N_id_1].append(
                        gen_sss_fd(N_id_1, N_id_2, N_re).get_sss_conj(slot_0_10 != 0)
                    )
        self.pss_ref_src = gr.vector_source_c(zeros(0), True, self.N_re)
        self.sss_ref_src = gr.vector_source_c(zeros(0), True, self.N_re)

        # SSS equalization flow graph
        self.equ_source = symbol_source(decim=self.decim, vlen=self.fft_size)
        fft = gr.fft_vcc(self.fft_size, True, (window.blackmanharris(1024)), True, 1)
        vector_to_stream_0 = gr.vector_to_stream(gr.sizeof_gr_complex * 1, self.fft_size)
        keep_m_in_n_0 = gr.keep_m_in_n(
            gr.sizeof_gr_complex, self.N_re / 2, self.fft_size, (self.fft_size - self.N_re) / 2 - 1
        )
        keep_m_in_n_1 = gr.keep_m_in_n(gr.sizeof_gr_complex, self.N_re / 2, self.fft_size, (self.fft_size) / 2)
        stream_mux_0 = gr.stream_mux(gr.sizeof_gr_complex, 2 * [self.N_re / 2])
        stream_to_vector_0_0 = gr.stream_to_vector(gr.sizeof_gr_complex * 1, self.N_re)
        deinterleave_0 = gr.deinterleave(gr.sizeof_gr_complex * self.N_re)
        self.equ = sss_equ2()
        self.equ_sink = gr.vector_sink_c(self.N_re)

        self.equ_top = gr.top_block("sss equ graph")
        self.equ_top.connect(self.equ_source, fft, vector_to_stream_0)
        self.equ_top.connect(vector_to_stream_0, keep_m_in_n_0, (stream_mux_0, 0))
        self.equ_top.connect(vector_to_stream_0, keep_m_in_n_1, (stream_mux_0, 1))
        self.equ_top.connect(stream_mux_0, stream_to_vector_0_0, deinterleave_0)
        self.equ_top.connect((deinterleave_0, 0), (self.equ, 0))
        self.equ_top.connect((deinterleave_0, 1), (self.equ, 1))
        self.equ_top.connect(self.pss_ref_src, (self.equ, 2))
        self.equ_top.connect((self.equ, 0), self.equ_sink)
        self.equ_top.connect((self.equ, 1), gr.null_sink(self.N_re * gr.sizeof_gr_complex))

        if self.dump != None:
            self.equ_top.connect(
                self.equ_source, gr.file_sink(gr.sizeof_gr_complex * self.fft_size, self.dump + "_sss_td_in.cfile")
            )
            self.equ_top.connect(
                (deinterleave_0, 0), gr.file_sink(gr.sizeof_gr_complex * self.N_re, self.dump + "_sss_fd_in.cfile")
            )
            self.equ_top.connect(
                (deinterleave_0, 1), gr.file_sink(gr.sizeof_gr_complex * self.N_re, self.dump + "_pss_fd_in.cfile")
            )
            self.equ_top.connect(
                self.equ, gr.file_sink(gr.sizeof_gr_complex * self.N_re, self.dump + "_sss_fd_equ.cfile")
            )

        # SSS maximum likelihood estimation
        self.ml_src = gr.vector_source_c(zeros(0), False, self.N_re)
        self.ml_derot = sss_derot()
        self.ml_sss = sss_ml_fd2(avg_frames=self.avg_frames)
        self.ml_sink = gr.vector_sink_f()

        self.ml_top = gr.top_block("sss ml graph")
        self.ml_top.connect(self.ml_src, self.ml_derot, self.ml_sss, self.ml_sink)
        self.ml_top.connect(self.sss_ref_src, (self.ml_derot, 1))
        self.ml_top.connect(self.sss_ref_src, (self.ml_sss, 1))

        if self.dump != None:
            self.ml_top.connect(
                self.ml_derot, gr.file_sink(gr.sizeof_gr_complex * self.N_re, self.dump + "_sss_fd_derot.cfile")
            )
            self.ml_top.connect(self.ml_sss, gr.file_sink(gr.sizeof_float, self.dump + "_sss_corr.cfile"))
Пример #5
0
	def __init__(self, freq_corr=0, avg_frames=1, decim=16, N_id_2=0, N_id_1=134):
		grc_wxgui.top_block_gui.__init__(self, title="Sss Corr5 Gui")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.freq_corr = freq_corr
		self.avg_frames = avg_frames
		self.decim = decim
		self.N_id_2 = N_id_2
		self.N_id_1 = N_id_1

		##################################################
		# Variables
		##################################################
		self.vec_half_frame = vec_half_frame = 30720*5/decim
		self.symbol_start = symbol_start = 144/decim
		self.slot_0_10 = slot_0_10 = 1
		self.samp_rate = samp_rate = 30720e3/decim
		self.rot = rot = 0
		self.noise_level = noise_level = 0
		self.fft_size = fft_size = 2048/decim
		self.N_re = N_re = 62

		##################################################
		# Blocks
		##################################################
		_rot_sizer = wx.BoxSizer(wx.VERTICAL)
		self._rot_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_rot_sizer,
			value=self.rot,
			callback=self.set_rot,
			label='rot',
			converter=forms.float_converter(),
			proportion=0,
		)
		self._rot_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_rot_sizer,
			value=self.rot,
			callback=self.set_rot,
			minimum=0,
			maximum=1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_rot_sizer)
		self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "SSS ML")
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "SSS equ")
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "SSS in")
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "PSS equ")
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "PSS ch est")
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "foo")
		self.Add(self.notebook_0)
		_noise_level_sizer = wx.BoxSizer(wx.VERTICAL)
		self._noise_level_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_noise_level_sizer,
			value=self.noise_level,
			callback=self.set_noise_level,
			label='noise_level',
			converter=forms.float_converter(),
			proportion=0,
		)
		self._noise_level_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_noise_level_sizer,
			value=self.noise_level,
			callback=self.set_noise_level,
			minimum=0,
			maximum=10,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_noise_level_sizer)
		self.wxgui_scopesink2_0_1_0_1 = scopesink2.scope_sink_c(
			self.notebook_0.GetPage(3).GetWin(),
			title="Scope Plot",
			sample_rate=samp_rate,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=False,
			num_inputs=2,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0_1_0_1.win)
		self.wxgui_scopesink2_0_1_0_0 = scopesink2.scope_sink_c(
			self.notebook_0.GetPage(2).GetWin(),
			title="Scope Plot",
			sample_rate=samp_rate,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.notebook_0.GetPage(2).Add(self.wxgui_scopesink2_0_1_0_0.win)
		self.wxgui_scopesink2_0_1_0 = scopesink2.scope_sink_c(
			self.notebook_0.GetPage(1).GetWin(),
			title="Scope Plot",
			sample_rate=samp_rate,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_0_1_0.win)
		self.wxgui_scopesink2_0_1 = scopesink2.scope_sink_f(
			self.notebook_0.GetPage(0).GetWin(),
			title="Scope Plot",
			sample_rate=100/avg_frames,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.notebook_0.GetPage(0).Add(self.wxgui_scopesink2_0_1.win)
		_symbol_start_sizer = wx.BoxSizer(wx.VERTICAL)
		self._symbol_start_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_symbol_start_sizer,
			value=self.symbol_start,
			callback=self.set_symbol_start,
			label='symbol_start',
			converter=forms.int_converter(),
			proportion=0,
		)
		self._symbol_start_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_symbol_start_sizer,
			value=self.symbol_start,
			callback=self.set_symbol_start,
			minimum=0,
			maximum=144/decim,
			num_steps=144/decim,
			style=wx.SL_HORIZONTAL,
			cast=int,
			proportion=1,
		)
		self.Add(_symbol_start_sizer)
		self.sss_ml_fd_0 = sss_ml_fd(
			decim=decim,
			avg_frames=avg_frames,
			N_id_1=N_id_1,
			N_id_2=N_id_2,
			slot_0_10=slot_0_10,
		)
		self.pss_chan_est2_0 = pss_chan_est2(
			N_id_2=N_id_2,
		)
		self.gr_vector_to_stream_0_0_1_0 = gr.vector_to_stream(gr.sizeof_gr_complex*1, N_re)
		self.gr_vector_to_stream_0_0_1 = gr.vector_to_stream(gr.sizeof_gr_complex*1, N_re)
		self.gr_vector_to_stream_0_0_0 = gr.vector_to_stream(gr.sizeof_gr_complex*1, N_re)
		self.gr_vector_to_stream_0_0 = gr.vector_to_stream(gr.sizeof_gr_complex*1, N_re)
		self.gr_vector_to_stream_0 = gr.vector_to_stream(gr.sizeof_gr_complex*1, fft_size)
		self.gr_vector_source_x_0_0_0 = gr.vector_source_c((gen_pss_fd(N_id_2, N_re, False).get_data()), True, N_re)
		self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate)
		self.gr_stream_to_vector_0_0 = gr.stream_to_vector(gr.sizeof_gr_complex*1, N_re)
		self.gr_stream_to_vector_0 = gr.stream_to_vector(gr.sizeof_gr_complex*1, fft_size)
		self.gr_stream_mux_0 = gr.stream_mux(gr.sizeof_gr_complex*1, (N_re/2, N_re/2))
		self.gr_null_source_0 = gr.null_source(gr.sizeof_gr_complex*1)
		self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise_level, 0)
		self.gr_multiply_xx_1_0 = gr.multiply_vcc(N_re)
		self.gr_multiply_xx_1 = gr.multiply_vcc(N_re)
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((0.005*exp(rot*2*numpy.pi*1j), ))
		self.gr_keep_m_in_n_0_0 = gr.keep_m_in_n(gr.sizeof_gr_complex, N_re/2, fft_size, (fft_size-N_re)/2-1)
		self.gr_keep_m_in_n_0 = gr.keep_m_in_n(gr.sizeof_gr_complex, N_re/2, fft_size, (fft_size)/2)
		self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/home/user/git/gr-lte/gr-lte/test/octave/foo_sss_td_in.cfile", True)
		self.gr_fft_vxx_0 = gr.fft_vcc(fft_size, True, (window.blackmanharris(1024)), True, 1)
		self.gr_deinterleave_0 = gr.deinterleave(gr.sizeof_gr_complex*N_re)
		self.gr_channel_model_0 = gr.channel_model(
			noise_voltage=0.005*noise_level,
			frequency_offset=0.0,
			epsilon=1,
			taps=(0.005*exp(rot*2*numpy.pi*1j), ),
			noise_seed=0,
		)
		self.gr_add_xx_0 = gr.add_vcc(1)
		self.blks2_selector_0_0 = grc_blks2.selector(
			item_size=gr.sizeof_gr_complex*1,
			num_inputs=2,
			num_outputs=1,
			input_index=0,
			output_index=0,
		)
		self.blks2_selector_0 = grc_blks2.selector(
			item_size=gr.sizeof_gr_complex*1,
			num_inputs=3,
			num_outputs=2,
			input_index=0,
			output_index=0,
		)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1))
		self.connect((self.gr_add_xx_0, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.blks2_selector_0, 0), (self.gr_channel_model_0, 0))
		self.connect((self.blks2_selector_0, 1), (self.gr_add_xx_0, 0))
		self.connect((self.gr_channel_model_0, 0), (self.blks2_selector_0_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_selector_0_0, 1))
		self.connect((self.gr_file_source_0, 0), (self.blks2_selector_0, 0))
		self.connect((self.blks2_selector_0_0, 0), (self.gr_throttle_0, 0))
		self.connect((self.gr_deinterleave_0, 0), (self.gr_vector_to_stream_0_0_0, 0))
		self.connect((self.gr_vector_to_stream_0_0_0, 0), (self.wxgui_scopesink2_0_1_0_0, 0))
		self.connect((self.gr_vector_to_stream_0_0, 0), (self.wxgui_scopesink2_0_1_0, 0))
		self.connect((self.gr_fft_vxx_0, 0), (self.gr_vector_to_stream_0, 0))
		self.connect((self.gr_vector_to_stream_0, 0), (self.gr_keep_m_in_n_0, 0))
		self.connect((self.gr_stream_to_vector_0_0, 0), (self.gr_deinterleave_0, 0))
		self.connect((self.gr_stream_to_vector_0, 0), (self.gr_fft_vxx_0, 0))
		self.connect((self.gr_vector_to_stream_0_0_1, 0), (self.wxgui_scopesink2_0_1_0_1, 0))
		self.connect((self.gr_vector_to_stream_0_0_1_0, 0), (self.wxgui_scopesink2_0_1_0_1, 1))
		self.connect((self.gr_vector_source_x_0_0_0, 0), (self.gr_vector_to_stream_0_0_1_0, 0))
		self.connect((self.pss_chan_est2_0, 0), (self.gr_multiply_xx_1, 1))
		self.connect((self.gr_multiply_xx_1, 0), (self.sss_ml_fd_0, 0))
		self.connect((self.gr_multiply_xx_1, 0), (self.gr_vector_to_stream_0_0, 0))
		self.connect((self.pss_chan_est2_0, 0), (self.gr_multiply_xx_1_0, 0))
		self.connect((self.gr_deinterleave_0, 1), (self.gr_multiply_xx_1_0, 1))
		self.connect((self.gr_multiply_xx_1_0, 0), (self.gr_vector_to_stream_0_0_1, 0))
		self.connect((self.gr_deinterleave_0, 1), (self.pss_chan_est2_0, 0))
		self.connect((self.gr_vector_to_stream_0, 0), (self.gr_keep_m_in_n_0_0, 0))
		self.connect((self.gr_keep_m_in_n_0_0, 0), (self.gr_stream_mux_0, 0))
		self.connect((self.gr_keep_m_in_n_0, 0), (self.gr_stream_mux_0, 1))
		self.connect((self.gr_stream_mux_0, 0), (self.gr_stream_to_vector_0_0, 0))
		self.connect((self.gr_throttle_0, 0), (self.gr_stream_to_vector_0, 0))
		self.connect((self.gr_null_source_0, 0), (self.blks2_selector_0, 1))
		self.connect((self.gr_null_source_0, 0), (self.blks2_selector_0, 2))
		self.connect((self.sss_ml_fd_0, 0), (self.wxgui_scopesink2_0_1, 0))
		self.connect((self.gr_deinterleave_0, 0), (self.gr_multiply_xx_1, 0))