Exemple #1
0
def main():
    import sys
    if len(sys.argv) <= 1:
        print "Usage: example1.py file1.fil [file2.fil ...]"
        sys.exit(-1)
    filenames = sys.argv[1:]

    h_filterbank = read_sigproc(filenames, gulp_nframe=16000, core=0)
    h_filterbank = scrunch(h_filterbank, 16, core=0)
    d_filterbank = copy(h_filterbank, space='cuda', gpu=0, core=2)
    blocks.print_header(d_filterbank)
    with bfp.block_scope(core=2, gpu=0):
        d_filterbankT = transpose(d_filterbank,
                                  ['pol', 'freq', 'time'])  #[1,2,0])
        d_dispersionbankT = fdmt(d_filterbankT, max_dm=282.52)
        blocks.print_header(d_dispersionbankT)
        d_dispersionbank = transpose(d_dispersionbankT,
                                     ['time', 'pol', 'dispersion'])  #[2,0,1])
    h_dispersionbank = copy(d_dispersionbank, space='system', core=3)
    write_pgm(h_dispersionbank, core=3)

    pipeline = bfp.get_default_pipeline()
    graph_filename = "example1.dot"
    with open(graph_filename, 'w') as dotfile:
        dotfile.write(str(pipeline.dot_graph()))
        print "Wrote graph definition to", graph_filename
    pipeline.run()
    print "All done"
Exemple #2
0
def main(args):
    h_filterbank = read_sigproc(args.filename, gulp_nframe=16000, core=0)
    h_filterbank = scrunch(h_filterbank, 16, core=0)
    d_filterbank = copy(h_filterbank, space='cuda', gpu=0, core=2)
    blocks.print_header(d_filterbank)
    with bfp.block_scope(core=2, gpu=0):
        d_filterbankT = transpose(d_filterbank,
                                  ['pol', 'freq', 'time'])  #[1,2,0])
        d_dispersionbankT = fdmt(d_filterbankT, max_dm=282.52)
        blocks.print_header(d_dispersionbankT)
        d_dispersionbank = transpose(d_dispersionbankT,
                                     ['time', 'pol', 'dispersion'])  #[2,0,1])
    h_dispersionbank = copy(d_dispersionbank, space='system', core=3)
    write_pgm(h_dispersionbank, core=3)

    pipeline = bfp.get_default_pipeline()
    graph_filename = "example1.dot"
    with open(graph_filename, 'w') as dotfile:
        dotfile.write(str(pipeline.dot_graph()))
        print("Wrote graph definition to", graph_filename)
    pipeline.run()
    print("All done")
Exemple #3
0
    def test_read_sigproc(self):
        """Capture print output, assert it is a long string"""
        gulp_nframe = 101

        stdout = io.BytesIO()
        with ExitStack() as stack:
            pipeline = stack.enter_context(bfp.Pipeline())
            stack.enter_context(redirect_stdout(stdout))

            rawdata = blocks.sigproc.read_sigproc([self.fil_file], gulp_nframe)
            print_header_block = blocks.print_header(rawdata)
            pipeline.run()
        print_header_dump = stdout.getvalue()
        self.assertGreater(len(print_header_dump), 10)
Exemple #4
0
    #############

    # Buffer up two blocks & reshape to allow longer FFT
    with bf.block_scope(fuse=True, core=1):
        b_gup2 = views.split_axis(b_read,
                                  axis='time',
                                  n=n_chunks,
                                  label='time_chunk')
        b_gup2 = blocks.transpose(
            b_gup2, axes=['time', 'channel', 'time_chunk', 'fine_time', 'pol'])
        b_gup2 = views.reverse_scale(b_gup2, 'time_chunk')
        b_gup2 = views.merge_axes(b_gup2,
                                  'time_chunk',
                                  'fine_time',
                                  label='fine_time')
        blocks.print_header(b_gup2)

    # Copy over to GPU and FFT
    with bf.block_scope(fuse=True, core=2):
        b_copy = blocks.copy(b_gup2, space='cuda')
        b_fft = blocks.fft(b_copy, axes='fine_time', axis_labels='freq')
        b_ffs = blocks.fftshift(b_fft, axes='freq')
        #blocks.print_header(b_fft)
        b_pow = blocks.detect(b_ffs, mode='stokes')
        b_copp = blocks.copy(b_pow, space='system')

    #blocks.print_header(b_copp)
    # Flatten channel/freq axis to form output spectra and accumulate
    b_copp = blocks.copy(b_copp, space='system', buffer_nframe=4, core=2)
    b_flat = views.merge_axes(b_copp, 'channel', 'freq', label='freq')
    b_acc = byip.accumulate(b_flat, n_int, core=2, buffer_nframe=4)
               ospan.data.shape,
               'i',
               'j',
               'k',
               'l',
               a=ispan.data,
               b=ospan.data)


