Esempio n. 1
0
    def __init__(self, vlen):
        gr.hier_block2.__init__(
            self, "snr_estimator",
            gr.io_signature(2, 2, gr.sizeof_gr_complex * vlen),
            gr.io_signature(1, 1, gr.sizeof_float))

        reference = gr.kludge_copy(gr.sizeof_gr_complex * vlen)
        received = gr.kludge_copy(gr.sizeof_gr_complex * vlen)
        self.connect((self, 0), reference)
        self.connect((self, 1), received)

        received_conjugated = gr.conjugate_cc(vlen)
        self.connect(received, received_conjugated)

        R_innerproduct = gr.multiply_vcc(vlen)
        self.connect(reference, R_innerproduct)
        self.connect(received_conjugated, (R_innerproduct, 1))

        R_sum = vector_sum_vcc(vlen)
        self.connect(R_innerproduct, R_sum)

        R = gr.complex_to_mag_squared()
        self.connect(R_sum, R)

        received_magsqrd = gr.complex_to_mag_squared(vlen)
        reference_magsqrd = gr.complex_to_mag_squared(vlen)
        self.connect(received, received_magsqrd)
        self.connect(reference, reference_magsqrd)

        received_sum = vector_sum_vff(vlen)
        reference_sum = vector_sum_vff(vlen)
        self.connect(received_magsqrd, received_sum)
        self.connect(reference_magsqrd, reference_sum)

        P = gr.multiply_ff()
        self.connect(received_sum, (P, 0))
        self.connect(reference_sum, (P, 1))

        denominator = gr.sub_ff()
        self.connect(P, denominator)
        self.connect(R, (denominator, 1))

        rho_hat = gr.divide_ff()
        self.connect(R, rho_hat)
        self.connect(denominator, (rho_hat, 1))
        self.connect(rho_hat, self)
Esempio n. 2
0
  def __init__(self,vlen):
    gr.hier_block2.__init__(self,"snr_estimator",
      gr.io_signature(2,2,gr.sizeof_gr_complex*vlen),
      gr.io_signature(1,1,gr.sizeof_float))

    reference = gr.kludge_copy(gr.sizeof_gr_complex*vlen)
    received = gr.kludge_copy(gr.sizeof_gr_complex*vlen)
    self.connect((self,0),reference)
    self.connect((self,1),received)

    received_conjugated = gr.conjugate_cc(vlen)
    self.connect(received,received_conjugated)

    R_innerproduct = gr.multiply_vcc(vlen)
    self.connect(reference,R_innerproduct)
    self.connect(received_conjugated,(R_innerproduct,1))

    R_sum = vector_sum_vcc(vlen)
    self.connect(R_innerproduct,R_sum)

    R = gr.complex_to_mag_squared()
    self.connect(R_sum,R)

    received_magsqrd = gr.complex_to_mag_squared(vlen)
    reference_magsqrd = gr.complex_to_mag_squared(vlen)
    self.connect(received,received_magsqrd)
    self.connect(reference,reference_magsqrd)

    received_sum = vector_sum_vff(vlen)
    reference_sum = vector_sum_vff(vlen)
    self.connect(received_magsqrd,received_sum)
    self.connect(reference_magsqrd,reference_sum)

    P = gr.multiply_ff()
    self.connect(received_sum,(P,0))
    self.connect(reference_sum,(P,1))

    denominator = gr.sub_ff()
    self.connect(P,denominator)
    self.connect(R,(denominator,1))

    rho_hat = gr.divide_ff()
    self.connect(R,rho_hat)
    self.connect(denominator,(rho_hat,1))
    self.connect(rho_hat,self)
  def __init__( self, vlen, startup ):
    gr.hier_block2.__init__( self,
          "vector_acc_se",
          gr.io_signature( 1, 1, gr.sizeof_gr_complex * vlen ),
          gr.io_signature( 1, 1, gr.sizeof_float ) )

    squared_error_subc = gr.complex_to_mag_squared( vlen )
    squared_error_block = ofdm.vector_sum_vff( vlen )
    accumulated_squared_error = ofdm.accumulator_ff()

    if startup > 0:
      startup_skip = gr.skiphead( gr.sizeof_gr_complex * vlen, startup )
      self.connect( self, startup_skip, squared_error_subc, squared_error_block,
                    accumulated_squared_error, self )
    else:
      self.connect( self, squared_error_subc, squared_error_block,
                    accumulated_squared_error, self )
