Exemple #1
0
    def __init__(self, N=512 , NW=3 , K=5, weighting='adaptive', fftshift=False):
        gr.hier_block2.__init__(self, "mtm",
                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                gr.io_signature(1, 1, gr.sizeof_float*N))
        self.check_parameters(N, NW, K)

        self.s2v = gr.stream_to_vector(gr.sizeof_gr_complex, N)
        self.connect(self, self.s2v)

        dpss = specest_gendpss.gendpss(N=N, NW=NW, K=K)
        self.mtm = [eigenspectrum(dpss.dpssarray[i], fftshift) for i in xrange(K)]
        if weighting == 'adaptive':
            self.sum = specest_swig.adaptiveweighting_vff(N, dpss.lambdas)
            self.connect_mtm(K)
            self.connect(self.sum, self)
        elif weighting == 'unity':
            self.sum = gr.add_ff(N)
            self.divide = gr.multiply_const_vff([1./K]*N)
            self.connect_mtm(K)
            self.connect(self.sum, self.divide, self)
        elif weighting == 'eigenvalues':
            self.eigvalmulti = []
            self.lambdasum = 0
            for i in xrange(K):
                self.eigvalmulti.append(gr.multiply_const_vff([dpss.lambdas[i]]*N))
                self.lambdasum += dpss.lambdas[i]
            self.divide = gr.multiply_const_vff([1./self.lambdasum]*N)
            self.sum = gr.add_ff(N)
            self.connect_mtm(K)
            self.connect(self.sum, self.divide, self)
        else:
            raise ValueError, 'weighting-type should be: adaptive, unity or eigenvalues'
Exemple #2
0
    def __init__(self, N=512 , NW=3 , K=5, weighting='adaptive', fftshift=False):
        gr.hier_block2.__init__(self, "mtm",
                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                gr.io_signature(1, 1, gr.sizeof_float*N))
        self.check_parameters(N, NW, K)

        self.s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, N)
        self.connect(self, self.s2v)

        dpss = specest_gendpss.gendpss(N=N, NW=NW, K=K)
        self.mtm = [eigenspectrum(dpss.dpssarray[i], fftshift) for i in xrange(K)]
        if weighting == 'adaptive':
            self.sum = specest_swig.adaptiveweighting_vff(N, dpss.lambdas)
            self.connect_mtm(K)
            self.connect(self.sum, self)
        elif weighting == 'unity':
            self.sum = blocks.add_ff(N)
            self.divide = blocks.multiply_const_vff([1./K]*N)
            self.connect_mtm(K)
            self.connect(self.sum, self.divide, self)
        elif weighting == 'eigenvalues':
            self.eigvalmulti = []
            self.lambdasum = 0
            for i in xrange(K):
                self.eigvalmulti.append(blocks.multiply_const_vff([dpss.lambdas[i]]*N))
                self.lambdasum += dpss.lambdas[i]
            self.divide = blocks.multiply_const_vff([1./self.lambdasum]*N)
            self.sum = blocks.add_ff(N)
            self.connect_mtm(K)
            self.connect(self.sum, self.divide, self)
        else:
            raise ValueError, 'weighting-type should be: adaptive, unity or eigenvalues'
Exemple #3
0
    def __init__(self, N=512 , NW=3 , K=5, fftshift=False, samp_rate = 1, rate = 10):
        gr.hier_block2.__init__(self, "loeve",
                gr.io_signature(2, 2, gr.sizeof_gr_complex),
                gr.io_signature(1, 1, gr.sizeof_float*N))
        self.check_parameters(N, NW, K)

        self.s2v1 = blocks.stream_to_vector(gr.sizeof_gr_complex, N)
        self.s2v2 = blocks.stream_to_vector(gr.sizeof_gr_complex, N)
        self.one_in_n1 = blocks.keep_one_in_n(gr.sizeof_gr_complex * N, max(1, int(samp_rate/N/rate)))
        self.one_in_n2 = blocks.keep_one_in_n(gr.sizeof_gr_complex * N, max(1, int(samp_rate/N/rate)))
        self.connect((self, 0), self.s2v1, self.one_in_n1)
        self.connect((self, 1), self.s2v2, self.one_in_n2)

        dpss = specest_gendpss.gendpss(N=N, NW=NW, K=K)
        self.mtm1 = [eigenspectrum(dpss.dpssarray[i], fftshift) for i in xrange(K)]
        self.mtm2 = [eigenspectrum(dpss.dpssarray[i], fftshift) for i in xrange(K)]
        
        self.multipliers = [blocks.multiply_vcc(N) for i in xrange(K)]

        self.sum = blocks.add_vcc(N)
        self.divide = blocks.multiply_const_vcc([1./K]*N)
        self.c2mag = blocks.complex_to_mag_squared(N)
        self.connect_loeve(K)
        self.connect(self.sum, self.divide, self.c2mag, self)
	def test_gen(self):
		dpss = specest_gendpss.gendpss(N = self.N, K = self.K, NW = self.NW)	
		A = numpy.array(dpss.dpssarray)
		B = numpy.array(test_sig)
		self.assertMatrixAlmostEqual(A,B,places=6)
Exemple #5
0
 def test_gen(self):
     dpss = specest_gendpss.gendpss(N=self.N, K=self.K, NW=self.NW)
     A = numpy.array(dpss.dpssarray)
     B = numpy.array(test_sig)
     self.assertMatrixAlmostEqual(A, B, places=6)