예제 #1
0
 def test_flag_baseline(self):
     """test flag in calmode=baseline"""
     tb.open(self.infile)
     flagchan_pre = tb.getcol('FLAG')
     flagrow_pre = tb.getcol('FLAG_ROW')
     tb.close()
     sdtpimaging(infile=self.infile,
                 calmode='baseline',
                 masklist=[5, 5],
                 createimage=False)
     # make sure flag is not changed
     tb.open(self.infile)
     flagchan_post = tb.getcol('FLAG')
     flagrow_post = tb.getcol('FLAG_ROW')
     data = tb.getcol('DATA')
     tb.close()
     self.assertTrue(flagchan_pre.shape == flagchan_post.shape,
                     "Data shape has been changed by task operation")
     self.assertTrue((flagrow_post == flagrow_pre).all(),
                     "FLAG_ROW has been changed by task operation")
     self.assertTrue((flagchan_post == flagchan_pre).all(),
                     "FLAG has been changed by task operation")
     # now check baseline result
     ref_bl = [0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 0, 0, 85, 84, 0, 0, 0]
     (npol, nchan, nrow) = data.shape
     self.assertEqual(nchan, 1, 'number of channels is not 1')
     self.assertEqual(nrow, len(ref_bl),
                      'number of rows is not %d' % len(ref_bl))
     for irow in range(nrow):
         for ipol in range(npol):
             if flagchan_post[ipol][0][irow] > 0: continue
             self.assertEqual(
                 data[ipol][0][irow].real, ref_bl[irow],
                 "Spectral value differs in row %d: %f (expected: %f)" %
                 (irow, data[ipol][0][irow].real, ref_bl[irow]))
예제 #2
0
 def test_flag_baseline(self):
     """test flag in calmode=baseline"""
     tb.open(self.infile)
     flagchan_pre = tb.getcol('FLAG')
     flagrow_pre = tb.getcol('FLAG_ROW')
     tb.close()
     sdtpimaging(infile=self.infile,calmode='baseline', masklist=[5,5],
                 createimage=False)
     # make sure flag is not changed
     tb.open(self.infile)
     flagchan_post = tb.getcol('FLAG')
     flagrow_post = tb.getcol('FLAG_ROW')
     data = tb.getcol('DATA')
     tb.close()
     self.assertTrue(flagchan_pre.shape==flagchan_post.shape,
                     "Data shape has been changed by task operation")
     self.assertTrue((flagrow_post==flagrow_pre).all(),
                     "FLAG_ROW has been changed by task operation")
     self.assertTrue((flagchan_post==flagchan_pre).all(),
                     "FLAG has been changed by task operation")
     # now check baseline result
     ref_bl = [0,0,0,0,0,0,0,3,3,3,3,3,3,0,0,85,84,0,0,0]
     (npol, nchan, nrow) = data.shape
     self.assertEqual(nchan, 1, 'number of channels is not 1')
     self.assertEqual(nrow, len(ref_bl), 'number of rows is not %d' % len(ref_bl))
     for irow in range(nrow):
         for ipol in range(npol):
             if flagchan_post[ipol][0][irow] > 0: continue
             self.assertEqual(data[ipol][0][irow].real, ref_bl[irow],
                              "Spectral value differs in row %d: %f (expected: %f)" % (irow, data[ipol][0][irow].real, ref_bl[irow]))
예제 #3
0
 def test_flag_image2(self):
     """test flag in imaging (2 integration -> 1 pixel)"""
     # flag scans 15~17
     self._chanflag_ms_rows(self.infile, [15, 16, 17])
     # input MS = [0,1,2,3,4,5,6,10,11,12,13,14,15,13,14,F,F,F,18,19]
     # an image pixel should be masked out only if all data mapped
     # to the pixel are flagged
     ref_ma = numpy.ma.masked_array(
         [0.5, 2.5, 4.5, 8, 11.5, 13.5, 14, 14, 0, 18.5],
         ([False] * 8 + [True, False]))
     # invoke task
     cell_factor = 2
     npixx = self.nrow / cell_factor
     outfile = self.outimage
     cell = [qa.tos(qa.mul(self.cell, cell_factor)), self.cell]
     imsize = [npixx, 1]
     center = 'J2000 23:59:59.6259 -27.00.00.0'
     sdtpimaging(infile=self.infile,
                 calmode='none',
                 createimage=True,
                 outfile=outfile,
                 cell=cell,
                 imsize=imsize,
                 phasecenter=center,
                 gridfunction='BOX')
     self._test_image(outfile, (npixx, 1, 1, 1), ref_ma)
예제 #4
0
 def test_flag_image1(self):
     """test flag in imaging (1 integration -> 1 pixel)"""
     ref_ma = numpy.ma.masked_array(self.inmsdata, self.inflag)
     # invoke task
     outfile=self.outimage
     cell=[self.cell, self.cell]
     imsize=[self.nrow, 1]
     sdtpimaging(infile=self.infile,calmode='none', createimage=True,
                 outfile=outfile,cell=cell,imsize=imsize,
                 phasecenter=self.center,gridfunction='BOX')
     self._test_image(outfile, (self.nrow,1,1,1), ref_ma)
예제 #5
0
 def test_flag_image1(self):
     """test flag in imaging (1 integration -> 1 pixel)"""
     ref_ma = numpy.ma.masked_array(self.inmsdata, self.inflag)
     # invoke task
     outfile = self.outimage
     cell = [self.cell, self.cell]
     imsize = [self.nrow, 1]
     sdtpimaging(infile=self.infile,
                 calmode='none',
                 createimage=True,
                 outfile=outfile,
                 cell=cell,
                 imsize=imsize,
                 phasecenter=self.center,
                 gridfunction='BOX')
     self._test_image(outfile, (self.nrow, 1, 1, 1), ref_ma)
예제 #6
0
 def test007(self):
     """Test 007: Bad pointing column name"""
     # argument verification error
     self.res = sdtpimaging(infile=self.infile,
                            createimage=True,
                            outfile=self.outimage,
                            pointingcolumn='XXX')
     self.assertFalse(self.res)
예제 #7
0
 def test008(self):
     """Test 008: Unexisting grid function"""
     # argument verification error
     self.res = sdtpimaging(infile=self.infile,
                            createimage=True,
                            outfile=self.outimage,
                            gridfunction='XXX')
     self.assertFalse(self.res)
예제 #8
0
 def test006(self):
     """Test 006: Bad phase center string"""
     try:
         self.res=sdtpimaging(infile=self.infile,spw=2,createimage=True,outfile=self.outimage,phasecenter='XXX')
         self.assertTrue(False,
                         msg='The task must throw exception')
     except Exception, e:
         pos=str(e).find('Could not interprete phasecenter parameter')
         self.assertNotEqual(pos,-1,
                             msg='Unexpected exception was thrown: %s'%(str(e)))
예제 #9
0
 def test002(self):
     """Test 002: Bad stokes string"""
     try:
         self.res=sdtpimaging(infile=self.infile,spw=2,stokes='J')
         self.assertTrue(False,
                         msg='The task must throw exception')
     except Exception, e:
         pos=str(e).find('stokes=J specified but the data contains only [\'XX\']')
         self.assertNotEqual(pos,-1,
                             msg='Unexpected exception was thrown: %s'%(str(e)))
예제 #10
0
 def test003(self):
     """Test 003: Try to create image without output image name"""
     try:
         self.res=sdtpimaging(infile=self.infile,spw=2,createimage=True,outfile='')
         self.assertTrue(False,
                         msg='The task must throw exception')
     except Exception, e:
         pos=str(e).find('Please specify out image name')
         self.assertNotEqual(pos,-1,
                             msg='Unexpected exception was thrown: %s'%(str(e)))
예제 #11
0
 def test001(self):
     """Test 001: Bad antenna id"""
     try:
         self.res=sdtpimaging(infile=self.infile,spw=2,antenna='99')
         self.assertTrue(False,
                         msg='The task must throw exception')
     except Exception, e:
         pos=str(e).find('No matching antenna ID or name in the data, please check antenna parameter')
         self.assertNotEqual(pos,-1,
                             msg='Unexpected exception was thrown: %s'%(str(e)))
예제 #12
0
 def test_flag_image2(self):
     """test flag in imaging (2 integration -> 1 pixel)"""
     # flag scans 15~17
     self._chanflag_ms_rows(self.infile, [15,16,17])
     # input MS = [0,1,2,3,4,5,6,10,11,12,13,14,15,13,14,F,F,F,18,19]
     # an image pixel should be masked out only if all data mapped
     # to the pixel are flagged
     ref_ma = numpy.ma.masked_array([0.5,2.5,4.5,8,11.5,13.5,14,14,0,18.5],
                                    ([False]*8+[True, False]))
     # invoke task
     cell_factor = 2
     npixx = self.nrow/cell_factor
     outfile=self.outimage
     cell=[qa.tos(qa.mul(self.cell,cell_factor)), self.cell]
     imsize=[npixx, 1]
     center = 'J2000 23:59:59.6259 -27.00.00.0'
     sdtpimaging(infile=self.infile,calmode='none', createimage=True,
                 outfile=outfile,cell=cell,imsize=imsize,
                 phasecenter=center,gridfunction='BOX')
     self._test_image(outfile, (npixx,1,1,1), ref_ma)
예제 #13
0
 def test004(self):
     """Test 004: Negative imsize"""
     try:
         self.res=sdtpimaging(infile=self.infile,spw=2,createimage=True,outfile=self.outimage,imsize=[-1])
         self.assertTrue(False,
                         msg='The task must throw exception')
     except Exception, e:
         # failed to create image so that outimage not exist
         pos=str(e).find('%s does not exist'%(self.outimage))
         self.assertNotEqual(pos,-1,
                             msg='Unexpected exception was thrown: %s'%(str(e)))
