Source
'''Concat 14: 2 parts of same MS split in time, use of ephemerides, first ephemeris covers both MS time ranges, not chronologically ordered'''
#########################################################################
# test_task_concat.py
# Copyright (C) 2018
# Associated Universities, Inc. Washington DC, USA.
#
# This script is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
# License for more details.
#
#
# Based on the requirements listed in casadocs found here:
# https://casadocs.readthedocs.io/en/stable/api/tt/casatasks.manipulation.concat.html
#
##########################################################################
import os
import sys
import shutil
import glob
import unittest
from math import sqrt
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/')
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)
print(" expected value is ", mycell[2])