Source
'''Concat 14: 2 parts of same MS split in time, use of ephemerides, first ephemeris covers both MS time ranges, not chronologically ordered'''
#############################################################################
# $Id:$
# Test Name: #
# Unit Test Script for the concat task
#
# #
#############################################################################
from __future__ import absolute_import
from __future__ import print_function
import os
import sys
import shutil
import glob
import unittest
from math import sqrt
from casatasks.private.casa_transition import is_CASA6
if is_CASA6:
from casatools import ctsys, calibrater
from casatools import table as tbtool
from casatools import ms as mstool
from casatasks import split, concat
cb = calibrater( )
tb = tbtool( )
ms = mstool( )
datapath = ctsys.resolve('unittest/concat/')
else:
from __main__ import default
from tasks import *
from taskinit import *
cb = cbtool( )
dataroot = os.environ.get('CASAPATH').split()[0]
datapath = os.path.join(dataroot,'casatestdata/unittest/concat/')
ephempath = os.path.join(dataroot, 'data/')
myname = 'test_concat'
# name of the resulting MS
msname = 'concatenated.ms'
testmms=False
def checktable(thename, theexpectation, multims=False):
global msname, myname
if multims:
tb.open(msname+"/SUBMSS/"+thename)
else:
tb.open(msname+"/"+thename)
if thename == "":
thename = "MAIN"
for mycell in theexpectation:
print(myname, ": comparing ", mycell)
value = tb.getcell(mycell[0], mycell[1])
# see if value is array
try:
isarray = value.__len__
except:
# it's not an array
# zero tolerance?
if mycell[3] == 0:
in_agreement = (value == mycell[2])
else:
in_agreement = ( abs(value - mycell[2]) < mycell[3])
else:
# it's an array
if type(value) == str: # it's actually a string
try:
# zero tolerance?
if mycell[3] == 0:
in_agreement = (value == mycell[2])
else:
in_agreement = (mycell[2] in value ) # i.e. the expectation is contained
except:
in_agreement = False
else:
# zero tolerance?
if mycell[3] == 0:
in_agreement = (value == mycell[2]).all()
else:
try:
in_agreement = (abs(value - mycell[2]) < mycell[3]).all()
except:
in_agreement = False
if not in_agreement:
print(myname, ": Error in MS subtable", thename, ":")
print(" column ", mycell[0], " row ", mycell[1], " contains ", value)