from __main__ import default
Unit tests for task fixvis.
1. Do converted directions in the FIELD table have the right shape?
2. Does the phase center shifting result in the expected shifts?
3. Does the distances parameter work
Note: The equinox_vis regression is a more general test of fixvis.
datapath = os.environ.get('CASAPATH').split()[0] + '/data/regression/0420+417/'
datapath2 = os.environ.get('CASAPATH').split()[0] + '/data/regression/unittest/fixvis/'
inpms2 = 'twocenteredpointsources.ms'
class fixvis_test1(unittest.TestCase):
if not os.path.exists(inpms):
shutil.copytree(datapath + inpms, inpms)
if not os.path.exists(inpms2):
shutil.copytree(datapath2 + inpms2, inpms2)
shutil.rmtree(outms, ignore_errors=True)
shutil.rmtree(outms2, ignore_errors=True)
shutil.rmtree(outms, ignore_errors=True)
shutil.rmtree(outms2, ignore_errors=True)
os.system('rm -rf test[yz]*')
'''Test1: Do converted directions in the FIELD table have the right shape?'''
self.res = fixvis(inpms, outms, refcode=refcode)
tb.open(outms + '/FIELD')
retValue = {'success': True, 'msgs': "", 'error_msgs': '' }
def record_error(errmsg, retValue):
"""Helper function to print and update retValue on an error."""
print "test_fixvis.test1: Error:", errmsg
retValue['success'] = False
retValue['error_msgs'] += errmsg + "\n"
mscomponents = set(["table.dat",
for name in mscomponents:
if not os.access(outms + "/" + name, os.F_OK):
record_error(outms + "/" + name + " does not exist.", retValue)
tb.open(outms + '/FIELD')
npoly = tb.getcell('NUM_POLY', 0)
record_error('FIELD/NUM_POLY[0], ' + str(npoly) + ' != expected '
+ str(exp_npoly), retValue)
exp_shape = '[2, ' + str(npoly + 1) + ']'
for dircol in ('PHASE_DIR', 'DELAY_DIR', 'REFERENCE_DIR'):
ref = tb.getcolkeywords(dircol)['MEASINFO']['Ref']
record_error(dircol + "'s stated frame, " + ref
+ ', != expected ' + refcode, retValue)
dirshape = tb.getcolshapestring(dircol)
if dirshape[0] != exp_shape: