Пример #1
0
    def test_antennaselwithscan(self):
        '''Fluxscale test 1.6: antenna selection with scan selection test'''
        # Input
        gtable = self.gtable

        # Output
        outtable = self.msfile + '.antsel.fcal'

        thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1331*',
                  transfer='1445*', antenna='!24', scan='1~5', incremental=True)
        self.assertTrue(os.path.exists(outtable))
Пример #2
0
    def test_gainthreshold(self):
        '''Fluxscale test 1.3: gainthreshold parameter test'''
        # Input
        gtable = self.gtable

        # Output
        outtable = self.msfile + '.thres.fcal'

        thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1331*',
                  transfer='1445*', gainthreshold=0.05,incremental=True)
        self.assertTrue(os.path.exists(outtable))
Пример #3
0
    def test_antennaselwithscan(self):
        '''Fluxscale test 1.6: antenna selection with scan selection test'''
        # Input
        gtable = self.gtable

        # Output
        outtable = self.msfile + '.antsel.fcal'

        thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1331*',
                  transfer='1445*', antenna='!24', scan='1~5', incremental=True)
        self.assertTrue(os.path.exists(outtable))
Пример #4
0
    def test_gainthreshold(self):
        '''Fluxscale test 1.3: gainthreshold parameter test'''
        # Input
        gtable = self.gtable

        # Output
        outtable = self.msfile + '.thres.fcal'

        thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1331*',
                  transfer='1445*', gainthreshold=0.05,incremental=True)
        self.assertTrue(os.path.exists(outtable))
Пример #5
0
    def test_flaggedref2(self):
        '''Fluxscale test3: Ref field 3 in caltable is partially flagged'''

        # Input
        gtable = self.gtable2

        # Output
        outtable = self.prefix + '.flagPartFld3.fcal'

        # torelance for value test
        tol = 1.e-5

        thisdict = fluxscale(vis=self.msfile,
                             caltable=gtable,
                             fluxtable=outtable,
                             reference='1,3,4',
                             transfer='2')
        self.assertTrue(os.path.exists(outtable))

        # File to compare with
        reference = self.reffile2

        # Compare the calibration table with a reference
        self.assertTrue(th.compTables(outtable, reference, ['WEIGHT']))

        # compare some determined values returned in the dict (tested on RHEL6)
        refdict = {
            'freq':
            np.array([1.41825202e+09]),
            '2': {
                'fitRefFreq': 0.0,
                'spidxerr': np.array([0., 0., 0.]),
                'spidx': np.array([0., 0., 0.]),
                '0': {
                    'fluxdErr': np.array([0.0022236, 0., 0., 0.]),
                    'numSol': np.array([54., 0., 0., 0.]),
                    'fluxd': np.array([3.19455455, 0., 0., 0.])
                },
                'fitFluxd': 0.0,
                'fieldName': '0841+708',
                'fitFluxdErr': 0.0
            },
            'spwName':
            np.array(['127*24.4 kHz channels @ 1.42 GHz (BARY)'],
                     dtype='|S40'),
            'spwID':
            np.array([0], dtype=np.int32)
        }

        diff_fluxd = abs(refdict['2']['0']['fluxd'][0] - thisdict['2']['0']
                         ['fluxd'][0]) / refdict['2']['0']['fluxd'][0]

        self.assertTrue(diff_fluxd < tol)
