import glob
from datetime import datetime
import time
from copy import deepcopy
import bifrost
import bifrost.pipeline as bfp
import bifrost.blocks as blocks
import bifrost.views as views
import bifrost.guppi_raw as guppi_raw
import bifrost.sigproc as sigproc
from bifrost.DataType import DataType
with bfp.Pipeline() as pipeline:
n_int = 128
n_chunks = 1 # I want this to be 2, but I run out of GPU memory
filelist = sorted(glob.glob('*.raw'))[:2]
# 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
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'], buffer_nframe=1)
b_gup2 = views.merge_axes(b_gup2, 'time_chunk', 'fine_time', label='fine_time')
# Copy over to GPU and FFT
b_copy = blocks.copy(b_gup2, space='cuda', buffer_nframe=1, core=1)
b_fft = blocks.fft(b_copy, axes='fine_time', axis_labels='freq', buffer_nframe=1, core=2)
b_ffs = blocks.fftshift(b_fft, axes='freq', buffer_nframe=1, core=2)
b_pow = blocks.detect(b_ffs, mode='stokes', buffer_nframe=1, core=2)
b_acc = blocks.accumulate(b_pow, nframe=n_int, buffer_nframe=1, core=2)
# Copy back to host and flatten channel/freq axis to form output spectra
b_copp = blocks.copy(b_acc, space='system', buffer_nframe=1, core=3)
blocks.print_header(b_copp)
b_flat = views.merge_axes(b_copp, 'channel', 'freq', label='freq')
#b_writer = write_to_disk_here()
pipeline.run()
Which when run crashes:
dancpr@bldcpr:/bldata/pulsar_dev$ python bf_gpuspec_hires.py
Exception in thread Pipeline_0/CopyBlock_0:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "build/bdist.linux-x86_64/egg/bifrost/pipeline.py", line 293, in run
self.main(active_orings)
File "build/bdist.linux-x86_64/egg/bifrost/pipeline.py", line 426, in main
self.sequence_proclogs[i].update(iseq.header)
File "build/bdist.linux-x86_64/egg/bifrost/ring2.py", line 288, in header
hdr = self.header_transform(deepcopy(hdr))
File "build/bdist.linux-x86_64/egg/bifrost/views/basic_views.py", line 137, in header_transform
axis2 = tensor['labels'].index(axis2)
ValueError: 'freq' is not in list
Catching the ValueError and adding in a print() call in basic_views.py, I see:
I have the following code for a gpuspec pipeline:
Which when run crashes:
Catching the ValueError and adding in a print() call in
basic_views.py
, I see:Which seems to suggest that the merge_views is acting on the wrong block. Is this a bug or do I have a stupid typo?