def test005(self): """Test 005: Existing output file""" shutil.copytree(self.datapath+self.rawfile, self.outfile) try: msmoments(infile=self.rawfile,outfile=self.outfile) self.assertTrue(False, msg='The task must throw exception') except Exception, e: self.assertEqual(str(e),'%s exists.'%(self.outfile), msg='Unexpected exception was thrown.')
def test005(self): """Test 005: Existing output file""" shutil.copytree(self.datapath + self.rawfile, self.outfile) try: msmoments(infile=self.rawfile, outfile=self.outfile) self.assertTrue(False, msg='The task must throw exception') except Exception, e: self.assertEqual(str(e), '%s exists.' % (self.outfile), msg='Unexpected exception was thrown.')
def test001(self): """Test 001: Undefined moment""" moments=[-2] try: msmoments(infile=self.rawfile,moments=moments,outfile=self.outfile) self.assertTrue(False, msg='The task must throw exception') except StandardError, e: pos=str(e).find('Illegal moment requested') self.assertNotEqual(pos,-1, msg='Unexpected exception was thrown: %s'%(str(e)))
def test003(self): """Test 003: Illegal field name""" field='SOMEWHARE' #def call(): # msmoments(infile=self.rawfile,field=field,outfile=self.outfile) #self.assertRaises(StandardError, call) try: msmoments(infile=self.rawfile,field=field,outfile=self.outfile) self.assertTrue(False, msg='The task must throw exception') except StandardError, e: pos=str(e).find('Field Expression: No match found') self.assertNotEqual(pos,-1, msg='Unexpected exception was thrown: %s'%(str(e)))
def test002(self): """Test 002: Illegal antenna id""" antenna=-2 #def call(): # msmoments(infile=self.rawfile,antenna=antnna,outfile=self.outfile) #self.assertRaises(StandardError, call) try: msmoments(infile=self.rawfile,antenna=antenna,outfile=self.outfile) self.assertTrue(False, msg='The task must throw exception') except StandardError, e: pos=str(e).find('Antenna Expression: Parse error') self.assertNotEqual(pos,-1, msg='Unexpected exception was thrown: %s'%(str(e)))
def test004(self): """Test 004: Illegal spw id""" id=99 #def call(): # msmoments(infile=self.rawfile,spw=id,outfile=self.outfile) #self.assertRaises(StandardError, call) try: msmoments(infile=self.rawfile,spw=id,outfile=self.outfile) self.assertTrue(False, msg='The task must throw exception') except StandardError, e: pos=str(e).find('No Spw ID(s) matched') self.assertNotEqual(pos,-1, msg='Unexpected exception was thrown: %s'%(str(e)))
def test104(self): """Test 104: Median""" moments=[3] postfix='.median' refval=[2.8934342861175537,2.6451926231384277] res=msmoments(infile=self.rawfile,moments=moments,outfile=self.outfile) # the task doesn't return table anymore self.assertTrue(os.path.exists(self.outfile), msg='Out put table does not exist.') self._compare(self.outfile,refval,'K')
def test103(self): """Test 103: Weighted dispersion of coordinate (velocity dispersion)""" moments=[2] postfix='.weighted_dispersion_coord' refval=[95.011787414550781,95.257194519042969] res=msmoments(infile=self.rawfile,moments=moments,outfile=self.outfile) # the task doesn't return table anymore self.assertTrue(os.path.exists(self.outfile), msg='Out put table does not exist.') self._compare(self.outfile,refval,'km/s')
def test102(self): """Test 102: Weighted coordinate (velocity field)""" moments=[1] postfix='.weighted_coord' refval=[6.8671870231628418,7.6601519584655762] res=msmoments(infile=self.rawfile,moments=moments,outfile=self.outfile) # the task doesn't return table anymore self.assertTrue(os.path.exists(self.outfile), msg='Out put table does not exist.') self._compare(self.outfile,refval,'km/s')
def test101(self): """Test 101: Integrated intensity""" moments=[0] postfix='.integrated' refval=[954.87066650390625,873.48583984375] res=msmoments(infile=self.rawfile,moments=moments,outfile=self.outfile) # the task doesn't return table anymore self.assertTrue(os.path.exists(self.outfile), msg='Out put table does not exist.') self._compare(self.outfile,refval,'K.km/s')
def test106(self): """Test 106: Standard deviation about the mean""" moments=[5] postfix='.standard_deviation' refval=[0.13466399908065796,0.13539622724056244] res=msmoments(infile=self.rawfile,moments=moments,outfile=self.outfile) # the task doesn't return table anymore self.assertTrue(os.path.exists(self.outfile), msg='Out put table does not exist.') self._compare(self.outfile,refval,'K')
def test111(self): """Test 111: Minimum value""" moments=[10] postfix='.minimum' refval=[1.7176277637481689, 1.4913345575332642] res=msmoments(infile=self.rawfile,moments=moments,outfile=self.outfile) # the task doesn't return table anymore self.assertTrue(os.path.exists(self.outfile), msg='Out put table does not exist.') self._compare(self.outfile,refval,'K')
def test107(self): """Test 107: Rms""" moments=[6] postfix='.rms' refval=[2.9006123542785645, 2.6539843082427979] res=msmoments(infile=self.rawfile,moments=moments,outfile=self.outfile) # the task doesn't return table anymore self.assertTrue(os.path.exists(self.outfile), msg='Out put table does not exist.') self._compare(self.outfile,refval,'K')
def test110(self): """Test 110: Coordinate of maximum value""" moments=[9] postfix='.maximum_Coord' refval=[5.71909856796, 5.59841299057] res=msmoments(infile=self.rawfile,moments=moments,outfile=self.outfile) # the task doesn't return table anymore self.assertTrue(os.path.exists(self.outfile), msg='Out put table does not exist.') self._compare(self.outfile,refval,'km/s') #Hz?
def test109(self): """Test 109: Maximum value""" moments=[8] postfix='.maximum' refval=[3.9766585826873779, 3.7296187877655029] res=msmoments(infile=self.rawfile,moments=moments,outfile=self.outfile) # the task doesn't return table anymore self.assertTrue(os.path.exists(self.outfile), msg='Out put table does not exist.') self._compare(self.outfile,refval,'K')
def test108(self): """Test 108: Absolute mean deviation""" moments=[7] postfix='.abs_mean_dev' refval=[0.09538549929857254, 0.10068970918655396] res=msmoments(infile=self.rawfile,moments=moments,outfile=self.outfile) # the task doesn't return table anymore self.assertTrue(os.path.exists(self.outfile), msg='Out put table does not exist.') self._compare(self.outfile,refval,'K')
def test112(self): """Test 112: Coordinate of minimum value""" moments=[11] postfix='.minimum_coord' #refval=[45514190848.0, 45464350720.0] refval=[-157.729125977, 170.736236572] res=msmoments(infile=self.rawfile,moments=moments,outfile=self.outfile) # the task doesn't return table anymore self.assertTrue(os.path.exists(self.outfile), msg='Out put table does not exist.') self._compare(self.outfile,refval,'km/s')# Hz?
def test100(self): """Test 100: Mean""" moments=[-1] postfix='.average' refval=[2.8974850177764893,2.6505289077758789] if (os.path.exists(self.outfile)): shutil.rmtree(self.outfile) res=msmoments(infile=self.rawfile,moments=moments,outfile=self.outfile) # the task doesn't return table anymore self.assertTrue(os.path.exists(self.outfile), msg='Out put table does not exist.') self._compare(self.outfile,refval,'K')
def test105(self): """Test 105: Median coordinate (fail at the moment)""" moments=[4] postfix='.median_coordinate' refval=[] try: res=msmoments(infile=self.rawfile,spw=id,moments=moments,outfile=self.outfile) self.assertTrue(False, msg='The task must throw exception') except StandardError, e: pos=str(e).find('moment not allowed to calculate') self.assertNotEqual(pos,-1, msg='Unexpected exception was thrown: %s'%(str(e)))
def test113(self): """Test 113: Multiple moments (mean + velocity field)""" moments=[-1,1] postfix=['.average','.weighted_coord'] refval0=[2.8974850177764893,2.6505289077758789] refval1=[6.8671870231628418,7.6601519584655762] res=msmoments(infile=self.rawfile,moments=moments,outfile=self.outfile) # the task doesn't return table anymore # file existence check for imom in range(len(moments)): name='./'+self.outfile+postfix[imom] self.assertEqual(os.path.exists(name),True, msg='%s must exist'%(name)) # check moments[0] table self._compare(self.outfile+postfix[0],refval0,'K') # check second moment self._compare(self.outfile+postfix[1],refval1,'km/s')
def test000(self): """Test 000: Default parameters""" res = msmoments() self.assertFalse(res)
def test000(self): """Test 000: Default parameters""" res=msmoments() self.assertFalse(res)