Source
os.symlink(os.environ.get('CASAPATH').split()[0] + casaguidedata_path + "working_data/sis14_twhya_calibrated_flagged.ms",os.getcwd()+'/sis14_twhya_calibrated_flagged.ms')
import os
import shutil
import casac
from tasks import *
from taskinit import *
from __main__ import *
import subprocess
import time
import string
import importlib
import inspect
import shutil
import logging
import hashlib
import threading
import imp
from contextlib import contextmanager
from contextlib import closing
from functools import wraps
import unittest
from numpy import count_nonzero
import tarfile
def compVarColTables(referencetab, testtab, varcol, tolerance=0.):
'''Compare a variable column of two tables.
referencetab --> a reference table
testtab --> a table to verify
varcol --> the name of a variable column (str)
Returns True or False.
'''
retval = True
tb2 = casac.table()
tb.open(referencetab)
cnames = tb.colnames()
tb2.open(testtab)
col = varcol
if tb.isvarcol(col) and tb2.isvarcol(col):
try:
# First check
if tb.nrows() != tb2.nrows():
print 'Length of '+ str(referencetab) +' differ from '+ str(testtab)+','+ str(tb.nrows())+ '!=' + str(tb2.nrows())
retval = False
else:
for therow in xrange(tb.nrows()):
rdata = tb.getcell(col,therow)
tdata = tb2.getcell(col,therow)
if not rdata.all()==tdata.all():
if (tolerance>0.):
differs=False
for j in range(0,len(rdata)):
if ((isinstance(rdata[j],float)) or (isinstance(rdata[j],int))):
if (abs(rdata[j]-tdata[j]) > tolerance*abs(rdata[j]+tdata[j])):
differs = True
elif (isinstance(rdata[j],list)) or (isinstance(rdata[j],np.ndarray)):
for k in range(0,len(rdata[j])):
if (abs(rdata[j][k]-tdata[j][k]) > tolerance*abs(rdata[j][k]+tdata[j][k])):
differs = True
if differs:
print 'ERROR: Column ' + str(col) + ' of ' + str(referencetab) + ' and ' + str(testtab)+ ' do not agree within tolerance '+ str(tolerance)
break
else:
print 'ERROR: Column ' +str(col)+ ' of ' +str(referencetab)+ ' and ' +str(testtab) + ' do not agree.'
print 'ERROR: First row to differ is row=' + str(therow)
retval = False
break
finally:
tb.close()
tb2.close()
else:
print 'Column: ' +str(col) + 'are not varcolumns.'
retval = False
if retval:
print 'Column ' + str(col) + ' of ' + str(referencetab) + ' and ' + str(testtab) + ' agree'
return retval
def assert_file(file):
return os.access(file, os.F_OK)
def openTable(tableName):
try:
import casac
from casac import casac