示例#1
0
    def test6(self):
        '''cvel2 6: I/O vis set, more complex input vis, one field selected, one spw selected, passall = True'''
        if testmms:
            return
        self.setUp_vis_a()
        myvis = vis_a
        os.system('ln -sf ' + myvis + ' myinput.ms')
        rval = cvel2(vis='myinput.ms',
                     outputvis=outfile,
                     field='1',
                     spw='0',
                     nchan=32,
                     start=10,
                     passall=True)
        self.assertNotEqual(rval, False)

        # Simulate the passall=True. This MS has fields 0~6
        desel = outfile + '.deselected'
        split2(vis='myinput.ms',
               outputvis=desel,
               field='0,2,3,4,5,6',
               spw='0',
               datacolumn='all')
        mslocal = mstool()
        mslocal.open(outfile, nomodify=False)
        mslocal.concatenate(msfile=desel)
        mslocal.close()
        ret = (verify_ms(outfile, 2, 32, 0))
        self.assertTrue(ret[0], ret[1])
示例#2
0
 def test6(self):
     '''cvel2 6: I/O vis set, more complex input vis, one field selected, one spw selected, passall = True'''
     if testmms:
         return
     self.setUp_vis_a()
     myvis = vis_a
     os.system('ln -sf ' + myvis + ' myinput.ms')
     rval = cvel2(
         vis = 'myinput.ms',
         outputvis = outfile,
         field = '1',
         spw = '0',
         nchan = 32,
         start = 10,
         passall = True
         )
     self.assertNotEqual(rval,False)
     
     # Simulate the passall=True. This MS has fields 0~6
     desel = outfile+'.deselected'
     split2(vis='myinput.ms',outputvis=desel,field='0,2,3,4,5,6',spw='0',datacolumn='all')
     mslocal = mstool()
     mslocal.open(outfile, nomodify=False)
     mslocal.concatenate(msfile=desel)            
     mslocal.close()
     ret = (verify_ms(outfile, 2, 32, 0))
     self.assertTrue(ret[0],ret[1])
示例#3
0
 def setUp_vis_g(self):
     if testmms:
         os.system('cp -RL ' + datapath + vis_g + ' .')
     elif(not os.path.exists(vis_g)):
         # construct an MS with attached Jupiter ephemeris from vis_c
         self.setUp_vis_c()
         split2(vis=vis_c, outputvis=vis_g, field='JUPITER', datacolumn='data')
         mytb.open(vis_g, nomodify=False)
         a = mytb.getcol('TIME')
         delta = (54709.*86400-a[0])
         a = a + delta
         strt = a[0]
         mytb.putcol('TIME', a)
         a = mytb.getcol('TIME_CENTROID')
         a = a + delta
         mytb.putcol('TIME_CENTROID', a)
         mytb.close()
         mytb.open(vis_g+'/OBSERVATION', nomodify=False)
         a = mytb.getcol('TIME_RANGE')
         delta = strt - a[0][0]
         a = a + delta
         mytb.putcol('TIME_RANGE', a)
         mytb.close()
         mytb.open(vis_g+'/FIELD', nomodify=False)
         a = mytb.getcol('TIME')
         delta = strt - a[0]
         a = a + delta
         mytb.putcol('TIME', a)
         mytb.close()
         myms.open(vis_g, nomodify=False)
         myms.addephemeris(0,os.environ.get('CASAPATH').split()[0]+'/data/ephemerides/JPL-Horizons/Jupiter_54708-55437dUTC.tab',
                         'Jupiter_54708-55437dUTC', 0)
         myms.close()
示例#4
0
 def setUp_vis_g(self):
     if testmms:
         os.system('cp -RL ' + datapath + vis_g + ' .')
     elif (not os.path.exists(vis_g)):
         # construct an MS with attached Jupiter ephemeris from vis_c
         self.setUp_vis_c()
         split2(vis=vis_c,
                outputvis=vis_g,
                field='JUPITER',
                datacolumn='data')
         mytb.open(vis_g, nomodify=False)
         a = mytb.getcol('TIME')
         delta = (54709. * 86400 - a[0])
         a = a + delta
         strt = a[0]
         mytb.putcol('TIME', a)
         a = mytb.getcol('TIME_CENTROID')
         a = a + delta
         mytb.putcol('TIME_CENTROID', a)
         mytb.close()
         mytb.open(vis_g + '/OBSERVATION', nomodify=False)
         a = mytb.getcol('TIME_RANGE')
         delta = strt - a[0][0]
         a = a + delta
         mytb.putcol('TIME_RANGE', a)
         mytb.close()
         mytb.open(vis_g + '/FIELD', nomodify=False)
         a = mytb.getcol('TIME')
         delta = strt - a[0]
         a = a + delta
         mytb.putcol('TIME', a)
         mytb.close()
         myms.open(vis_g, nomodify=False)
         myms.addephemeris(
             0,
             os.environ.get('CASAPATH').split()[0] +
             '/data/ephemerides/JPL-Horizons/Jupiter_54708-55437dUTC.tab',
             'Jupiter_54708-55437dUTC', 0)
         myms.close()
示例#5
0
    def test4(self):
        '''hanningsmooth2 - Test 4: Theoretical and calculated values should be the same for MMS-case'''
	
        # Split the input to decrease the running time
        split2(self.msfile, outputvis='splithan.ms',scan='1,2',datacolumn='data')
        self.msfile = 'splithan.ms'
        
        # create a test MMS. It creates self.testmms
        self.createMMS(self.msfile)
        self.outputms = 'hann4.mms'
        
      # check correct flagging (just for one row as a sample)
        mslocal = mstool()
        mslocal.open(self.msfile)
        mslocal.sort('sorted.ms',['OBSERVATION_ID','ARRAY_ID','SCAN_NUMBER','FIELD_ID','DATA_DESC_ID','ANTENNA1','ANTENNA2','TIME'])
        mslocal.close()
        self.msfile = 'sorted.ms'
        flag_col = th.getVarCol(self.msfile, 'FLAG')
        self.assertTrue(flag_col['r1'][0][0] == [False])
        self.assertTrue(flag_col['r1'][0][1] == [False])
        self.assertTrue(flag_col['r1'][0][61] == [False])
        self.assertTrue(flag_col['r1'][0][62] == [False])
        
        data_col = th.getVarCol(self.msfile, 'DATA')        
        hanningsmooth2(vis=self.testmms, outputvis=self.outputms, datacolumn='data', keepmms=True)
        self.assertTrue(ParallelDataHelper.isParallelMS(self.outputms), 'Output should be an MMS')

      # Sort the MMS
        mslocal.open(self.outputms)
        mslocal.sort('sorted.mms',['OBSERVATION_ID','ARRAY_ID','SCAN_NUMBER','FIELD_ID','DATA_DESC_ID','ANTENNA1','ANTENNA2','TIME'])
        mslocal.close()
        self.outputms = 'sorted.mms'
        
        corr_col = th.getVarCol(self.outputms, 'DATA')
        nrows = len(corr_col)

      # check correct flagging (just for one row as a sample)
        flag_col = th.getVarCol(self.outputms, 'FLAG')
        self.assertTrue(flag_col['r1'][0][0] == [True])
        self.assertTrue(flag_col['r1'][0][1] == [False])
        self.assertTrue(flag_col['r1'][0][61] == [False])
        self.assertTrue(flag_col['r1'][0][62] == [True])
        
      # Loop over every 2nd row,pol and get the data for each channel
        max = 1e-05
        for i in range(1,nrows,2) :
            row = 'r%s'%i            
            # polarization is 0-1
            for pol in range(0,2) :
                # array's channels is 0-63
                for chan in range(1,62) :
                    # channels must start from second and end before the last
                    data = data_col[row][pol][chan]
                    dataB = data_col[row][pol][chan-1]
                    dataA = data_col[row][pol][chan+1]
        
                    Smoothed = th.calculateHanning(dataB,data,dataA)
                    CorData = corr_col[row][pol][chan]
                    
                    # Check the difference
                    self.assertTrue(abs(CorData-Smoothed) < max )
示例#6
0
    def test4(self):
        '''hanningsmooth2 - Test 4: Theoretical and calculated values should be the same for MMS-case'''

        # Split the input to decrease the running time
        split2(self.msfile,
               outputvis='splithan.ms',
               scan='1,2',
               datacolumn='data')
        self.msfile = 'splithan.ms'

        # create a test MMS. It creates self.testmms
        self.createMMS(self.msfile)
        self.outputms = 'hann4.mms'

        # check correct flagging (just for one row as a sample)
        mslocal = mstool()
        mslocal.open(self.msfile)
        mslocal.sort('sorted.ms', [
            'OBSERVATION_ID', 'ARRAY_ID', 'SCAN_NUMBER', 'FIELD_ID',
            'DATA_DESC_ID', 'ANTENNA1', 'ANTENNA2', 'TIME'
        ])
        mslocal.close()
        self.msfile = 'sorted.ms'
        flag_col = th.getVarCol(self.msfile, 'FLAG')
        self.assertTrue(flag_col['r1'][0][0] == [False])
        self.assertTrue(flag_col['r1'][0][1] == [False])
        self.assertTrue(flag_col['r1'][0][61] == [False])
        self.assertTrue(flag_col['r1'][0][62] == [False])

        data_col = th.getVarCol(self.msfile, 'DATA')
        hanningsmooth2(vis=self.testmms,
                       outputvis=self.outputms,
                       datacolumn='data',
                       keepmms=True)
        self.assertTrue(ParallelDataHelper.isParallelMS(self.outputms),
                        'Output should be an MMS')

        # Sort the MMS
        mslocal.open(self.outputms)
        mslocal.sort('sorted.mms', [
            'OBSERVATION_ID', 'ARRAY_ID', 'SCAN_NUMBER', 'FIELD_ID',
            'DATA_DESC_ID', 'ANTENNA1', 'ANTENNA2', 'TIME'
        ])
        mslocal.close()
        self.outputms = 'sorted.mms'

        corr_col = th.getVarCol(self.outputms, 'DATA')
        nrows = len(corr_col)

        # check correct flagging (just for one row as a sample)
        flag_col = th.getVarCol(self.outputms, 'FLAG')
        self.assertTrue(flag_col['r1'][0][0] == [True])
        self.assertTrue(flag_col['r1'][0][1] == [False])
        self.assertTrue(flag_col['r1'][0][61] == [False])
        self.assertTrue(flag_col['r1'][0][62] == [True])

        # Loop over every 2nd row,pol and get the data for each channel
        max = 1e-05
        for i in range(1, nrows, 2):
            row = 'r%s' % i
            # polarization is 0-1
            for pol in range(0, 2):
                # array's channels is 0-63
                for chan in range(1, 62):
                    # channels must start from second and end before the last
                    data = data_col[row][pol][chan]
                    dataB = data_col[row][pol][chan - 1]
                    dataA = data_col[row][pol][chan + 1]

                    Smoothed = th.calculateHanning(dataB, data, dataA)
                    CorData = corr_col[row][pol][chan]

                    # Check the difference
                    self.assertTrue(abs(CorData - Smoothed) < max)