예제 #1
0
This testbench initializes a simple bifrost pipeline that reads from a binary file,
and then writes the data to an output file. 
"""
import os
import numpy as np
import bifrost.pipeline as bfp
from bifrost.blocks import BinaryFileReadBlock, BinaryFileWriteBlock
import glob

if __name__ == "__main__":

    # Setup pipeline
    filenames = sorted(glob.glob('testdata/sin_data*.bin'))
    b_read = BinaryFileReadBlock(filenames, 32768, 1, 'f32')
    b_write = BinaryFileWriteBlock(b_read)

    # Run pipeline
    pipeline = bfp.get_default_pipeline()
    print pipeline.dot_graph()
    pipeline.run()

    # Check the output files match the input files
    for filename in filenames:
        try:
            print filename
            indata = np.fromfile(filename, dtype='float32')
            outdata = np.fromfile('%s.out' % filename, dtype='float32')
            assert np.allclose(indata, outdata)
            print "    Input data and output data match."
        except AssertionError:
예제 #2
0
from scipy.fftpack import fft as scipy_fft

if __name__ == "__main__":
    # FFT Parameters
    window_len = 2**18
    n_window = 32

    # Setup pipeline
    filenames = sorted(glob.glob('testdata/noisy_data*.bin'))

    b_read = BinaryFileReadBlock(filenames, window_len, 1, 'cf32', core=0)
    b_copy = CopyBlock(b_read, space='cuda', core=1, gpu=0)
    b_fft = FftBlock(b_copy, axes=1, core=2, gpu=0)
    b_out = CopyBlock(b_fft, space='system', core=3)
    b_write = BinaryFileWriteBlock(b_out, core=4)

    # Run pipeline
    pipeline = bfp.get_default_pipeline()
    print(pipeline.dot_graph())
    pipeline.run()

    # Check the output files match the input files
    for filename in filenames:
        try:
            print(filename)

            # Load the input data, do a windowed FFT
            indata = np.fromfile(filename, dtype='complex64')
            indata = scipy_fft(indata.reshape(n_window, window_len), axis=1)