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"
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")
# Read from guppi raw file b_read = blocks.read_guppi_raw(filelist, core=0, buffer_nframe=2) b_read = views.rename_axis(b_read, 'freq', 'channel') ############# ## HIRES ## ############# # 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')
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()
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) # 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)
n_t = n_blocks / n_int / n_chunks n_chan = n_coarse * n_t_per_coarse * n_chunks filelist = sorted(glob.glob(os.path.join(filepath, '*.raw'))) # Read from guppi raw file b_guppi = blocks.read_guppi_raw(filelist, core=1, buffer_nframe=4) 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')