Пример #6
0
    def test_default(self):
        '''Fluxscale test 1.1: Create a flux table using field=0 as reference'''
        
        # Input
        gtable = self.gtable
        
        # Output
        outtable = self.msfile + '.fcal'
        
        thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1331*', 
                  transfer='1445*')
        self.assertTrue(os.path.exists(outtable))
        
        # File to compare with
        reference = self.reffile
        
        # Compare the calibration table with a reference
        self.assertTrue(th.compTables(outtable, reference, ['WEIGHT']))

        # compare some determined values returned in the dict

        #refdict={'1': {'spidxerr': np.array([ 0.,  0.,  0.]), 'spidx': np.array([ 0.,  0.,  0.]), \
        #         'fluxdErr': np.array([0.00055571]), \
        #         'fieldName': '1445+09900002_0', 'numSol': np.array([54]), \
                 #'fluxd': np.array([0.16825763])}, \
                 # flux density seems changed a bit. Updated - 2013.01.29 TT
		 # for linux on current trunk 22670
		 # for OSX 10.6 got the previous value 
        #         'fluxd': np.array([0.16825765])}, \
        #         'freq': np.array([1.41266507e+09]), \
        #         'spwName': np.array(['none'], dtype='|S5'), \
        #         'spwID': np.array([0])} 
      
        # new returned dictionary (2013.09.12 TT)
        refdict={'1': {'fitRefFreq': 0.0, 
                       'spidxerr': np.array([ 0.,  0.,  0.]), 
                       'spidx': np.array([ 0.,  0.,  0.]), 
                       '0': {'fluxdErr': np.array([ 0.00055574,  0.        ,  0.        ,  0.        ]), 
                             'numSol': np.array([ 54.,   0.,   0.,   0.]), 
                             'fluxd': np.array([ 0.16825768,  0.        ,  0.        ,  0.        ])}, 
                       'fitFluxd': 0.0, 
                       'fieldName': '1445+09900002_0', 
                       'fitFluxdErr': 0.0}, 
                       'freq': np.array([  1.41266507e+09]), 
                 'spwName': np.array(['none'],dtype='|S5'), 
                 'spwID': np.array([0], dtype=np.int32)}

        
        diff_fluxd=abs(refdict['1']['0']['fluxd'][0]-thisdict['1']['0']['fluxd'][0])/refdict['1']['0']['fluxd'][0]
        #self.assertTrue(diff_fluxd<1.5e-8)
	# increase the tolerance level
        self.assertTrue(diff_fluxd<1e-5)
Пример #7
0
    def test_default(self):
        '''Fluxscale test 1.1: Create a flux table using field=0 as reference'''
        
        # Input
        gtable = self.gtable
        
        # Output
        outtable = self.msfile + '.fcal'
        
        thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1331*', 
                  transfer='1445*')
        self.assertTrue(os.path.exists(outtable))
        
        # File to compare with
        reference = self.reffile
        
        # Compare the calibration table with a reference
        self.assertTrue(th.compTables(outtable, reference, ['WEIGHT']))

        # compare some determined values returned in the dict

        #refdict={'1': {'spidxerr': np.array([ 0.,  0.,  0.]), 'spidx': np.array([ 0.,  0.,  0.]), \
        #         'fluxdErr': np.array([0.00055571]), \
        #         'fieldName': '1445+09900002_0', 'numSol': np.array([54]), \
                 #'fluxd': np.array([0.16825763])}, \
                 # flux density seems changed a bit. Updated - 2013.01.29 TT
		 # for linux on current trunk 22670
		 # for OSX 10.6 got the previous value 
        #         'fluxd': np.array([0.16825765])}, \
        #         'freq': np.array([1.41266507e+09]), \
        #         'spwName': np.array(['none'], dtype='|S5'), \
        #         'spwID': np.array([0])} 
      
        # new returned dictionary (2013.09.12 TT)
        refdict={'1': {'fitRefFreq': 0.0, 
                       'spidxerr': np.array([ 0.,  0.,  0.]), 
                       'spidx': np.array([ 0.,  0.,  0.]), 
                       '0': {'fluxdErr': np.array([ 0.00055574,  0.        ,  0.        ,  0.        ]), 
                             'numSol': np.array([ 54.,   0.,   0.,   0.]), 
                             'fluxd': np.array([ 0.16825768,  0.        ,  0.        ,  0.        ])}, 
                       'fitFluxd': 0.0, 
                       'fieldName': '1445+09900002_0', 
                       'fitFluxdErr': 0.0}, 
                       'freq': np.array([  1.41266507e+09]), 
                 'spwName': np.array(['none'],dtype='|S5'), 
                 'spwID': np.array([0], dtype=np.int32)}

        
        diff_fluxd=abs(refdict['1']['0']['fluxd'][0]-thisdict['1']['0']['fluxd'][0])/refdict['1']['0']['fluxd'][0]
        #self.assertTrue(diff_fluxd<1.5e-8)
	# increase the tolerance level
        self.assertTrue(diff_fluxd<1e-5)
