コード例 #1
0
ファイル: phase_noise_gen.py プロジェクト: no-net/gr-winelo
    def __init__(self, alpha=0.1, noise_mag=0):
        """
            Parameters:

                alpha: float
                noise_mag: float
        """
        gr.hier_block2.__init__(
            self, "Phase Noise Generator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
        )

        ##################################################
        # Parameters
        ##################################################
        self.alpha = alpha
        self.noise_mag = noise_mag

        ##################################################
        # Blocks
        ##################################################
        self.gr_transcendental_0_0 = gr.transcendental("sin", "float")
        self.gr_transcendental_0 = gr.transcendental("cos", "float")
        self.gr_single_pole_iir_filter_xx_0 = gr.single_pole_iir_filter_ff(
            alpha, 1)
        self.gr_noise_source_x_0 = gr.noise_source_f(gr.GR_GAUSSIAN, noise_mag,
                                                     42)
        self.gr_multiply_xx_0 = gr.multiply_vcc(1)
        self.gr_float_to_complex_0 = gr.float_to_complex(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_float_to_complex_0, 0),
                     (self.gr_multiply_xx_0, 1))
        self.connect((self.gr_noise_source_x_0, 0),
                     (self.gr_single_pole_iir_filter_xx_0, 0))
        self.connect((self.gr_multiply_xx_0, 0), (self, 0))
        self.connect((self, 0), (self.gr_multiply_xx_0, 0))
        self.connect((self.gr_single_pole_iir_filter_xx_0, 0),
                     (self.gr_transcendental_0, 0))
        self.connect((self.gr_single_pole_iir_filter_xx_0, 0),
                     (self.gr_transcendental_0_0, 0))
        self.connect((self.gr_transcendental_0, 0),
                     (self.gr_float_to_complex_0, 0))
        self.connect((self.gr_transcendental_0_0, 0),
                     (self.gr_float_to_complex_0, 1))
コード例 #2
0
 def test_atan_ff (self):
     src_data = [float(i/100) for i in range(-100, 100)]
     expected_result = tuple(math.atan(i) for i in src_data)
     src = gr.vector_source_f(src_data)
     op = gr.transcendental('atan', 'float')
     snk = gr.vector_sink_f()
     self.tb.connect(src, op, snk)
     self.tb.run()
     result = snk.data()
     self.assertFloatTuplesAlmostEqual(expected_result, result, places=5)
コード例 #3
0
 def test_sqrt_cc (self):
     src_data = [complex(i,i+1) for i in range(1, 100, 2)]
     expected_result = tuple(cmath.sqrt(i) for i in src_data)
     src = gr.vector_source_c(src_data)
     op = gr.transcendental('sqrt', 'complex_float')
     snk = gr.vector_sink_c()
     self.tb.connect(src, op, snk)
     self.tb.run()
     result = snk.data()
     self.assertComplexTuplesAlmostEqual(expected_result, result, places=5)