from __future__ import absolute_import
from casatasks.private.casa_transition import is_CASA6
from casatools import ctsys, table
from casatasks import smoothcal
from casatasks import accor,smoothcal
from __main__ import default
from casa_stack_manip import stack_frame_find
casa_stack_rethrow = stack_frame_find().get('__rethrow_casa_exceptions', False)
Unit tests for task smoothcal. It tests the following parameters:
vis: wrong and correct values
tablein: wrong and correct values
caltable: existence of output
field: wrong field value; non-default value
smmothtype: unsupported value; non-default value
smoothtime: unsupported value; non-default values
Other tests: check the values of column smoothed GAIN against reference.
check calibration tables produces by accor are smoothable.
class smoothcal_test(unittest.TestCase):
gcal = 'ngc1333_ut_nct.gcal' # New format caltables
ref = 'ngc1333_ut_nct.ref'
accor = 'smoothcal_accor'
datapath = ctsys.resolve('unittest/smoothcal/')
datapath = os.path.join(os.environ.get('CASAPATH').split()[0],'casatestdata/unittest/smoothcal/')
shutil.copytree(os.path.join(datapath,self.msfile), self.msfile)
shutil.copytree(os.path.join(datapath,self.gcal), self.gcal)
shutil.copytree(os.path.join(datapath,self.ref), self.ref)
shutil.copytree(os.path.join(datapath,self.vlbams), self.vlbams)
if (os.path.exists(self.msfile)):
os.system('rm -rf ' + self.msfile)
if (os.path.exists(self.gcal)):
os.system('rm -rf ' + self.gcal)
if (os.path.exists(self.ref)):
os.system('rm -rf ' + self.ref)
if (os.path.exists(self.vlbams)):
os.system('rm -rf ' + self.vlbams)
if (os.path.exists(self.accor)):
os.system('rm -rf ' + self.accor)
if (os.path.exists(self.out)):
os.system('rm -rf ' + self.out)
def getvarcol(self,table,colname):
'''Return the requested column'''
col = _tb.getvarcol(colname)
EPS = 1e-5; # Logical "zero"
# Loop over every row,pol and get the data
for i in range(1,nrows,1) :
refdata = refcol[row][pol]
self.assertTrue(abs(refdata - smdata) < EPS)
'''Test11: Smooth accor table'''
accor(vis=self.vlbams,caltable=self.accor,corrdepflags=True)
self.res=smoothcal(vis=self.vlbams,tablein=self.accor,caltable=self.out)
self.assertTrue(os.path.exists(self.out))
if __name__ == '__main__':