Пример #8
0
    def test_refintransfer(self):
        '''Fluxscale test 1.7: test CAS-10227 fix: reference field included in transfer fields'''

        #input
        gtable = self.gtable

        # Output
        outtable = self.msfile + '.test1.7.fcal'

        thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1331*',
                  transfer='1445*,1331*', incremental=True)
        self.assertTrue(os.path.exists(outtable))
        self.assertFalse(thisdict.has_key('0'))
Пример #9
0
    def test_antennaselwithtime(self):
        '''Fluxscale test 1.5: empy selection case: antenna with time selection test'''
        # Input
        gtable = self.gtable

        # Output
        outtable = self.msfile + '.antsel.fcal'

        # This time selection deselect all the data for the reference source and would raise an exception.
        try:
          thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1331*',
                  transfer='1445*', antenna='!24', timerange='>1995/04/13/09:38:00', incremental=True)
        except exceptions.RuntimeError, instance:
          print "Expected exception raised:",instance
Пример #10
0
    def test_antennaselwithtime(self):
        '''Fluxscale test 1.5: empy selection case: antenna with time selection test'''
        # Input
        gtable = self.gtable

        # Output
        outtable = self.msfile + '.antsel.fcal'

        # This time selection deselect all the data for the reference source and would raise an exception.
        try:
          thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1331*',
                  transfer='1445*', antenna='!24', timerange='>1995/04/13/09:38:00', incremental=True)
        except exceptions.RuntimeError, instance:
          print "Expected exception raised:",instance
Пример #11
0
    def test_incremental(self): 
        '''Fluxscale test 1.2: Create an incremental flux table using field=0 as reference'''
        # Input
        gtable = self.gtable

        # Output
        outtable = self.msfile + '.inc.fcal'

        thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1331*',
                  transfer='1445*', incremental=True)
        self.assertTrue(os.path.exists(outtable))

        # File to compare with
        reference = self.reffile2

        # Compare the calibration table with a reference
        self.assertTrue(th.compTables(outtable, reference, ['WEIGHT']))
Пример #12
0
    def test_incremental(self): 
        '''Fluxscale test 1.2: Create an incremental flux table using field=0 as reference'''
        # Input
        gtable = self.gtable

        # Output
        outtable = self.msfile + '.inc.fcal'

        thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1331*',
                  transfer='1445*', incremental=True)
        self.assertTrue(os.path.exists(outtable))

        # File to compare with
        reference = self.reffile2

        # Compare the calibration table with a reference
        self.assertTrue(th.compTables(outtable, reference, ['WEIGHT']))
Пример #13
0
    def test_flaggedref2(self):
        '''Fluxscale test3: Ref field 3 in caltable is partially flagged'''

        # Input
        gtable = self.gtable2

        # Output
        outtable = self.prefix + '.flagPartFld3.fcal'

        # torelance for value test
        tol = 1.e-5

        thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1,3,4',
                             transfer='2')
        self.assertTrue(os.path.exists(outtable))

        # File to compare with
        reference = self.reffile2

        # Compare the calibration table with a reference
        self.assertTrue(th.compTables(outtable, reference, ['WEIGHT']))

        # compare some determined values returned in the dict (tested on RHEL6)
        refdict={'freq': np.array([  1.41825202e+09]), 
                 '2': {'fitRefFreq': 0.0, 'spidxerr': np.array([ 0.,  0.,  0.]), 
                       'spidx': np.array([ 0.,  0.,  0.]), 
                       '0': {'fluxdErr': np.array([ 0.0022236,  0.,  0.,  0.]), 
                             'numSol': np.array([ 54.,   0.,   0.,   0.]), 
                             'fluxd': np.array([ 3.19455455,  0.,  0.,  0.])}, 
                             'fitFluxd': 0.0, 'fieldName': '0841+708', 'fitFluxdErr': 0.0}, 
                       'spwName': np.array(['127*24.4 kHz channels @ 1.42 GHz (BARY)'], dtype='|S40'), 
                       'spwID': np.array([0], dtype=np.int32)} 


        diff_fluxd=abs(refdict['2']['0']['fluxd'][0]-thisdict['2']['0']['fluxd'][0])/refdict['2']['0']['fluxd'][0]

        self.assertTrue(diff_fluxd<tol)
