if __name__ == "__main__": parser = ArgumentParser(description="Command line utility for creating" "spectra from GuppiRaw files.") parser.add_argument('filenames', nargs='+', type=str, help='Names of files to read') parser.add_argument('-f', default=1, dest='f_avg', type=int, help='Number of channels to average together after FFT') parser.add_argument('-N', default=1, dest='n_int', type=int, help='number of integrations per dump') args = parser.parse_args() print("Building pipeline") bc = bf.BlockChainer() bc.blocks.read_guppi_raw(args.filenames, core=0) bc.blocks.copy(space='cuda', core=1) with bf.block_scope(fuse=True, gpu=0): bc.blocks.transpose(['time', 'pol', 'freq', 'fine_time']) bc.blocks.fft(axes='fine_time', axis_labels='fine_freq', apply_fftshift=True) bc.blocks.detect('stokes') bc.views.merge_axes('freq', 'fine_freq') bc.blocks.reduce('freq', args.f_avg) bc.blocks.accumulate(args.n_int) bc.blocks.copy(space='cuda_host', core=2) bc.blocks.write_sigproc(core=3) print("Running pipeline") bf.get_default_pipeline().shutdown_on_signals() bf.get_default_pipeline().run() print("All done")
n_chan_midres = n_fft_midres * n_coarse n_t_midres = n_blocks * (n_t_per_coarse / n_fft_midres) / n_int_midres n_t_lowres = n_blocks * (n_t_per_coarse / n_fft_lowres) / n_int_midres filelist = sorted(glob.glob(os.path.join(filepath, '*.raw'))) # 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):
####### ## 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) # Do midres FFT + Detect on GPU with bf.block_scope(fuse=True, core=3): b_midres = blocks.copy(b_midres, space='cuda')