コード例 #1
0
ファイル: test_fdmt.py プロジェクト: zhuww/bifrost-1
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"
コード例 #2
0
 def test_null_accumulate(self):
     """Check that accumulating no spans leaves header intact"""
     self.shape_settings = [-1, 1, 2]
     with bfp.Pipeline() as pipeline:
         c_data = blocks.sigproc.read_sigproc([self.fil_file], self.gulp_nframe)
         g_data = blocks.copy(c_data, space='cuda')
         call_data = CallbackBlock(
                 g_data, self.check_sequence_before, self.check_data_before)
         accumulated = blocks.accumulate(g_data, 1)
         call_data = CallbackBlock(
                 accumulated, self.check_sequence_after, self.check_data_after)
         pipeline.run()
コード例 #3
0
ファイル: test_fdmt.py プロジェクト: telegraphic/bifrost
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")
コード例 #4
0
ファイル: bf_gpuspec.py プロジェクト: MilesCranmer/bunyip
        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)
    #blocks.print_header(b_acc)
    b_hdf = byip.hdf_writer(b_acc,
                            shape=[n_t, n_chan, n_pol],
                            dtype='float32',
コード例 #5
0
               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()
コード例 #6
0
                                   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)

    # Do midres FFT + Detect on GPU
    with bf.block_scope(fuse=True, core=3):
        b_midres = blocks.copy(b_midres, space='cuda')
        b_midres = blocks.FftBlock(b_midres,
                                   axes='fft_window',
                                   axis_labels='freq')
        b_midres = blocks.fftshift(b_midres, axes='freq')
        b_midres = blocks.detect(b_midres, mode='stokes')
        b_midres = blocks.accumulate(b_midres, n_int_midres)
        b_midres = blocks.copy(b_midres, space='system')

    # Reshape array for lowres FFT
コード例 #7
0
        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)
    # Flatten channel/freq axis to form output spectra and accumulate
    b_copp = blocks.copy(b_copp, space='system', buffer_nframe=4)
    b_flat = views.merge_axes(b_copp, 'channel', 'freq', label='freq')
    b_acc = byip.accumulate(b_flat, n_int, core=4, buffer_nframe=4)
    #blocks.print_header(b_acc)
    b_hdf = byip.hdf_writer(b_acc,
                            shape=[n_t, n_chan, n_pol],
                            dtype='float32',