Пример #14
0
    def test_spws(self):
        '''Fluxscale 2: Create a fluxscale table for an MS with many spws'''
        # Input
        gtable = self.gtable
        
        # Output
        outtable = self.msfile + '.fcal'
        
        # torelance for value tests
        tol = 1.e-5

        thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='3C273-F0',
                             transfer=['1310+323-F0'],refspwmap=[0,0])
        self.assertTrue(os.path.exists(outtable))
        
        # File to compare with
        reference = self.reffile
        
        # Compare the calibration table with a reference
        self.assertTrue(th.compTables(outtable, reference, ['WEIGHT']))
        
        # compare some determined values returned in the dict

        #refdict={'1': {'spidxerr': np.array([ 0.,  0.,  0.]), 'spidx': np.array([ 0.,  0.,  0.]), \
        #         'fluxdErr': np.array([-1.        ,  0.04080052, -1.        , -1.        , -1.        , -1.        ]), \
        #         'fieldName': '1310+323-F0', 'numSol': np.array([-1,  8, -1, -1, -1, -1], dtype=np.int32), \
        #         'fluxd': np.array([-1.        ,  1.44578847, -1.        , -1.        , -1.        , -1.        ])}, \
        #         'freq': np.array([  1.15138579e+11,   1.15217017e+11,  -1.00000000e+00, -1.00000000e+00,  -1.00000000e+00, \
        #                         -1.00000000e+00]), 'spwName': np.array(['', '', '', '', '', ''], dtype='|S1'), \
        #         'spwID': np.array([0, 1, 2, 3, 4, 5], dtype=np.int32)} 

        # updated for new returned dictionary format (2013.09.12 TT)
        refdict= {'1': {'fitRefFreq': 0.0, 
                        'spidxerr': np.array([ 0.,  0.,  0.]), 
                        'fitFluxd': 0.0, 
                        'spidx': np.array([ 0.,  0.,  0.]), 
                        '1': {'fluxdErr': np.array([ 0.04080052,  0.        ,  0.        ,  0.        ]), 
                              'numSol': np.array([ 8.,  0.,  0.,  0.]), 
                              'fluxd': np.array([ 1.44578847,  0.        ,  0.        ,  0.        ])}, 
                        '0': {'fluxdErr': np.array([-1., -1., -1., -1.]), 
                              'numSol': np.array([-1., -1., -1., -1.]), 
                              'fluxd': np.array([-1., -1., -1., -1.])}, 
                        '3': {'fluxdErr': np.array([-1., -1., -1., -1.]), 
                              'numSol': np.array([-1., -1., -1., -1.]), 
                              'fluxd': np.array([-1., -1., -1., -1.])}, 
                        '2': {'fluxdErr': np.array([-1., -1., -1., -1.]), 
                              'numSol': np.array([-1., -1., -1., -1.]), 
                              'fluxd': np.array([-1., -1., -1., -1.])}, 
                        '5': {'fluxdErr': np.array([-1., -1., -1., -1.]), 
                              'numSol': np.array([-1., -1., -1., -1.]), 
                              'fluxd': np.array([-1., -1., -1., -1.])}, 
                        '4': {'fluxdErr': np.array([-1., -1., -1., -1.]), 
                              'numSol': np.array([-1., -1., -1., -1.]), 
                              'fluxd': np.array([-1., -1., -1., -1.])}, 
                        'fieldName': '1310+323-F0', 
                        'fitFluxdErr': 0.0}, 
                  'freq': np.array([  1.15138579e+11,   1.15217017e+11,  -1.00000000e+00, -1.00000000e+00,  
                                      -1.00000000e+00,  -1.00000000e+00]), 
                  'spwName': np.array(['', '', '', '', '', ''], dtype='|S1'), 
                  'spwID': np.array([0, 1, 2, 3, 4, 5], dtype=np.int32)}

        diff_fluxd=abs(refdict['1']['1']['fluxd'][0]-thisdict['1']['1']['fluxd'][0])/refdict['1']['1']['fluxd'][0]

        self.assertTrue(diff_fluxd<tol)