Esempio n. 4
0
  def __init__(self, vlen):
    gr.hier_block2.__init__(self, "snr_estimator",
        gr.io_signature2(2,2,gr.sizeof_gr_complex,gr.sizeof_char),
        gr.io_signature (1,1,gr.sizeof_float))
    
    data_in = (self,0)
    trig_in = (self,1)
    snr_out = (self,0)

    ## Preamble Extraction
    sampler = vector_sampler(gr.sizeof_gr_complex,vlen)
    self.connect(data_in,sampler)
    self.connect(trig_in,(sampler,1))
    
    ## Algorithm implementation
    estim = sc_snr_estimator(vlen)
    self.connect(sampler,estim)
    self.connect(estim,snr_out)
    
    return 
  
  
  

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

    ## Conjugate first half block
    conj = gr.conjugate_cc(vlen/2)
    self.connect(splitter,conj)

    ## Vector multiplication of both half blocks
    vmult = gr.multiply_vcc(vlen/2)
    self.connect(conj,vmult)
    self.connect((splitter,1),(vmult,1))

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

    ## Magnitude of P(d)
    p_mag = gr.complex_to_mag()
    self.connect(psum,p_mag)

    ## Squared Magnitude of block
    r_magsqrd = gr.complex_to_mag_squared(vlen)
    self.connect(sampler,r_magsqrd)

    ## Sum of squared second half block
    r_sum = vector_sum_vff(vlen)
    self.connect(r_magsqrd,r_sum)

    ## Square Root of Metric
    m_sqrt = gr.divide_ff()
    self.connect(p_mag,(m_sqrt,0))
    self.connect(r_sum,gr.multiply_const_ff(0.5),(m_sqrt,1))

    ## Denominator of SNR estimate
    denom = gr.add_const_ff(1)
    neg_m_sqrt = gr.multiply_const_ff(-1.0)
    self.connect(m_sqrt,limit_vff(1,1-2e-5,-1000),neg_m_sqrt,denom)

    ## SNR estimate
    snr_est = gr.divide_ff()
    self.connect(m_sqrt,(snr_est,0))
    self.connect(denom,(snr_est,1))

    ## Setup Output Connections
    self.connect(snr_est,self)
Esempio n. 5
0
    def __init__(self, subc, vlen, ss):
        gr.hier_block2.__init__(
            self, "new_snr_estimator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * vlen),
            gr.io_signature(1, 1, gr.sizeof_float))

        print "Created Milan's SNR estimator"

        trigger = [0] * vlen
        trigger[0] = 1

        u = range(vlen / ss * (ss - 1))
        zeros_ind = map(lambda z: z + 1 + z / (ss - 1), u)

        skip1 = skip(gr.sizeof_gr_complex, vlen)
        for x in zeros_ind:
            skip1.skip(x)

        #print "skipped zeros",zeros_ind

        v = range(vlen / ss)
        ones_ind = map(lambda z: z * ss, v)

        skip2 = skip(gr.sizeof_gr_complex, vlen)
        for x in ones_ind:
            skip2.skip(x)

        #print "skipped ones",ones_ind

        v2s = gr.vector_to_stream(gr.sizeof_gr_complex, vlen)
        s2v1 = gr.stream_to_vector(gr.sizeof_gr_complex, vlen / ss)
        trigger_src_1 = gr.vector_source_b(trigger, True)

        s2v2 = gr.stream_to_vector(gr.sizeof_gr_complex, vlen / ss * (ss - 1))
        trigger_src_2 = gr.vector_source_b(trigger, True)

        mag_sq_ones = gr.complex_to_mag_squared(vlen / ss)
        mag_sq_zeros = gr.complex_to_mag_squared(vlen / ss * (ss - 1))

        filt_ones = gr.single_pole_iir_filter_ff(0.1, vlen / ss)
        filt_zeros = gr.single_pole_iir_filter_ff(0.1, vlen / ss * (ss - 1))

        sum_ones = vector_sum_vff(vlen / ss)
        sum_zeros = vector_sum_vff(vlen / ss * (ss - 1))

        D = gr.divide_ff()
        P = gr.multiply_ff()
        mult1 = gr.multiply_const_ff(ss - 1.0)
        add1 = gr.add_const_ff(-1.0)
        mult2 = gr.multiply_const_ff(1. / ss)
        scsnrdb = gr.nlog10_ff(10, 1, 0)
        filt_end = gr.single_pole_iir_filter_ff(0.1)

        self.connect(self, v2s, skip1, s2v1, mag_sq_ones, filt_ones, sum_ones)
        self.connect(trigger_src_1, (skip1, 1))

        self.connect(v2s, skip2, s2v2, mag_sq_zeros, filt_zeros, sum_zeros)
        self.connect(trigger_src_2, (skip2, 1))

        self.connect(sum_ones, D)
        self.connect(sum_zeros, (D, 1))
        self.connect(D, mult1, add1, mult2)

        self.connect(mult2, scsnrdb, filt_end, self)
