Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove checks preventing casa gain tables from being written. #448

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion cubical/data_handler/ms_data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def __init__(self, ms_name, data_column, output_column=None, output_model_column
assert set(spwtabcols) <= set(
_spwtab.colnames()), "Measurement set conformance error - keyword table SPECTRAL_WINDOW incomplete. Perhaps disable --out-casa-gaintables or check your MS!"
nrows = _spwtab.nrows()
self._spwtabcols = {t: [_spwtab.getcol(t, row, 1) for row in range(nrows)] for t in spwtabcols}
self._spwtabcols = {t: _spwtab.getcol(t, row, 1) for row in range(nrows) for t in spwtabcols}

# read observation details
obstabcols = ["TIME_RANGE", "LOG", "SCHEDULE", "FLAG_ROW",
Expand Down
Binary file modified cubical/database/blankcaltable.CASA.tgz
Binary file not shown.
31 changes: 8 additions & 23 deletions cubical/database/casa_db_adaptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ def init_empty(cls, db, filename, solfreqs, solants, field_ndir=1, is_complex=Tr
is_complex: Solutions are complex or real-valued
viscal_label: Sets viscal property of CASA table - used as identifier in CASA
"""
if six.PY3:
log.error("Gaintables cannot be written in Python 3 mode due to current casacore implementation issues")
return

if os.path.exists(filename):
if os.path.isfile(filename):
log.error("CASA calibration table destination already exists but is not a directory. Will not remove.")
Expand Down Expand Up @@ -78,7 +76,7 @@ def init_empty(cls, db, filename, solfreqs, solants, field_ndir=1, is_complex=Tr
t.putcol("REFERENCE_DIR", np.tile(db.fieldrefdir[selfield], (field_ndir, 1)))
t.putcol("CODE", np.tile(np.array(db.fieldcode)[selfield], (field_ndir, 1)))
t.putcol("FLAG_ROW", np.tile(db.fieldflagrow[selfield], (field_ndir, 1)))
t.putcol("NAME", np.array(map(str, ["%s_DIR_%d" % (f, fdi) for fdi, f in enumerate([db.fieldname[np.where(selfield)[0][0]]] * field_ndir)])).T)
t.putcol("NAME", np.array(list(map(str, ["%s_DIR_%d" % (f, fdi) for fdi, f in enumerate([db.fieldname[np.where(selfield)[0][0]]] * field_ndir)]))).T)
t.putcol("SOURCE_ID", np.tile(db.fieldsrcid[selfield], (field_ndir, 1)) + np.arange(field_ndir).T)
t.putcol("TIME", np.tile(db.fieldtime[selfield], (field_ndir, 1)))

Expand Down Expand Up @@ -118,7 +116,7 @@ def init_empty(cls, db, filename, solfreqs, solants, field_ndir=1, is_complex=Tr
t.putcell("REF_FREQUENCY", iddid, db.spwreffreq[spwid])
t.putcell("CHAN_WIDTH", iddid, ddsolwidth)
t.putcell("EFFECTIVE_BW", iddid, ddsolwidth) # TODO: this may not be true
t.putcell("RESOLUTION", iddid, db.spwresolution[spwid])
t.putcell("RESOLUTION", iddid, ddsolwidth)
t.putcell("FLAG_ROW", iddid, db.spwflagrow[spwid])
t.putcell("FREQ_GROUP", iddid, db.spwfreqgroup[spwid])
t.putcell("FREQ_GROUP_NAME", iddid, db.spwfreqgroupname[spwid])
Expand Down Expand Up @@ -148,9 +146,7 @@ def create_G_table(cls, db, gname, outname = "Gphase"):
gname: name of pickled_db solutions to export
outname: suffix of exported CASA gaintable
"""
if six.PY3:
log.error("Gaintables cannot be written in Python 3 mode due to current casacore implementation issues")
return

if np.prod(db[gname].shape) == 0:
log.warn("No %s solutions. Will not write CASA table" % gname)
return
Expand Down Expand Up @@ -224,9 +220,7 @@ def create_B_table(cls, db, gname, outname = "B", diag=True):
outname: suffix of exported CASA gaintable
diag: Write out diagonal of Jones matrix if true, off-diagonal (leakage) terms otherwise.
"""
if six.PY3:
log.error("Gaintables cannot be written in Python 3 mode due to current casacore implementation issues")
return

if np.prod(db[gname].shape) == 0:
log.warn("No %s solutions. Will not write CASA table" % gname)
return
Expand Down Expand Up @@ -295,9 +289,7 @@ def create_D_table(cls, db, gname, outname = "D"):
gname: name of pickled_db solutions to export
outname: suffix of exported CASA gaintable
"""
if six.PY3:
log.error("Gaintables cannot be written in Python 3 mode due to current casacore implementation issues")
return

cls.create_B_table(db, gname, outname, diag=False)

@classmethod
Expand All @@ -310,9 +302,7 @@ def create_K_table(cls, db, gname, outname = "K"):
gname: name of pickled_db solutions to export
outname: suffix of exported CASA gaintable
"""
if six.PY3:
log.error("Gaintables cannot be written in Python 3 mode due to current casacore implementation issues")
return

if np.prod(db[gname].shape) == 0:
log.warn("No %s solutions. Will not write CASA table" % gname)
return
Expand Down Expand Up @@ -398,9 +388,6 @@ def set_metadata(self, src):
Args:
src: a cubical.data_handler instance
"""
if six.PY3 and self.export_enabled:
log.error("Gaintables cannot be written in Python 3 mode due to current casacore implementation issues")
self.export_enabled = False

if not isinstance(src, MSDataHandler):
raise TypeError("src must be of type Cubical DataHandler")
Expand Down Expand Up @@ -456,9 +443,7 @@ def set_metadata(self, src):

def __export(self):
""" exports the database to CASA gaintables """
if six.PY3:
log.error("Gaintables cannot be written in Python 3 mode due to current casacore implementation issues")
return

self._load(self.filename)

if not self.meta_avail:
Expand Down