Example #1
0
  def __init__(self, vlen):
    gr.hier_block2.__init__(self, "coarse_frequency_offset_estimation",
        gr.io_signature2(2,2,gr.sizeof_gr_complex,gr.sizeof_char),
        gr.io_signature (1,1,gr.sizeof_float))

    ## Preamble Extraction
    sampler = vector_sampler(gr.sizeof_gr_complex,vlen)
    self.connect(self,sampler)
    self.connect((self,1),(sampler,1))

    ## Split block into two parts
    splitter = gr.vector_to_streams(gr.sizeof_gr_complex*vlen/2,2)
    self.connect(sampler,splitter)

    ## Multiply 2nd sub-part with conjugate of 1st sub-part
    conj_mult = gr.multiply_conjugate_cc(vlen/2)
    self.connect((splitter,1),(conj_mult,0))
    self.connect((splitter,0),(conj_mult,1))

    ## Sum of Products
    psum = vector_sum_vcc(vlen/2)
    self.connect((conj_mult,0),psum)

    ## Complex to Angle
    angle = complex_to_arg()
    self.connect(psum,angle)

    ## Normalize
    norm = gr.multiply_const_ff(1.0/math.pi)
    self.connect(angle,norm)

    ## Setup Output Connections
    self.connect(norm,self)
Example #2
0
    def __init__(self, vlen):
        gr.hier_block2.__init__(
            self, "coarse_frequency_offset_estimation",
            gr.io_signature2(2, 2, gr.sizeof_gr_complex, gr.sizeof_char),
            gr.io_signature(1, 1, gr.sizeof_float))

        ## Preamble Extraction
        sampler = vector_sampler(gr.sizeof_gr_complex, vlen)
        self.connect(self, sampler)
        self.connect((self, 1), (sampler, 1))

        ## Split block into two parts
        splitter = gr.vector_to_streams(gr.sizeof_gr_complex * vlen / 2, 2)
        self.connect(sampler, splitter)

        ## Multiply 2nd sub-part with conjugate of 1st sub-part
        conj_mult = gr.multiply_conjugate_cc(vlen / 2)
        self.connect((splitter, 1), (conj_mult, 0))
        self.connect((splitter, 0), (conj_mult, 1))

        ## Sum of Products
        psum = vector_sum_vcc(vlen / 2)
        self.connect((conj_mult, 0), psum)

        ## Complex to Angle
        angle = complex_to_arg()
        self.connect(psum, angle)

        ## Normalize
        norm = gr.multiply_const_ff(1.0 / math.pi)
        self.connect(angle, norm)

        ## Setup Output Connections
        self.connect(norm, self)
    def test_000(self):
        src_data0 = (-2 - 2j, -1 - 1j, -2 + 2j, -1 + 1j, 2 - 2j, 1 - 1j,
                     2 + 2j, 1 + 1j, 0 + 0j)
        src_data1 = (-3 - 3j, -4 - 4j, -3 + 3j, -4 + 4j, 3 - 3j, 4 - 4j,
                     3 + 3j, 4 + 4j, 0 + 0j)

        exp_data = (12 + 0j, 8 + 0j, 12 + 0j, 8 + 0j, 12 + 0j, 8 + 0j, 12 + 0j,
                    8 + 0j, 0 + 0j)
        src0 = gr.vector_source_c(src_data0)
        src1 = gr.vector_source_c(src_data1)
        op = gr.multiply_conjugate_cc()
        self.help_cc((src_data0, src_data1), exp_data, op)
    def test_000 (self):
        src_data0 = (-2-2j, -1-1j, -2+2j, -1+1j,
                      2-2j,  1-1j,  2+2j,  1+1j,
                      0+0j)
        src_data1 = (-3-3j, -4-4j, -3+3j, -4+4j,
                      3-3j,  4-4j,  3+3j,  4+4j,
                      0+0j)

        exp_data = (12+0j, 8+0j, 12+0j, 8+0j,
                    12+0j, 8+0j, 12+0j, 8+0j,
                    0+0j)
        src0 = gr.vector_source_c(src_data0)
        src1 = gr.vector_source_c(src_data1)
        op = gr.multiply_conjugate_cc ()
        self.help_cc ((src_data0, src_data1),
                      exp_data, op)
Example #5
0
    def test_000(self):
        src_data0 = (-2 - 2j, -1 - 1j, -2 + 2j, -1 + 1j, 2 - 2j, 1 - 1j,
                     2 + 2j, 1 + 1j, 0 + 0j)
        src_data1 = (-3 - 3j, -4 - 4j, -3 + 3j, -4 + 4j, 3 - 3j, 4 - 4j,
                     3 + 3j, 4 + 4j, 0 + 0j)

        exp_data = (12 + 0j, 8 + 0j, 12 + 0j, 8 + 0j, 12 + 0j, 8 + 0j, 12 + 0j,
                    8 + 0j, 0 + 0j)
        src0 = gr.vector_source_c(src_data0)
        src1 = gr.vector_source_c(src_data1)
        op = gr.multiply_conjugate_cc()
        dst = gr.vector_sink_c()

        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(exp_data, result_data)
Example #6
0
def multiply_conjugate_cc(N):
    try:
        op = gr.multiply_conjugate_cc()
        tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_gr_complex, 2, 1)
        return tb

    except AttributeError:
        class s(gr.hier_block2):
            def __init__(self):
                gr.hier_block2.__init__(self, "s",
                                        gr.io_signature(2, 2, gr.sizeof_gr_complex),
                                        gr.io_signature(1, 1, gr.sizeof_gr_complex))
                conj = gr.conjugate_cc()
                mult = gr.multiply_cc()
                self.connect((self,0), (mult,0))
                self.connect((self,1), conj, (mult,1))
                self.connect(mult, self)

        op = s()
        tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_gr_complex, 2, 1)
        return tb
Example #7
0
def multiply_conjugate_cc(N):
    try:
        op = gr.multiply_conjugate_cc()
        tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_gr_complex, 2, 1)
        return tb

    except AttributeError:

        class s(gr.hier_block2):
            def __init__(self):
                gr.hier_block2.__init__(
                    self, "s", gr.io_signature(2, 2, gr.sizeof_gr_complex),
                    gr.io_signature(1, 1, gr.sizeof_gr_complex))
                conj = gr.conjugate_cc()
                mult = gr.multiply_cc()
                self.connect((self, 0), (mult, 0))
                self.connect((self, 1), conj, (mult, 1))
                self.connect(mult, self)

        op = s()
        tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_gr_complex, 2, 1)
        return tb
    def test_000 (self):
        src_data0 = (-2-2j, -1-1j, -2+2j, -1+1j,
                      2-2j,  1-1j,  2+2j,  1+1j,
                      0+0j)
        src_data1 = (-3-3j, -4-4j, -3+3j, -4+4j,
                      3-3j,  4-4j,  3+3j,  4+4j,
                      0+0j)
        
        exp_data = (12+0j, 8+0j, 12+0j, 8+0j, 
                    12+0j, 8+0j, 12+0j, 8+0j,
                    0+0j)
        src0 = gr.vector_source_c(src_data0)
        src1 = gr.vector_source_c(src_data1)
        op = gr.multiply_conjugate_cc ()
        dst = gr.vector_sink_c ()

        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 (exp_data, result_data)