Esempio n. 6
0
    def __init__(self, subc, vlen, ss):
        gr.hier_block2.__init__(
            self,
            "new_snr_estimator",
            gr.io_signature(2, 2, gr.sizeof_gr_complex * vlen),
            #gr.io_signature2(2,2,gr.sizeof_float*vlen,gr.sizeof_float*vlen/ss*(ss-1)))
            gr.io_signature2(2, 2, gr.sizeof_float * vlen, gr.sizeof_float))

        print "Created Milan's SINR estimator"

        trigger = [0] * vlen
        trigger[0] = 1

        v = range(vlen / ss)
        ones_ind = map(lambda z: z * ss, v)

        skip2_pr0 = skip(gr.sizeof_gr_complex, vlen)
        skip2_pr1 = skip(gr.sizeof_gr_complex, vlen)
        for x in ones_ind:
            skip2_pr0.skip(x)
            skip2_pr1.skip(x)

        #print "skipped ones",ones_ind

        v2s_pr0 = gr.vector_to_stream(gr.sizeof_gr_complex, vlen)
        v2s_pr1 = gr.vector_to_stream(gr.sizeof_gr_complex, vlen)

        s2v2_pr0 = gr.stream_to_vector(gr.sizeof_gr_complex,
                                       vlen / ss * (ss - 1))
        trigger_src_2_pr0 = gr.vector_source_b(trigger, True)
        s2v2_pr1 = gr.stream_to_vector(gr.sizeof_gr_complex,
                                       vlen / ss * (ss - 1))
        trigger_src_2_pr1 = gr.vector_source_b(trigger, True)

        mag_sq_zeros_pr0 = gr.complex_to_mag_squared(vlen / ss * (ss - 1))
        mag_sq_zeros_pr1 = gr.complex_to_mag_squared(vlen / ss * (ss - 1))

        filt_zeros_pr0 = gr.single_pole_iir_filter_ff(0.01,
                                                      vlen / ss * (ss - 1))
        filt_zeros_pr1 = gr.single_pole_iir_filter_ff(0.01,
                                                      vlen / ss * (ss - 1))
        v1 = vlen / ss * (ss - 1)
        vevc1 = [-1] * v1
        neg_nomin_z = gr.multiply_const_vff(vevc1)
        div_z = gr.divide_ff(vlen / ss * (ss - 1))
        on_zeros = gr.add_const_vff(vevc1)
        sum_zeros = add_vff(vlen / ss * (ss - 1))

        # For average
        sum_all = vector_sum_vff(vlen)
        mult = gr.multiply_const_ff(1. / vlen)
        scsnr_db_av = gr.nlog10_ff(10, 1, 0)
        filt_end_av = gr.single_pole_iir_filter_ff(0.1)

        self.connect((self, 0), v2s_pr0, skip2_pr0, s2v2_pr0, mag_sq_zeros_pr0,
                     filt_zeros_pr0)
        self.connect(trigger_src_2_pr0, (skip2_pr0, 1))

        self.connect((self, 1), v2s_pr1, skip2_pr1, s2v2_pr1, mag_sq_zeros_pr1,
                     filt_zeros_pr1)
        self.connect(trigger_src_2_pr1, (skip2_pr1, 1))

        # On zeros
        self.connect(filt_zeros_pr1, (sum_zeros, 0))
        self.connect(filt_zeros_pr0, neg_nomin_z, (sum_zeros, 1))
        self.connect(sum_zeros, div_z)
        self.connect(filt_zeros_pr0, (div_z, 1))

        scsnr_db = gr.nlog10_ff(10, vlen, 0)
        filt_end = gr.single_pole_iir_filter_ff(0.1, vlen)

        dd = []
        for i in range(vlen / ss):
            dd.extend([i * ss])
        #print dd
        interpolator = sinr_interpolator(vlen, ss, dd)

        self.connect(div_z, interpolator, filt_end, scsnr_db, self)
        self.connect(interpolator, sum_all, mult, scsnr_db_av, filt_end_av,
                     (self, 1))
