def test_000(self): N = 1000 # number of samples to use M = 5 # Number of channels fs = 1000 # baseband sampling rate ifs = M*fs # input samp rate to decimator taps = filter.firdes.low_pass_2(M, ifs, fs/2, fs/10, attenuation_dB=80, window=filter.firdes.WIN_BLACKMAN_hARRIS) freq = 100 data = sig_source_c(fs, freq, 1, N) signal = blocks.vector_source_c(data) pfb = filter.pfb_interpolator_ccf(M, taps) snk = blocks.vector_sink_c() self.tb.connect(signal, pfb) self.tb.connect(pfb, snk) self.tb.run() Ntest = 50 L = len(snk.data()) t = map(lambda x: float(x)/ifs, xrange(L)) # Create known data as complex sinusoids at freq # of the channel at the interpolated rate. phase = 0.62833 expected_data = map(lambda x: math.cos(2.*math.pi*freq*x+phase) + \ 1j*math.sin(2.*math.pi*freq*x+phase), t) dst_data = snk.data() self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:], dst_data[-Ntest:], 4)
def test_000(self): N = 1000 # number of samples to use M = 5 # Number of channels fs = 1000 # baseband sampling rate ofs = M * fs # output samp rate of interpolator taps = filter.firdes.low_pass_2( M, ofs, fs / 4, fs / 10, attenuation_dB=80, window=filter.firdes.WIN_BLACKMAN_hARRIS) freq = 123.456 data = sig_source_c(fs, freq, 1, N) signal = blocks.vector_source_c(data) pfb = filter.pfb_interpolator_ccf(M, taps) snk = blocks.vector_sink_c() self.tb.connect(signal, pfb) self.tb.connect(pfb, snk) self.tb.run() Ntest = 50 L = len(snk.data()) # Phase rotation through the filters phase = 4.8870112969978994 # Create a time scale t = [float(x) / ofs for x in range(0, L)] # Create known data as complex sinusoids for the baseband freq # of the extracted channel is due to decimator output order. 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:], 4)
def test_000(self): N = 1000 # number of samples to use M = 5 # Number of channels fs = 1000 # baseband sampling rate ifs = M*fs # input samp rate to decimator taps = filter.firdes.low_pass_2(M, ifs, fs/2, fs/10, attenuation_dB=80, window=filter.firdes.WIN_BLACKMAN_hARRIS) freq = 123.456 data = sig_source_c(fs, freq, 1, N) signal = blocks.vector_source_c(data) pfb = filter.pfb_interpolator_ccf(M, taps) snk = blocks.vector_sink_c() self.tb.connect(signal, pfb) self.tb.connect(pfb, snk) self.tb.run() Ntest = 50 L = len(snk.data()) # Can only get channel 0 out; no phase rotation phase = 0 # Calculate the filter delay delay = -(len(taps) - 1) / 2.0 - (M-1) delay = int(delay) # Create a time scale that's delayed to match the filter delay t = map(lambda x: float(x)/ifs, xrange(delay, L+delay)) # Create known data as complex sinusoids for the baseband freq # of the extracted channel is due to decimator output order. expected_data = map(lambda x: math.cos(2.*math.pi*freq*x+phase) + \ 1j*math.sin(2.*math.pi*freq*x+phase), t) dst_data = snk.data() self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:], dst_data[-Ntest:], 4)
def test_000(self): N = 1000 # number of samples to use M = 5 # Number of channels fs = 1000 # baseband sampling rate ifs = M * fs # input samp rate to decimator taps = filter.firdes.low_pass_2( M, ifs, fs / 2, fs / 10, attenuation_dB=80, window=filter.firdes.WIN_BLACKMAN_hARRIS) freq = 100 data = sig_source_c(fs, freq, 1, N) signal = blocks.vector_source_c(data) pfb = filter.pfb_interpolator_ccf(M, taps) snk = blocks.vector_sink_c() self.tb.connect(signal, pfb) self.tb.connect(pfb, snk) self.tb.run() Ntest = 50 L = len(snk.data()) t = map(lambda x: float(x) / ifs, xrange(L)) # Create known data as complex sinusoids at freq # of the channel at the interpolated rate. phase = 0.62833 expected_data = map(lambda x: math.cos(2.*math.pi*freq*x+phase) + \ 1j*math.sin(2.*math.pi*freq*x+phase), t) dst_data = snk.data() self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:], dst_data[-Ntest:], 4)
def test_000(self): N = 1000 # number of samples to use M = 5 # Number of channels fs = 1000 # baseband sampling rate ofs = M*fs # output samp rate of interpolator taps = filter.firdes.low_pass_2(M, ofs, fs/4, fs/10, attenuation_dB=80, window=filter.firdes.WIN_BLACKMAN_hARRIS) freq = 123.456 data = sig_source_c(fs, freq, 1, N) signal = blocks.vector_source_c(data) pfb = filter.pfb_interpolator_ccf(M, taps) snk = blocks.vector_sink_c() self.tb.connect(signal, pfb) self.tb.connect(pfb, snk) self.tb.run() Ntest = 50 L = len(snk.data()) # Phase rotation through the filters phase = 4.8870112969978994 # Create a time scale t = map(lambda x: float(x)/ofs, xrange(0, L)) # Create known data as complex sinusoids for the baseband freq # of the extracted channel is due to decimator output order. expected_data = map(lambda x: math.cos(2.*math.pi*freq*x+phase) + \ 1j*math.sin(2.*math.pi*freq*x+phase), t) dst_data = snk.data() self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:], dst_data[-Ntest:], 4)