예제 #14
0
 def test002(self):
     """Test 002: Bad stokes string"""
     try:
         self.res = sdtpimaging(infile=self.infile, spw=2, stokes='J')
         self.assertTrue(False, msg='The task must throw exception')
     except Exception, e:
         pos = str(e).find(
             'stokes=J specified but the data contains only [\'XX\']')
         self.assertNotEqual(pos,
                             -1,
                             msg='Unexpected exception was thrown: %s' %
                             (str(e)))
예제 #15
0
 def test001(self):
     """Test 001: Bad antenna id"""
     try:
         self.res = sdtpimaging(infile=self.infile, spw=2, antenna='99')
         self.assertTrue(False, msg='The task must throw exception')
     except Exception, e:
         pos = str(e).find(
             'No matching antenna ID or name in the data, please check antenna parameter'
         )
         self.assertNotEqual(pos,
                             -1,
                             msg='Unexpected exception was thrown: %s' %
                             (str(e)))
예제 #16
0
 def test003(self):
     """Test 003: Try to create image without output image name"""
     try:
         self.res = sdtpimaging(infile=self.infile,
                                spw=2,
                                createimage=True,
                                outfile='')
         self.assertTrue(False, msg='The task must throw exception')
     except Exception, e:
         pos = str(e).find('Please specify out image name')
         self.assertNotEqual(pos,
                             -1,
                             msg='Unexpected exception was thrown: %s' %
                             (str(e)))
예제 #17
0
 def test100(self):
     """Test 100: test to image data without spatial baseline subtraction"""
     self.res = sdtpimaging(infile=self.infile,
                            calmode='none',
                            stokes='XX',
                            spw=2,
                            createimage=True,
                            outfile=self.outimage,
                            imsize=[64],
                            cell=['15arcsec'],
                            phasecenter='J2000 05h35m07s -5d21m00s',
                            pointingcolumn='direction',
                            gridfunction='SF')
     self.assertEqual(self.res, None)
     self._compare(self.refimage, self.outimage)
예제 #18
0
 def test006(self):
     """Test 006: Bad phase center string"""
     try:
         self.res = sdtpimaging(infile=self.infile,
                                spw=2,
                                createimage=True,
                                outfile=self.outimage,
                                phasecenter='XXX')
         self.assertTrue(False, msg='The task must throw exception')
     except Exception, e:
         pos = str(e).find('Could not interprete phasecenter parameter')
         self.assertNotEqual(pos,
                             -1,
                             msg='Unexpected exception was thrown: %s' %
                             (str(e)))
예제 #19
0
 def test004(self):
     """Test 004: Negative imsize"""
     try:
         self.res = sdtpimaging(infile=self.infile,
                                spw=2,
                                createimage=True,
                                outfile=self.outimage,
                                imsize=[-1])
         self.assertTrue(False, msg='The task must throw exception')
     except Exception, e:
         # failed to create image so that outimage not exist
         pos = str(e).find('%s does not exist' % (self.outimage))
         self.assertNotEqual(pos,
                             -1,
                             msg='Unexpected exception was thrown: %s' %
                             (str(e)))
예제 #20
0
 def test007(self):
     """Test 007: Bad pointing column name"""
     # argument verification error
     self.res=sdtpimaging(infile=self.infile,createimage=True,outfile=self.outimage,pointingcolumn='XXX')
     self.assertFalse(self.res)
예제 #21
0
 def test009(self):
     """Test 009: Invalid calmode"""
     # argument verification error
     self.res = sdtpimaging(infile=self.infile, calmode='ps')
     self.assertFalse(self.res)
예제 #22
0
 def test008(self):
     """Test 008: Unexisting grid function"""
     # argument verification error
     self.res=sdtpimaging(infile=self.infile,createimage=True,outfile=self.outimage,gridfunction='XXX')
     self.assertFalse(self.res)
예제 #23
0
 def test009(self):
     """Test 009: Invalid calmode"""
     # argument verification error
     self.res=sdtpimaging(infile=self.infile,calmode='ps')
     self.assertFalse(self.res)
예제 #24
0
 def test000(self):
     """Test 000: Default parameters"""
     # argument verification error
     self.res=sdtpimaging()
     self.assertFalse(self.res)
예제 #25
0
 def test000(self):
     """Test 000: Default parameters"""
     # argument verification error
     self.res = sdtpimaging()
     self.assertFalse(self.res)
예제 #26
0
 def test200(self):
     """Test 200: test to image data with spatial baseline subtraction"""
     self.res=sdtpimaging(infile=self.infile,calmode='baseline',masklist=[10,10],blpoly=1,stokes='XX',spw=2,createimage=True,outfile=self.outimage,imsize=[64],cell=['15arcsec'],phasecenter='J2000 05h35m07s -5d21m00s',pointingcolumn='direction',gridfunction='SF')
     self.assertEqual(self.res,None)
     self._compare(self.refimage,self.outimage)