def test_ccc_001(self):
        N = 50000  # number of samples to use
        fs = 5000.0  # baseband sampling rate
        rrate = 0.715  # resampling rate

        nfilts = 32
        taps = filter.firdes.complex_band_pass_2(
            nfilts,
            nfilts * fs,
            50,
            400,
            fs / 10,
            attenuation_dB=80,
            window=filter.firdes.WIN_BLACKMAN_hARRIS)

        freq = 211.123
        data = sig_source_c(fs, freq, 1, N)
        signal = blocks.vector_source_c(data)
        pfb = filter.pfb_arb_resampler_ccc(rrate, taps, nfilts)
        snk = blocks.vector_sink_c()

        self.tb.connect(signal, pfb, snk)
        self.tb.run()

        Ntest = 50
        L = len(snk.data())

        # Get group delay and estimate of phase offset from the filter itself.
        delay = pfb.group_delay()
        phase = pfb.phase_offset(freq, fs)

        # Create a timeline offset by the filter's group delay
        t = [float(x) / (fs * rrate) for x in range(-delay, L - delay)]

        # Data of the sinusoid at frequency freq with the delay and phase
        # offset.
        expected_data = [
            math.cos(2. * math.pi * freq * x + phase) +
            1j * math.sin(2. * math.pi * freq * x + phase) for x in t
        ]

        dst_data = snk.data()

        self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:],
                                            dst_data[-Ntest:], 2)
Пример #2
0
    def test_ccc_001(self):
        N = 50000        # number of samples to use
        fs = 5000.0      # baseband sampling rate
        rrate = 0.715    # resampling rate

        nfilts = 32
        taps = filter.firdes.complex_band_pass_2(nfilts, nfilts*fs, 50, 400, fs / 10,
                                                 attenuation_dB=80,
                                                 window=filter.firdes.WIN_BLACKMAN_hARRIS)

        freq = 211.123
        data = sig_source_c(fs, freq, 1, N)
        signal = blocks.vector_source_c(data)
        pfb = filter.pfb_arb_resampler_ccc(rrate, taps, nfilts)
        snk = blocks.vector_sink_c()

        self.tb.connect(signal, pfb, snk)
        self.tb.run()

        Ntest = 50
        L = len(snk.data())

        # Get group delay and estimate of phase offset from the filter itself.
        delay = pfb.group_delay()
        phase = pfb.phase_offset(freq, fs)

        # Create a timeline offset by the filter's group delay
        t = [float(x) / (fs*rrate) for x in range(-delay, L-delay)]

        # Data of the sinusoid at frequency freq with the delay and phase offset.
        expected_data = [math.cos(2.*math.pi*freq*x+phase) + \
                                1j*math.sin(2.*math.pi*freq*x+phase) for x in t]

        dst_data = snk.data()

        self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:], dst_data[-Ntest:], 2)