Пример #15
0
    def test_spws(self):
        '''Fluxscale 2: Create a fluxscale table for an MS with many spws'''
        # Input
        gtable = self.gtable
        
        # Output
        outtable = self.msfile + '.fcal'
        
        # torelance for value tests
        tol = 1.e-5

        thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='3C273-F0',
                             transfer=['1310+323-F0'],refspwmap=[0,0])
        self.assertTrue(os.path.exists(outtable))
        
        # File to compare with
        reference = self.reffile
        
        # Compare the calibration table with a reference
        self.assertTrue(th.compTables(outtable, reference, ['WEIGHT']))
        
        # compare some determined values returned in the dict

        #refdict={'1': {'spidxerr': np.array([ 0.,  0.,  0.]), 'spidx': np.array([ 0.,  0.,  0.]), \
        #         'fluxdErr': np.array([-1.        ,  0.04080052, -1.        , -1.        , -1.        , -1.        ]), \
        #         'fieldName': '1310+323-F0', 'numSol': np.array([-1,  8, -1, -1, -1, -1], dtype=np.int32), \
        #         'fluxd': np.array([-1.        ,  1.44578847, -1.        , -1.        , -1.        , -1.        ])}, \
        #         'freq': np.array([  1.15138579e+11,   1.15217017e+11,  -1.00000000e+00, -1.00000000e+00,  -1.00000000e+00, \
        #                         -1.00000000e+00]), 'spwName': np.array(['', '', '', '', '', ''], dtype='|S1'), \
        #         'spwID': np.array([0, 1, 2, 3, 4, 5], dtype=np.int32)} 

        # updated for new returned dictionary format (2013.09.12 TT)
        refdict= {'1': {'fitRefFreq': 0.0, 
                        'spidxerr': np.array([ 0.,  0.,  0.]), 
                        'fitFluxd': 0.0, 
                        'spidx': np.array([ 0.,  0.,  0.]), 
                        '1': {'fluxdErr': np.array([ 0.04080052,  0.        ,  0.        ,  0.        ]), 
                              'numSol': np.array([ 8.,  0.,  0.,  0.]), 
                              'fluxd': np.array([ 1.44578847,  0.        ,  0.        ,  0.        ])}, 
                        '0': {'fluxdErr': np.array([-1., -1., -1., -1.]), 
                              'numSol': np.array([-1., -1., -1., -1.]), 
                              'fluxd': np.array([-1., -1., -1., -1.])}, 
                        '3': {'fluxdErr': np.array([-1., -1., -1., -1.]), 
                              'numSol': np.array([-1., -1., -1., -1.]), 
                              'fluxd': np.array([-1., -1., -1., -1.])}, 
                        '2': {'fluxdErr': np.array([-1., -1., -1., -1.]), 
                              'numSol': np.array([-1., -1., -1., -1.]), 
                              'fluxd': np.array([-1., -1., -1., -1.])}, 
                        '5': {'fluxdErr': np.array([-1., -1., -1., -1.]), 
                              'numSol': np.array([-1., -1., -1., -1.]), 
                              'fluxd': np.array([-1., -1., -1., -1.])}, 
                        '4': {'fluxdErr': np.array([-1., -1., -1., -1.]), 
                              'numSol': np.array([-1., -1., -1., -1.]), 
                              'fluxd': np.array([-1., -1., -1., -1.])}, 
                        'fieldName': '1310+323-F0', 
                        'fitFluxdErr': 0.0}, 
                  'freq': np.array([  1.15138579e+11,   1.15217017e+11,  -1.00000000e+00, -1.00000000e+00,  
                                      -1.00000000e+00,  -1.00000000e+00]), 
                  'spwName': np.array(['', '', '', '', '', ''], dtype='|S1'), 
                  'spwID': np.array([0, 1, 2, 3, 4, 5], dtype=np.int32)}

        diff_fluxd=abs(refdict['1']['1']['fluxd'][0]-thisdict['1']['1']['fluxd'][0])/refdict['1']['1']['fluxd'][0]

        self.assertTrue(diff_fluxd<tol)