Esempio n. 7
0
  def __init__(self, subc, vlen, ss):
    gr.hier_block2.__init__(self, "new_snr_estimator",
        gr.io_signature(1,1,gr.sizeof_gr_complex*vlen),
        gr.io_signature(1,1,gr.sizeof_float))

    print "Created Milan's SNR estimator"

    trigger = [0]*vlen
    trigger[0] = 1


    u = range (vlen/ss*(ss-1))
    zeros_ind= map(lambda z: z+1+z/(ss-1),u)

    skip1 = skip(gr.sizeof_gr_complex,vlen)
    for x in zeros_ind:
      skip1.skip(x)

    #print "skipped zeros",zeros_ind

    v = range (vlen/ss)
    ones_ind= map(lambda z: z*ss,v)

    skip2 = skip(gr.sizeof_gr_complex,vlen)
    for x in ones_ind:
      skip2.skip(x)

    #print "skipped ones",ones_ind

    v2s = gr.vector_to_stream(gr.sizeof_gr_complex,vlen)
    s2v1 = gr.stream_to_vector(gr.sizeof_gr_complex,vlen/ss)
    trigger_src_1 = gr.vector_source_b(trigger,True)

    s2v2 = gr.stream_to_vector(gr.sizeof_gr_complex,vlen/ss*(ss-1))
    trigger_src_2 = gr.vector_source_b(trigger,True)

    mag_sq_ones = gr.complex_to_mag_squared(vlen/ss)
    mag_sq_zeros = gr.complex_to_mag_squared(vlen/ss*(ss-1))

    filt_ones = gr.single_pole_iir_filter_ff(0.1,vlen/ss)
    filt_zeros = gr.single_pole_iir_filter_ff(0.1,vlen/ss*(ss-1))

    sum_ones = vector_sum_vff(vlen/ss)
    sum_zeros = vector_sum_vff(vlen/ss*(ss-1))

    D = gr.divide_ff()
    P = gr.multiply_ff()
    mult1 = gr.multiply_const_ff(ss-1.0)
    add1 = gr.add_const_ff(-1.0)
    mult2 = gr.multiply_const_ff(1./ss)
    scsnrdb = gr.nlog10_ff(10,1,0)
    filt_end = gr.single_pole_iir_filter_ff(0.1)

    self.connect(self,v2s,skip1,s2v1,mag_sq_ones,filt_ones,sum_ones)
    self.connect(trigger_src_1,(skip1,1))

    self.connect(v2s,skip2,s2v2,mag_sq_zeros,filt_zeros,sum_zeros)
    self.connect(trigger_src_2,(skip2,1))

    self.connect(sum_ones,D)
    self.connect(sum_zeros,(D,1))
    self.connect(D,mult1,add1,mult2)

    self.connect(mult2,scsnrdb,filt_end,self)
