Commits

Neal Schweighart authored 011b0a714ee
cleaned up cout statments in fringefitsmooth and added test case for new behavior
No tags

casatasks/tests/tasks/test_task_smoothcal.py

Modified
21 21 #
22 22 #
23 23 ##########################################################################
24 24 import os
25 25 import sys
26 26 import shutil
27 27 import unittest
28 28
29 29 from casatools import ctsys, table
30 30 from casatasks import accor,smoothcal
31 +import numpy as np
31 32
32 33 _tb = table()
33 34
34 35
35 36 '''
36 37 Unit tests for task smoothcal. It tests the following parameters:
37 38 vis: wrong and correct values
38 39 tablein: wrong and correct values
39 40 caltable: existence of output
40 41 field: wrong field value; non-default value
43 44
44 45 Other tests: check the values of column smoothed GAIN against reference.
45 46 check calibration tables produces by accor are smoothable.
46 47 '''
47 48 class smoothcal_test(unittest.TestCase):
48 49
49 50 # Input and output names
50 51 msfile = 'ngc1333_ut.ms'
51 52 gcal = 'ngc1333_ut_nct.gcal' # New format caltables
52 53 ref = 'ngc1333_ut_nct.ref'
54 + fringecal = 'ngc1333_ut_fringefit.cal'
53 55 res = None
54 56 vlbams = 'ba123a.ms'
55 57 accor = 'smoothcal_accor'
56 58 out = 'smoothcal_test'
57 59
58 60 def setUp(self):
59 61 self.res = None
60 62 datapath = ctsys.resolve('unittest/smoothcal/')
61 63
62 64
63 65 shutil.copytree(os.path.join(datapath,self.msfile), self.msfile)
64 66 shutil.copytree(os.path.join(datapath,self.gcal), self.gcal)
65 67 shutil.copytree(os.path.join(datapath,self.ref), self.ref)
66 68 shutil.copytree(os.path.join(datapath,self.vlbams), self.vlbams)
69 + shutil.copytree(os.path.join(datapath,self.fringecal), self.fringecal)
67 70
68 71 def tearDown(self):
69 72 if (os.path.exists(self.msfile)):
70 73 os.system('rm -rf ' + self.msfile)
71 74 if (os.path.exists(self.gcal)):
72 75 os.system('rm -rf ' + self.gcal)
73 76 if (os.path.exists(self.ref)):
74 77 os.system('rm -rf ' + self.ref)
75 78 if (os.path.exists(self.vlbams)):
76 79 os.system('rm -rf ' + self.vlbams)
77 80 if (os.path.exists(self.accor)):
78 81 os.system('rm -rf ' + self.accor)
82 + if (os.path.exists(self.fringecal)):
83 + os.system('rm -rf ' + self.fringecal)
79 84 if (os.path.exists(self.out)):
80 85 os.system('rm -rf ' + self.out)
81 86
82 87 def getvarcol(self,table,colname):
83 88 '''Return the requested column'''
84 89 _tb.open(table)
85 90 col = _tb.getvarcol(colname)
86 91 _tb.close()
87 92 return col
88 93
193 198 for pol in range(0,2) :
194 199 refdata = refcol[row][pol]
195 200 smdata = smcol[row][pol]
196 201 self.assertTrue(abs(refdata - smdata) < EPS)
197 202
198 203 def test11(self):
199 204 '''Test11: Smooth accor table'''
200 205 accor(vis=self.vlbams,caltable=self.accor,corrdepflags=True)
201 206 self.res=smoothcal(vis=self.vlbams,tablein=self.accor,caltable=self.out)
202 207 self.assertTrue(os.path.exists(self.out))
208 +
209 + def test_smooth_fringefit(self):
210 + '''Test smooth fringefit: smooth all values in fringefit cal table with phase unwrapping '''
211 + self.res = smoothcal(vis=self.msfile, tablein=self.fringecal, caltable=self.out, smoothtime=10000000000000)
212 +
213 + _tb.open(self.out)
214 + pol1Mean = np.mean(_tb.getcol('FPARAM')[0,0,:])
215 + pol2Mean = np.mean(_tb.getcol('FPARAM')[4,0,:])
216 + _tb.close()
217 +
218 + self.assertTrue(np.isclose(pol1Mean, -0.02804, atol=1e-5))
219 + self.assertTrue(np.isclose(pol2Mean, 0.08426, atol=1e-5))
203 220
204 221 if __name__ == '__main__':
205 222 unittest.main()

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut