Source
xxxxxxxxxx
''' Test calibration table produced when gencal is run on an MS with a SYSCAL table that contains NaNs'''
#########################################################################
# test_task_gencal.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.calibration.gencal.html
#
##########################################################################
import contextlib
import csv
import os
import shutil
import tempfile
import unittest
from unittest.mock import patch
import uuid
import numpy as np
from casatestutils import testhelper as th
from casatasks import gencal, rmtables
from casatasks.private import tec_maps
from casatools import ctsys, table
_tb = table()
datapath = ctsys.resolve('/unittest/gencal/')
# input data
evndata = 'n08c1.ms'
vlbadata = 'ba123a.ms'
swpowdata = '3C286_syspower_CAS-11860.ms'
vlbacal = os.path.join(datapath, 'ba123a.gc')
evncal = os.path.join(datapath, 'n08c1.tsys')
caltab = 'cal.A'
evncopy = 'evn_copy.ms'
vlbacopy = 'vlba_copy.ms'
swpowcopy = 'swpow_copy.ms'
'''
Unit tests for gencal
'''
#
# ToDo:
# add more tests
# once more independent tests (e.g. comparison
# the AIPS REWAY results) add reference mses
# and do tests against them
#
# Pick up alternative data directory to run tests on MMSs
testmms = False
if 'TEST_DATADIR' in os.environ:
DATADIR = str(os.environ.get('TEST_DATADIR'))+'/gencal/'
if os.path.isdir(DATADIR):
testmms = True
datapath = DATADIR
else:
print('WARN: directory '+DATADIR+' does not exist')
print('gencal tests will use data from ' + datapath)
class gencal_antpostest(unittest.TestCase):
# Input and output names
msfile = 'tdem0003gencal.ms'
# used for test_antpos_auto_evla_CAS13057
msfile2 = 'auto_antposcorr_evla_gencal.ms'
# if testmms:
# msfile = 'tdem0003gencal.mms'
caltable = 'anpos.cal'
reffile1 = os.path.join(datapath+'evla_reference/', 'anpos.manual.cal')
reffile2 = os.path.join(datapath+'evla_reference/', 'anpos.auto.cal')
reffile3 = os.path.join(datapath+'evla_reference/', 'anpos.autoCAS13057.cal')
res = False