Source
exp_data2 = [2.49434376e+00+0.j, -1.52505504e-03-0.00459018j, 1.09913200e-03+0.00773078j, -4.95528942e-03-0.00457142j, 7.29188230e-03+0.00369013j]
##########################################################################
# test_mstool.py
#
# Copyright (C) 2016
# 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.
#
# You should have received a copy of the GNU Library General Public License
# along with this library; if not, write to the Free Software Foundation,
# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
#
# Correspondence concerning AIPS++ should be adressed as follows:
# Internet email: aips2-request@nrao.edu.
# Postal address: AIPS++ Project Office
# National Radio Astronomy Observatory
# 520 Edgemont Road
# Charlottesville, VA 22903-2475 USA
#
# Test suite for the CASA ms tool,
# using examples from ms.xml
#
###########################################################################
import shutil
import os
import time
import unittest
from numpy import array, ndarray, testing, where
from math import ceil
from taskinit import mstool, cbtool
datadir = os.environ.get('CASAPATH').split()[0]+'/data/regression/'
datafile = os.path.join(datadir, "unittest/listobs/ngc5921_ut.ms")
print 'ms tool tests will use data from '+ datafile
class mstool_test_base(unittest.TestCase):
testms = "ngc5921.ms"
testms2 = "ngc7538.ms"
testfits = "ngc5921.fits"
def setUpTest(self, nomodify=True):
# Despite setUp/tearDown, some tests with writable MS left
# MS in a changed state and caused later tests to fail.
# So will copy RO testms to a RW one in those tests
self.ms = mstool()
if not os.path.exists(self.testms):
shutil.copytree(datafile, self.testms)
self.ms.open(self.testms, nomodify)
def setUpMs2(self):
ms2 = os.path.join(datadir, 'unittest/clean/ngc7538_ut.ms')
if not os.path.exists(self.testms2):
shutil.copytree(ms2, self.testms2, symlinks=True)
def setUpFits(self):
fitsfile = os.path.join(datadir, 'ngc5921/ngc5921.fits')
if not os.path.exists(self.testfits):
shutil.copyfile(fitsfile, self.testfits)
def tearDownTest(self):
self.ms.done()
self.removeMS(self.testms)
self.ms = None
def checkMS(self, msName):
# MS is a directory
self.assertTrue(os.path.isdir(msName), "MS check failed")
def removeMS(self, msName):
# really any directory, usually an MS in these tests
try:
shutil.rmtree(msName)
except OSError:
pass
def checkFile(self, fileName):
# MS is a directory
self.assertTrue(os.path.isfile(fileName), "File check failed")
def removeFile(self, fileName):