from __future__ import absolute_import
from __future__ import print_function
import os
import shutil
import numpy
import unittest
from casatasks.private.casa_transition import is_CASA6
if is_CASA6:
from casatools import ctsys, table
from casatasks import initweights
else:
from __main__ import default
from tasks import initweights
from taskinit import tbtool as table
from initweights import initweights
class initweights_common(unittest.TestCase):
"""
A base test class for initweights task
"""
if is_CASA6:
datapath = ctsys.resolve('regression/unittest/initweights')
else:
datapath = os.path.join(os.environ.get('CASAPATH').split()[0],
'data/regression/unittest/initweights')
testmms = False
if 'TEST_DATADIR' in os.environ:
DATADIR = str(os.environ.get('TEST_DATADIR'))+'/initweights/'
if os.path.isdir(DATADIR):
testmms = True
datapath = DATADIR
else:
raise ValueError('Could not find input data in datapath=%s' % DATADIR)
print('initweights tests will use data from %s' % datapath)
inputms = "tsysweight_ave.ms"
tsystable = "tsysweight_ave.tsys.cal"
"""
Note:
tsys spws in 'tsysweight_ave.tsys.cal' are 1,3,5,7
spw maps in tsysweight_ave.ms are 1->1,9, 3->3,11, 5->5,13, 7->7,15
All data and weight/sigma columns are intialized to 1.0
It does NOT have WEIGHT_SPECTRUM and SIGMA_SPECTRUM columns at first.
# Tsys spectra in the first Tsys measurements (the second one has +10 offset)
# spw 1: Tsys[ichan] = 50.
# spw 3: Tsys[ichan] = 45. + 10*ichan/nchan
# spw 5: Tsys[ichan] = 50. + 10*(ichan/nchan)^2
# spw 7: Tsys[ichan] = 60.
"""
templist = [inputms, tsystable]
spwmap = [0, 1, 2, 3, 4, 5, 6, 7, 8, 1, 10, 3, 12, 5, 14, 7]
nchan = -1
verbose = False
def setUp(self):
if not is_CASA6:
default(initweights)
for name in self.templist:
if (os.path.exists(name)):
shutil.rmtree(name)
shutil.copytree(os.path.join(self.datapath,name), name)
def tearDown(self):
for name in self.templist:
if (os.path.exists(name)):
shutil.rmtree(name)
def _run_local_tests(self, *args, **kwargs):
"""Additional tests to run in the class (the default is nothing)"""
pass
def _get_interpolated_wtsp(self, *args, **kwargs):
"""