Commits
Neal Schweighart authored and Ville Suoranta committed e7e1b22dc30 Merge
35 35 | from casatasks.private import tec_maps |
36 36 | from casatools import ctsys, table |
37 37 | |
38 38 | _tb = table() |
39 39 | |
40 40 | datapath = ctsys.resolve('/unittest/gencal/') |
41 41 | |
42 42 | # input data |
43 43 | evndata = 'n08c1.ms' |
44 44 | vlbadata = 'ba123a.ms' |
45 + | swpowdata = '3C286_syspower_CAS-11860.ms' |
46 + | |
45 47 | vlbacal = os.path.join(datapath, 'ba123a.gc') |
46 48 | evncal = os.path.join(datapath, 'n08c1.tsys') |
47 49 | |
48 50 | caltab = 'cal.A' |
49 51 | evncopy = 'evn_copy.ms' |
50 52 | vlbacopy = 'vlba_copy.ms' |
53 + | swpowcopy = 'swpow_copy.ms' |
51 54 | |
52 55 | ''' |
53 56 | Unit tests for gencal |
54 57 | ''' |
55 58 | # |
56 59 | # ToDo: |
57 60 | # add more tests |
58 61 | # once more independent tests (e.g. comparison |
59 62 | # the AIPS REWAY results) add reference mses |
60 63 | # and do tests against them |
869 872 | from casatasks.private.task_gencal import gencal as private_gencal |
870 873 | |
871 874 | with self.assertRaises(Exception) as cm: |
872 875 | private_gencal(vis=self.vis, |
873 876 | caltable=self.caltable, |
874 877 | caltype='jyperk', |
875 878 | infile=[self.jyperk_factor_csv], |
876 879 | uniform=False) |
877 880 | |
878 881 | self.assertEqual(cm.exception.args[0], 'The infile argument should be str or None.') |
882 + | |
883 + | class TestSwPow(unittest.TestCase): |
884 + | |
885 + | testcal = 'swpow.cal' |
886 + | def setUp(self): |
887 + | shutil.copytree(os.path.join(datapath,swpowdata), swpowcopy) |
888 + | |
889 + | def tearDown(self): |
890 + | if os.path.exists(swpowcopy): |
891 + | shutil.rmtree(swpowcopy) |
892 + | if os.path.exists(self.testcal): |
893 + | shutil.rmtree(self.testcal) |
894 + | |
895 + | def test_switched_power_weights_caltype(self): |
896 + | """Check that resulting caltable has all 1's for gains and non-trivial values for weight adjustment |
897 + | |
898 + | The following arguments are required for this test. |
899 + | * caltype='swpwts' |
900 + | """ |
901 + | gencal(vis=swpowcopy, caltable=self.testcal, caltype='swpwts') |
902 + | |
903 + | _tb.open(self.testcal) |
904 + | res = _tb.getcol('FPARAM') |
905 + | _tb.close() |
906 + | |
907 + | #self.assertTrue(np.all(res[0:1,:,:] == 1)) |
908 + | self.assertTrue(np.mean(res[1,:,:]) != 1) |
879 909 | |
880 910 | class gencal_eoptest(unittest.TestCase): |
881 911 | |
882 912 | usno_finals_erp = os.path.join(datapath, 'usno_finals.erp') |
883 913 | eopc04_IAU2000 = os.path.join(datapath, 'eopc04_IAU2000.62-now') |
884 914 | |
885 915 | |
886 916 | def setUpClass(cls): |
887 917 | shutil.copytree(os.path.join(datapath, evndata), evncopy) |
888 918 | shutil.copytree(os.path.join(datapath, vlbadata), vlbacopy) |