Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 42 additions & 18 deletions LWA/LWA_bifrost.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
from lsl.reader.ldp import TBNFile, TBFFile
from lsl.common.stations import lwasv

#Bifrost include Hari's upgrades
from bifrost.xCorr import xCorr
from bifrost.aCorr import aCorr
from bifrost.VGrid import VGrid


# some py2/3 compatibility
if sys.version_info.major < 3:
range = xrange # noqa
Expand Down Expand Up @@ -740,8 +746,8 @@ def main(self):
ishape = (self.ntime_gulp, nchan, nstand, npol)
ogulp_size = self.ntime_gulp * self.nchan_out * nstand * self.npol_out * 1 # ci4
oshape = (self.ntime_gulp, self.nchan_out, nstand, self.npol_out)
self.iring.resize(igulp_size)
self.oring.resize(ogulp_size) # , obuf_size)
self.iring.resize(igulp_size, buffer_factor=8)
self.oring.resize(ogulp_size, buffer_factor=512) # , obuf_size)

ohdr = ihdr.copy()
ohdr["nchan"] = self.nchan_out
Expand Down Expand Up @@ -970,8 +976,8 @@ def main(self):

oshape = (1, nchan, npol ** 2, self.grid_size, self.grid_size)
ogulp_size = nchan * npol ** 2 * self.grid_size * self.grid_size * 8
self.iring.resize(igulp_size)
self.oring.resize(ogulp_size, buffer_factor=5)
self.iring.resize(igulp_size, buffer_factor=512)
self.oring.resize(ogulp_size, buffer_factor=32)
prev_time = time.time()
with oring.begin_sequence(time_tag=iseq.time_tag, header=ohdr_str) as oseq:
iseq_spans = iseq.read(igulp_size)
Expand Down Expand Up @@ -1126,13 +1132,30 @@ def main(self):
space="cuda",
)

## Auto-Correlation of Antennas
if self.benchmark == True:
timeacorr1 = time.time()

try:
bf_acorr.execute(udata, autocorrs)
except NameError:
bf_acorr = aCorr()
bf_acorr.init(self.locs, polmajor=False)
bf_acorr.execute(udata, autocorrs)

if self.benchmark == True:
timeacorr2 = time.time()
print("Auto-Corr time : %f"%(timeacorr2 - timeacorr1))



# Cross multiply to calculate autocorrs
bifrost.map(
"a(i,j,k,l) += (b(i,j,k,l/2) * b(i,j,k,l%2).conj())",
{"a": autocorrs, "b": udata, "t": self.ntime_gulp},
axis_names=("i", "j", "k", "l"),
shape=(self.ntime_gulp, nchan, nstand, npol ** 2),
)
#bifrost.map(
# "a(i,j,k,l) += (b(i,j,k,l/2) * b(i,j,k,l%2).conj())",
# {"a": autocorrs, "b": udata, "t": self.ntime_gulp},
# axis_names=("i", "j", "k", "l"),
# shape=(self.ntime_gulp, nchan, nstand, npol ** 2),
#)
Comment on lines +1153 to +1158
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#bifrost.map(
# "a(i,j,k,l) += (b(i,j,k,l/2) * b(i,j,k,l%2).conj())",
# {"a": autocorrs, "b": udata, "t": self.ntime_gulp},
# axis_names=("i", "j", "k", "l"),
# shape=(self.ntime_gulp, nchan, nstand, npol ** 2),
#)


bifrost.map(
"a(i,j,p,k,l) += b(0,i,j,p/2,k,l)*b(0,i,j,p%2,k,l).conj()",
Expand Down Expand Up @@ -1432,9 +1455,9 @@ def main(self):
# sys.exit(1)

oshape = (nchan, npol ** 2, self.skymodes, 1)
ogulp_size = nchan * npol**2 * self.skymodes * 8
self.iring.resize(igulp_size)
self.oring.resize(ogulp_size, buffer_factor=5)
ogulp_size = nchan * npol**2 * self.skymodes * 32#8
self.iring.resize(igulp_size, buffer_factor=512)
self.oring.resize(ogulp_size, buffer_factor=32)
prev_time = time.time()
with oring.begin_sequence(time_tag=iseq.time_tag, header=ohdr_str) as oseq:
iseq_spans = iseq.read(igulp_size)
Expand Down Expand Up @@ -2165,10 +2188,10 @@ def main():
print("Output directory does not exist. Defaulting to current directory.")
args.out_dir = "."

if args.removeautocorrs:
raise NotImplementedError(
"Removing autocorrelations is not yet properly implemented."
)
#if args.removeautocorrs:
# raise NotImplementedError(
# "Removing autocorrelations is not yet properly implemented."
# )
Comment on lines +2191 to +2194
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if args.removeautocorrs:
# raise NotImplementedError(
# "Removing autocorrelations is not yet properly implemented."
# )


log = logging.getLogger(__name__)
logFormat = logging.Formatter(
Expand All @@ -2182,8 +2205,9 @@ def main():
log.setLevel(logging.DEBUG)

# Setup the cores and GPUs to use
cores = [0, 2, 3, 4, 5, 6, 7]
#cores = [0, 2, 3, 4, 5, 6, 7]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#cores = [0, 2, 3, 4, 5, 6, 7]

gpus = [0, 0, 0, 0, 0, 0, 0]
cores = [5, 4, 3, 2, 24, 25]

# Setup the signal handling
ops = []
Expand Down