def grab_first(iring, axis=0):
    return GrabFirstBlock(iring, axis)


with bfp.Pipeline() as pipeline:
    raw_guppi = new_read_guppi_raw(
        ['blc1_guppi_57388_HIP113357_0010.0000.raw'], buffer_nframe=1)
    g_guppi = blocks.copy(raw_guppi, space='cuda', buffer_nframe=1)
    ffted = blocks.fft(g_guppi,
                       axes='fine_time',
                       axis_labels='freq',
                       buffer_nframe=1)
    modulo = blocks.detect(ffted, mode='stokes', buffer_nframe=1)
    # Take I
    first_element = grab_first(modulo, 0)
    transposed = blocks.transpose(first_element,
                                  ['channel', 'time', 'pol', 'freq'])
    renamed = views.rename_axis(transposed, 'channel', 'beam')
    blocks.print_header(renamed)
    blocks.write_sigproc(renamed)
    pipeline.run()
Exemple #6
0
    n_int_lowres = 128
    n_gulp_lowres = 16

    #######
    ## PIPELINE DEFN
    #######

    # Read file into ring buffer
    b_read = MbBinaryFileReadBlock(filenames,
                                   n_beams,
                                   fine_time_len,
                                   n_pol,
                                   gulp_nframe=1,
                                   buffer_nframe=4,
                                   core=0)
    blocks.print_header(b_read)

    # Reshape array for midres FFT
    with bf.block_scope(fuse=True, core=1):
        b_midres = views.split_axis(b_read,
                                    axis='fine_time',
                                    n=n_fft_midres,
                                    label='fft_window')
        b_midres = blocks.transpose(
            b_midres, axes=['time', 'fine_time', 'beam', 'fft_window', 'pol'])
        b_midres = views.merge_axes(b_midres, 'time', 'fine_time')
        b_midres = blocks.copy(b_midres,
                               space='system',
                               gulp_nframe=n_gulp_midres)
        #blocks.print_header(b_midres)
    b_gup2 = views.rename_axis(b_guppi, 'freq', 'channel')

    # Buffer up two blocks & reshape to allow longer FFT
    with bf.block_scope(fuse=True, core=2):
        b_gup2 = views.split_axis(b_gup2,
                                  axis='time',
                                  n=n_chunks,
                                  label='time_chunk')
        b_gup2 = blocks.transpose(
            b_gup2, axes=['time', 'channel', 'time_chunk', 'fine_time', 'pol'])
        b_gup2 = views.reverse_scale(b_gup2, 'time_chunk')
        b_gup2 = views.merge_axes(b_gup2,
                                  'time_chunk',
                                  'fine_time',
                                  label='fine_time')
        blocks.print_header(b_gup2)

        #blocks.print_header(b_gup2)

    # blocks.print_header(b_gup2)

    # Copy over to GPU and FFT
    with bf.block_scope(fuse=True, core=3):
        b_copy = blocks.copy(b_gup2, space='cuda')
        b_fft = blocks.fft(b_copy, axes='fine_time', axis_labels='freq')
        b_ffs = blocks.fftshift(b_fft, axes='freq')
        #blocks.print_header(b_fft)
        b_pow = blocks.detect(b_ffs, mode='stokes')
        b_copp = blocks.copy(b_pow, space='system')

    #blocks.print_header(b_copp)
Exemple #8
0
import glob
import time

if __name__ == "__main__":
    filenames = sorted(glob.glob('../data/*.bin'))
    Nsamp = 1024 * 1024
    b_read = BinaryFileReadBlock(filenames, 1024, 1024, 'f32')
    b_read_rs = split_axis(b_read, axis=1, n=1024, label='time')
    b_copy = CopyBlock(b_read_rs, space='cuda', core=0, gpu=0)
    with bfp.block_scope(core=1, gpu=0, fuse=True):
        b_fft = FftBlock(b_copy, axes=1, core=1, gpu=0)
        b_fft = detect(b_fft, 'scalar')
    b_acc = reduce(b_fft, axis=2, op='mean')
    b_out = CopyBlock(b_acc, space='system', core=2)
    b_write = BinaryFileWriteBlock(b_out, core=3)
    print_header(b_read)
    #print_header(b_read_rs)
    print_header(b_copy)
    print_header(b_fft)
    print_header(b_acc)
    print_header(b_out)
    #print_header(b_write)
    #t0 = time.time()
    pipeline = bfp.get_default_pipeline()
    print(pipeline.dot_graph())
    t0 = time.time()
    pipeline.run()
    t1 = time.time()
    print "Time: ", t1 - t0