Esempio n. 8
0
  def __init__(self, subc, vlen, ss):
    gr.hier_block2.__init__(self, "new_snr_estimator",
        gr.io_signature(2,2,gr.sizeof_gr_complex*vlen),
        #gr.io_signature2(2,2,gr.sizeof_float*vlen,gr.sizeof_float*vlen/ss*(ss-1)))
        gr.io_signature2(2,2,gr.sizeof_float*vlen,gr.sizeof_float))

    print "Created Milan's SINR estimator"

    trigger = [0]*vlen
    trigger[0] = 1

    v = range (vlen/ss)
    ones_ind= map(lambda z: z*ss,v)

    skip2_pr0 = skip(gr.sizeof_gr_complex,vlen)
    skip2_pr1 = skip(gr.sizeof_gr_complex,vlen)
    for x in ones_ind:
      skip2_pr0.skip(x)
      skip2_pr1.skip(x)

    #print "skipped ones",ones_ind

    v2s_pr0 = gr.vector_to_stream(gr.sizeof_gr_complex,vlen)
    v2s_pr1 = gr.vector_to_stream(gr.sizeof_gr_complex,vlen)

    s2v2_pr0 = gr.stream_to_vector(gr.sizeof_gr_complex,vlen/ss*(ss-1))
    trigger_src_2_pr0 = gr.vector_source_b(trigger,True)
    s2v2_pr1 = gr.stream_to_vector(gr.sizeof_gr_complex,vlen/ss*(ss-1))
    trigger_src_2_pr1 = gr.vector_source_b(trigger,True)

    mag_sq_zeros_pr0 = gr.complex_to_mag_squared(vlen/ss*(ss-1))
    mag_sq_zeros_pr1 = gr.complex_to_mag_squared(vlen/ss*(ss-1))


    filt_zeros_pr0 = gr.single_pole_iir_filter_ff(0.01,vlen/ss*(ss-1))
    filt_zeros_pr1 = gr.single_pole_iir_filter_ff(0.01,vlen/ss*(ss-1))
    v1 = vlen/ss*(ss-1)
    vevc1 =[-1]*v1
    neg_nomin_z = gr.multiply_const_vff(vevc1)
    div_z=gr.divide_ff(vlen/ss*(ss-1))
    on_zeros = gr.add_const_vff(vevc1)
    sum_zeros = add_vff(vlen/ss*(ss-1))
    
    # For average
    sum_all = vector_sum_vff(vlen)
    mult = gr.multiply_const_ff(1./vlen)
    scsnr_db_av = gr.nlog10_ff(10,1,0)
    filt_end_av = gr.single_pole_iir_filter_ff(0.1)


    self.connect((self,0),v2s_pr0,skip2_pr0,s2v2_pr0,mag_sq_zeros_pr0,filt_zeros_pr0)
    self.connect(trigger_src_2_pr0,(skip2_pr0,1))



    self.connect((self,1),v2s_pr1,skip2_pr1,s2v2_pr1,mag_sq_zeros_pr1,filt_zeros_pr1)
    self.connect(trigger_src_2_pr1,(skip2_pr1,1))


    # On zeros
    self.connect(filt_zeros_pr1,(sum_zeros,0))
    self.connect(filt_zeros_pr0,neg_nomin_z,(sum_zeros,1))
    self.connect(sum_zeros,div_z)
    self.connect(filt_zeros_pr0,(div_z,1))


    scsnr_db = gr.nlog10_ff(10,vlen,0)
    filt_end = gr.single_pole_iir_filter_ff(0.1,vlen)



    dd = []
    for i in range (vlen/ss):
        dd.extend([i*ss])
    #print dd
    interpolator = sinr_interpolator(vlen, ss,dd)

    self.connect(div_z,interpolator,filt_end,scsnr_db,self)
    self.connect(interpolator,sum_all,mult,scsnr_db_av,filt_end_av,(self,1))
Esempio n. 9
0
    def __init__(self, vlen):
        gr.hier_block2.__init__(
            self, "snr_estimator",
            gr.io_signature2(2, 2, gr.sizeof_gr_complex, gr.sizeof_char),
            gr.io_signature(1, 1, gr.sizeof_float))

        data_in = (self, 0)
        trig_in = (self, 1)
        snr_out = (self, 0)

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

        ## Algorithm implementation
        estim = sc_snr_estimator(vlen)
        self.connect(sampler, estim)
        self.connect(estim, snr_out)

        return

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

        ## Conjugate first half block
        conj = gr.conjugate_cc(vlen / 2)
        self.connect(splitter, conj)

        ## Vector multiplication of both half blocks
        vmult = gr.multiply_vcc(vlen / 2)
        self.connect(conj, vmult)
        self.connect((splitter, 1), (vmult, 1))

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

        ## Magnitude of P(d)
        p_mag = gr.complex_to_mag()
        self.connect(psum, p_mag)

        ## Squared Magnitude of block
        r_magsqrd = gr.complex_to_mag_squared(vlen)
        self.connect(sampler, r_magsqrd)

        ## Sum of squared second half block
        r_sum = vector_sum_vff(vlen)
        self.connect(r_magsqrd, r_sum)

        ## Square Root of Metric
        m_sqrt = gr.divide_ff()
        self.connect(p_mag, (m_sqrt, 0))
        self.connect(r_sum, gr.multiply_const_ff(0.5), (m_sqrt, 1))

        ## Denominator of SNR estimate
        denom = gr.add_const_ff(1)
        neg_m_sqrt = gr.multiply_const_ff(-1.0)
        self.connect(m_sqrt, limit_vff(1, 1 - 2e-5, -1000), neg_m_sqrt, denom)

        ## SNR estimate
        snr_est = gr.divide_ff()
        self.connect(m_sqrt, (snr_est, 0))
        self.connect(denom, (snr_est, 1))

        ## Setup Output Connections
        self.connect(snr_est, self)