Source
xxxxxxxxxx
elif ["CALIBRATE_SIDEBAND_RATIO#OFF_SOURCE", "CALIBRATE_SIDEBAND_RATIO#ON_SOURCE"].count(i) > 0:
##########################################################################
# test_tool_msmetadata.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/latest/api/tt/casatools.msmetadata.html
#
##########################################################################
import shutil
import unittest
import numpy
import os
from casatools import msmetadata, table, ctsys, ms, measures, quanta, ms
_md = msmetadata()
_tb = table()
_me = measures()
_qa = quanta()
_ms = ms()
datadir = ctsys.resolve('unittest/msmetadata/')
fixture = os.path.join(datadir,'MSMetaData.ms')
writeable = os.path.join(datadir,'checker.ms')
tdm2fdm = os.path.join(datadir, 'uid___A002_Xd7be9d_X4838-spw16-18-20-22.ms')
def near(a, b, epsilon):
return abs((a-b)/max(a,b)) <= epsilon
class msmetadata_test(unittest.TestCase):
def setUp(self):
self.md = _md
self.md.open(fixture)
def tearDown(self):
self.md.done()
# self.assertTrue(len(_tb.showcache()) == 0)
def test_antennanames_and_antennaids(self):
"""Test antennanames() and antennaids()"""
names = [
"DA43", "DA44", "DV02", "DV03", "DV05",
"DV07", "DV08", "DV10", "DV12", "DV13",
"DV14", "DV15", "DV16", "DV17", "DV18"
]
# test default works
got = self.md.antennanames()
self.assertEqual(got, names, "Default value of antennanames() doesn't match")
for i in range(self.md.nantennas()):
got = self.md.antennanames(i)
self.assertTrue(got == [names[i]])
got = self.md.antennaids(names[i])
self.assertTrue(got == [i])
expec = ["DV07", "DV02"]
got = self.md.antennanames([5, 2])
self.assertTrue(got == expec)
expec = [4, 0, 7]
got = self.md.antennaids([names[4], names[0], names[7]])
self.assertTrue((got == expec).all())
got = self.md.antennaids()
expec = range(self.md.nantennas())
self.assertTrue((got == expec).all())
got = self.md.antennaids(["DV12", "DA*", "DV1*"])
expec = [ 8, 0, 1, 7, 9, 10, 11, 12, 13, 14]
self.assertTrue((got == expec).all())
got = self.md.antennaids(["DV12", "DA*", "DV1*"], "1m", _qa.quantity(15,"m"))
expec = [ 8, 0, 1, 7, 9, 10, 11, 12, 13, 14]
self.assertTrue((got == expec).all())
got = self.md.antennaids(["DV12", "DA*", "DV1*"], "1m", _qa.quantity(2,"m"))
self.assertTrue(len(got) == 0)
got = self.md.antennaids([], mindiameter="25m")
self.assertTrue(len(got) == 0)
def test_chanavgspws(self):
"""Test chanavgspws()"""
got = self.md.chanavgspws()