예제 #1
0
    def test_001 (self):
        src_data = (1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1)

        expected_data = (   0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 1.384, 0.794, 1.384, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.794, 1.384, 2.411, 1.384, 0.794, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.794, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000  )
        Np = 4
        P = 4
        L = 2
        src = gr.vector_source_c(src_data, False)
        cyclo_fam = specest.cyclo_fam(Np, P, L)

        sink = gr.vector_sink_f(2*Np)
        self.tb.connect(src, cyclo_fam, sink)
        self.tb.run()
        estimated_data =  sink.data()[-2*P*L*(2*Np):]
        self.assertFloatTuplesAlmostEqual(expected_data,estimated_data,3)
예제 #2
0
 def __init__(self,
              Np=32,
              P=128,
              L=2,
              filename=None,
              sample_type='complex',
              verbose=True):
     gr.top_block.__init__(self)
     if filename is None:
         src = analog.noise_source_c(analog.GR_GAUSSIAN, 1)
         if verbose:
             print "Using Gaussian noise source."
     else:
         if sample_type == 'complex':
             src = blocks.file_source(gr.sizeof_gr_complex, filename, True)
         else:
             fsrc = blocks.file_source(gr.sizeof_float, filename, True)
             src = blocks.float_to_complex()
             self.connect(fsrc, src)
         if verbose:
             print "Reading data from %s" % filename
     if verbose:
         print "FAM configuration:"
         print "N'   = %d" % Np
         print "P    = %d" % P
         print "L    = %d" % L
         #print "Δf   = %f" % asfd
     sink = blocks.null_sink(gr.sizeof_float * 2 * Np)
     self.cyclo_fam = specest.cyclo_fam(Np, P, L)
     self.connect(src, self.cyclo_fam, sink)
    def test_001 (self):
        src_data = (1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1)

        expected_data = (   0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 1.384, 0.794, 1.384, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.794, 1.384, 2.411, 1.384, 0.794, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.794, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
                            0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000  )
        Np = 4
        P = 4
        L = 2
        src = blocks.vector_source_c(src_data, False)
        cyclo_fam = specest.cyclo_fam(Np, P, L)

        sink = blocks.vector_sink_f(2*Np)
        self.tb.connect(src, cyclo_fam, sink)
        self.tb.run()
        estimated_data =  sink.data()[-2*P*L*(2*Np):]
        self.assertFloatTuplesAlmostEqual(expected_data,estimated_data,3)
예제 #4
0
    def test_008 (self):

        fs = 133
        df = 2.3
        da = 1.4
        q  = 0.9
        cyclo_fam  = specest.cyclo_fam(fs, df, da, q)
        self.assertEqual(cyclo_fam.get_sample_frequency(),fs)
예제 #5
0
    def test_get_functions_007 (self):

        Np = 128
        P = 512
        L = 4
        N = P*L
        cyclo_fam  = specest.cyclo_fam(Np,P,L)
        self.assertEqual(cyclo_fam.get_Np(),Np)
        self.assertEqual(cyclo_fam.get_N(),N)
        self.assertEqual(cyclo_fam.get_L(),L)
        self.assertEqual(cyclo_fam.get_P(),P)
예제 #6
0
 def test_002 (self):
     """ Stream some data through the block to see it all works. """
     Np = 128
     P = 512
     L = 4
     src = gr.noise_source_c(gr.GR_GAUSSIAN, 1)
     head = gr.head(gr.sizeof_gr_complex, P * L)
     cyclo_fam  = specest.cyclo_fam (Np,P,L)
     dst = gr.vector_sink_f(2*Np)
     self.tb.connect(src, head, cyclo_fam, dst)
     try:
         self.tb.run()
     except:
         self.fail("Something's wrong -- an exception was thrown during runtime.")
 def test_002 (self):
     """ Stream some data through the block to see it all works. """
     Np = 128
     P = 512
     L = 4
     src = analog.noise_source_c(analog.GR_GAUSSIAN, 1)
     head = blocks.head(gr.sizeof_gr_complex, P * L)
     cyclo_fam  = specest.cyclo_fam (Np,P,L)
     dst = blocks.vector_sink_f(2*Np)
     self.tb.connect(src, head, cyclo_fam, dst)
     try:
         self.tb.run()
     except:
         self.fail("Something's wrong -- an exception was thrown during runtime.")