00001 import os
00002 import sys
00003 import shutil
00004 from __main__ import default
00005 from tasks import *
00006 from taskinit import *
00007 import unittest
00008 import sha
00009 import time
00010 import numpy
00011 import re
00012 import string
00013
00014 from sdscale import sdscale
00015 import asap as sd
00016
00017
00018
00019
00020
00021
00022
00023
00024 class sdscale_unittest_base:
00025 """
00026 Base class for sdscale unit test
00027 """
00028 taskname='sdscale'
00029 datapath=os.environ.get('CASAPATH').split()[0] + '/data/regression/unittest/sdscale/'
00030
00031 def _checkfile( self, name ):
00032 isthere=os.path.exists(name)
00033 self.assertEqual(isthere,True,
00034 msg='output file %s was not created because of the task failure'%(name))
00035
00036 def _compare( self, name, ref, factor, scaletsys ):
00037 self._checkfile( name )
00038
00039 tb.open(ref)
00040 nrow0=tb.nrows()
00041 rspchans=[]
00042 rtsyschans=[]
00043 for irow in xrange(nrow0):
00044 rspchans.append(len(tb.getcell('SPECTRA',irow)))
00045 rtsyschans.append(len(tb.getcell('TSYS',irow)))
00046 tb.close()
00047
00048 tb.open(name)
00049 nrow=tb.nrows()
00050 self.assertEqual(nrow,2,
00051 msg='number of rows mismatch')
00052 sp=[]
00053 tsys=[]
00054 for irow in xrange(nrow):
00055 sp.append(tb.getcell('SPECTRA',irow))
00056 tsys.append(tb.getcell('TSYS',irow))
00057 self.assertEqual(len(sp[irow]),rspchans[irow],
00058 msg='SPECTRA: number of channel mismatch in row%s'%(irow))
00059 self.assertEqual(len(tsys[irow]),rtsyschans[irow],
00060 msg='TSYS: number of channel mismatch in row%s'%(irow))
00061 tb.close()
00062
00063 valuetype=type(sp[0][0])
00064 if type(factor) is not list:
00065
00066 for irow in xrange(nrow):
00067 arrs = numpy.ones(rspchans[irow],dtype=valuetype)*factor
00068 ret=numpy.allclose(arrs,sp[irow])
00069 self.assertEqual(ret,True,
00070 msg='SPECTRA: data differ in row%s'%(irow))
00071 arrt = numpy.ones(rtsyschans[irow],dtype=valuetype)
00072 if scaletsys:
00073 arrt *= factor
00074 ret=numpy.allclose(arrt,tsys[irow])
00075 self.assertEqual(ret,True,
00076 msg='TSYS: data differ in row%s'%(irow))
00077 elif type(factor[0]) is not list:
00078
00079 factor = numpy.array(factor)
00080 for irow in xrange(nrow):
00081 ret=numpy.allclose(factor,sp[irow])
00082 self.assertEqual(ret,True,
00083 msg='SPECTRA: data differ in row%s'%(irow))
00084 arrt = numpy.ones(rtsyschans[irow],dtype=valuetype)
00085 if scaletsys:
00086 arrt *= factor
00087 ret=numpy.allclose(arrt,tsys[irow])
00088 self.assertEqual(ret,True,
00089 msg='TSYS: data differ in row%s'%(irow))
00090 elif len(factor[0]) == 1:
00091
00092 for irow in xrange(nrow):
00093 arrs = numpy.ones(rspchans[irow],dtype=valuetype)*factor[irow]
00094 ret=numpy.allclose(arrs,sp[irow])
00095 self.assertEqual(ret,True,
00096 msg='SPECTRA: data differ in row%s'%(irow))
00097 arrt = numpy.ones(rtsyschans[irow],dtype=valuetype)
00098 if scaletsys:
00099 arrt *= factor[irow]
00100 ret=numpy.allclose(arrt,tsys[irow])
00101 self.assertEqual(ret,True,
00102 msg='TSYS: data differ in row%s'%(irow))
00103 else:
00104
00105 for irow in xrange(nrow):
00106 arrs = numpy.array(factor[irow])
00107 ret=numpy.allclose(arrs,sp[irow])
00108 self.assertEqual(ret,True,
00109 msg='SPECTRA: data differ in row%s'%(irow))
00110 arrt = numpy.ones(rtsyschans[irow],dtype=valuetype)
00111 if scaletsys:
00112 arrt *= numpy.array(factor[irow])
00113 ret=numpy.allclose(arrt,tsys[irow])
00114 self.assertEqual(ret,True,
00115 msg='TSYS: data differ in row%s'%(irow))
00116
00117
00118
00119
00120
00121 class sdscale_test0(unittest.TestCase,sdscale_unittest_base):
00122 """
00123 Test on bad parameter setting
00124
00125 Test data, sdscale1.asap, is artificial data with the following
00126 status:
00127
00128 - nrow = 2
00129 - nchan = 4 for spectral data
00130 - 1 Tsys value for each spectrum
00131 - all spectral values are 1.0
00132 - all Tsys values are 1.0
00133
00134 """
00135
00136 rawfile='sdscale1.asap'
00137 prefix=sdscale_unittest_base.taskname+'Test0'
00138 outfile=prefix+'.asap'
00139
00140 def setUp(self):
00141 self.res=None
00142 if (not os.path.exists(self.rawfile)):
00143 shutil.copytree(self.datapath+self.rawfile, self.rawfile)
00144
00145 default(sdscale)
00146
00147 def tearDown(self):
00148 if (os.path.exists(self.rawfile)):
00149 shutil.rmtree(self.rawfile)
00150 os.system( 'rm -rf '+self.prefix+'*' )
00151
00152 def test000(self):
00153 """Test 000: Default parameters"""
00154
00155 res=sdscale()
00156 self.assertFalse(res)
00157
00158 def test001(self):
00159 """Test 001: Existing outfile with overwrite=False"""
00160 os.system('cp -r %s %s'%(self.rawfile,self.outfile))
00161 try:
00162 res=sdscale(infile=self.rawfile,factor=2.0,outfile=self.outfile)
00163 self.assertTrue(False,
00164 msg='The task must throw exception')
00165 except Exception, e:
00166 pos=str(e).find('Output file \'%s\' exists.'%(self.outfile))
00167 self.assertNotEqual(pos,-1,
00168 msg='Unexpected exception was thrown: %s'%(str(e)))
00169
00170 def test002(self):
00171 """Test 002: Bad shaped factor"""
00172 factor = [2.0,3.0]
00173 try:
00174 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=False,outfile=self.outfile)
00175 self.assertTrue(False,
00176 msg='The task must throw exception')
00177 except Exception, e:
00178 pos=str(e).find('Vector size must be 1 or be same as number of channel.')
00179 self.assertNotEqual(pos,-1,
00180 msg='Unexpected exception was thrown: %s'%(str(e)))
00181
00182 def test003(self):
00183 """Test 003: Try to scale non-conform Tsys"""
00184 factor=[1.0,2.0,3.0,4.0]
00185 try:
00186 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=True,outfile=self.outfile)
00187 self.assertTrue(False,
00188 msg='The task must throw exception')
00189 except Exception, e:
00190 pos=str(e).find('SPECTRA and TSYS must conform in shape if you want to apply operation on Tsys.')
00191 self.assertNotEqual(pos,-1,
00192 msg='Unexpected exception was thrown: %s'%(str(e)))
00193
00194
00195
00196
00197 class sdscale_test1(unittest.TestCase,sdscale_unittest_base):
00198 """
00199 Test on actual scaling
00200
00201 Test data, sdscale0.asap, is artificial data with the following
00202 status:
00203
00204 - nrow = 2
00205 - nchan = 4
00206 - all spectral values are 1.0
00207 - all Tsys values are 1.0
00208
00209 scaletsys=True should be working.
00210
00211 """
00212
00213 rawfile='sdscale0.asap'
00214 prefix=sdscale_unittest_base.taskname+'Test1'
00215 outfile=prefix+'.asap'
00216
00217 def setUp(self):
00218 self.res=None
00219 if (not os.path.exists(self.rawfile)):
00220 shutil.copytree(self.datapath+self.rawfile, self.rawfile)
00221
00222 default(sdscale)
00223
00224 def tearDown(self):
00225 if (os.path.exists(self.rawfile)):
00226 shutil.rmtree(self.rawfile)
00227 os.system( 'rm -rf '+self.prefix+'*' )
00228
00229 def test100(self):
00230 """Test 100: scalar factor with Tsys scaling"""
00231 factor = 2.0
00232 scaletsys=True
00233 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00234 self.assertEqual(res,None,
00235 msg='Any error occurred during calibration')
00236 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00237
00238 def test101(self):
00239 """Test 101: scalar factor without Tsys scaling"""
00240 factor = 2.0
00241 scaletsys=False
00242 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00243 self.assertEqual(res,None,
00244 msg='Any error occurred during calibration')
00245 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00246
00247 def test102(self):
00248 """Test 102: 1D array factor with Tsys scaling"""
00249 factor = [2.0,3.0,4.0,5.0]
00250 scaletsys=True
00251 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00252 self.assertEqual(res,None,
00253 msg='Any error occurred during calibration')
00254 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00255
00256 def test103(self):
00257 """Test 103: 1D array factor without Tsys scaling"""
00258 factor = [2.0,3.0,4.0,5.0]
00259 scaletsys=False
00260 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00261 self.assertEqual(res,None,
00262 msg='Any error occurred during calibration')
00263 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00264
00265 def test104(self):
00266 """Test 104: 2D array ([nrow,1]) factor with Tsys scaling"""
00267 factor = [[2.0],[3.0]]
00268 scaletsys=True
00269 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00270 self.assertEqual(res,None,
00271 msg='Any error occurred during calibration')
00272 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00273
00274 def test105(self):
00275 """Test 105: 2D array ([nrow,1]) factor without Tsys scaling"""
00276 factor = [[2.0],[3.0]]
00277 scaletsys=False
00278 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00279 self.assertEqual(res,None,
00280 msg='Any error occurred during calibration')
00281 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00282
00283 def test106(self):
00284 """Test 106: 2D array ([nrow,nchan]) factor with Tsys scaling"""
00285 factor = [[2.0,4.0,6.0,8.0],[3.0,5.0,7.0,9.0]]
00286 scaletsys=True
00287 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00288 self.assertEqual(res,None,
00289 msg='Any error occurred during calibration')
00290 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00291
00292 def test107(self):
00293 """Test 107: 2D array ([nrow,nchan]) factor without Tsys scaling"""
00294 factor = [[2.0,4.0,6.0,8.0],[3.0,5.0,7.0,9.0]]
00295 scaletsys=False
00296 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00297 self.assertEqual(res,None,
00298 msg='Any error occurred during calibration')
00299 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00300
00301
00302
00303
00304 class sdscale_test2(unittest.TestCase,sdscale_unittest_base):
00305 """
00306 Test on actual scaling
00307
00308 Test data, sdscale1.asap, is artificial data with the following
00309 status:
00310
00311 - nrow = 2
00312 - nchan = 4
00313 - 1 Tsys value for each spectrum
00314 - all spectral values are 1.0
00315 - all Tsys values are 1.0
00316
00317 scaletsys=True should be working.
00318
00319 """
00320
00321 rawfile='sdscale1.asap'
00322 prefix=sdscale_unittest_base.taskname+'Test2'
00323 outfile=prefix+'.asap'
00324
00325 def setUp(self):
00326 self.res=None
00327 if (not os.path.exists(self.rawfile)):
00328 shutil.copytree(self.datapath+self.rawfile, self.rawfile)
00329
00330 default(sdscale)
00331
00332 def tearDown(self):
00333 if (os.path.exists(self.rawfile)):
00334 shutil.rmtree(self.rawfile)
00335 os.system( 'rm -rf '+self.prefix+'*' )
00336
00337 def test200(self):
00338 """Test 200: scalar factor with Tsys scaling"""
00339 factor = 2.0
00340 scaletsys=True
00341 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00342 self.assertEqual(res,None,
00343 msg='Any error occurred during calibration')
00344 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00345
00346 def test201(self):
00347 """Test 201: scalar factor without Tsys scaling"""
00348 factor = 2.0
00349 scaletsys=False
00350 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00351 self.assertEqual(res,None,
00352 msg='Any error occurred during calibration')
00353 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00354
00355 def test202(self):
00356 """Test 202: 1D array factor with Tsys scaling (must fail)"""
00357 factor = [2.0,3.0,4.0,5.0]
00358 scaletsys=True
00359 try:
00360 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00361 self.assertTrue(False,
00362 msg='The task must throw exception')
00363 except Exception, e:
00364 pos=str(e).find('SPECTRA and TSYS must conform in shape if you want to apply operation on Tsys.')
00365 self.assertNotEqual(pos,-1,
00366 msg='Unexpected exception was thrown: %s'%(str(e)))
00367
00368 def test203(self):
00369 """Test 203: 1D array factor without Tsys scaling"""
00370 factor = [2.0,3.0,4.0,5.0]
00371 scaletsys=False
00372 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00373 self.assertEqual(res,None,
00374 msg='Any error occurred during calibration')
00375 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00376
00377 def test204(self):
00378 """Test 204: 2D array ([nrow,1]) factor with Tsys scaling"""
00379 factor = [[2.0],[3.0]]
00380 scaletsys=True
00381 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00382 self.assertEqual(res,None,
00383 msg='Any error occurred during calibration')
00384 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00385
00386 def test205(self):
00387 """Test 205: 2D array ([nrow,1]) factor without Tsys scaling"""
00388 factor = [[2.0],[3.0]]
00389 scaletsys=False
00390 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00391 self.assertEqual(res,None,
00392 msg='Any error occurred during calibration')
00393 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00394
00395 def test206(self):
00396 """Test 206: 2D array ([nrow,nchan]) factor with Tsys scaling (must fail)"""
00397 factor = [[2.0,4.0,6.0,8.0],[3.0,5.0,7.0,9.0]]
00398 scaletsys=True
00399 try:
00400 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00401 self.assertTrue(False,
00402 msg='The task must throw exception')
00403 except Exception, e:
00404 pos=str(e).find('SPECTRA and TSYS must conform in shape if you want to apply operation on Tsys.')
00405 self.assertNotEqual(pos,-1,
00406 msg='Unexpected exception was thrown: %s'%(str(e)))
00407
00408 def test207(self):
00409 """Test 207: 2D array ([nrow,nchan]) factor without Tsys scaling"""
00410 factor = [[2.0,4.0,6.0,8.0],[3.0,5.0,7.0,9.0]]
00411 scaletsys=False
00412 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00413 self.assertEqual(res,None,
00414 msg='Any error occurred during calibration')
00415 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00416
00417
00418
00419
00420 class sdscale_test3(unittest.TestCase,sdscale_unittest_base):
00421 """
00422 Test on actual scaling
00423
00424 Test data, sdscale2.asap, is artificial data with the following
00425 status:
00426
00427 - nrow = 2
00428 - nchan = 4 in row0, 1 in row1
00429 - all spectral values are 1.0
00430 - all Tsys values are 1.0
00431
00432 scaletsys=True should be working.
00433
00434 """
00435
00436 rawfile='sdscale2.asap'
00437 prefix=sdscale_unittest_base.taskname+'Test3'
00438 outfile=prefix+'.asap'
00439
00440 def setUp(self):
00441 self.res=None
00442 if (not os.path.exists(self.rawfile)):
00443 shutil.copytree(self.datapath+self.rawfile, self.rawfile)
00444
00445 default(sdscale)
00446
00447 def tearDown(self):
00448 if (os.path.exists(self.rawfile)):
00449 shutil.rmtree(self.rawfile)
00450 os.system( 'rm -rf '+self.prefix+'*' )
00451
00452 def test300(self):
00453 """Test 300: scalar factor with Tsys scaling"""
00454 factor = 2.0
00455 scaletsys=True
00456 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00457 self.assertEqual(res,None,
00458 msg='Any error occurred during calibration')
00459 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00460
00461 def test301(self):
00462 """Test 301: scalar factor without Tsys scaling"""
00463 factor = 2.0
00464 scaletsys=False
00465 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00466 self.assertEqual(res,None,
00467 msg='Any error occurred during calibration')
00468 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00469
00470 def test302(self):
00471 """Test 302: 1D array factor with Tsys scaling (must fail)"""
00472 factor = [2.0,3.0,4.0,5.0]
00473 scaletsys=True
00474 try:
00475 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00476 self.assertTrue(False,
00477 msg='The task must throw exception')
00478 except Exception, e:
00479 pos=str(e).find('ArrayColumn::getColumn cannot be done for column SPECTRA; the array shapes vary: Table array conformance error')
00480 self.assertNotEqual(pos,-1,
00481 msg='Unexpected exception was thrown: %s'%(str(e)))
00482
00483 def test303(self):
00484 """Test 303: 1D array factor without Tsys scaling (must fail)"""
00485 factor = [2.0,3.0,4.0,5.0]
00486 scaletsys=False
00487 try:
00488 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00489 self.assertTrue(False,
00490 msg='The task must throw exception')
00491 except Exception, e:
00492 pos=str(e).find('All spectra in the input scantable must have the same number of channel for vector operation.')
00493 self.assertNotEqual(pos,-1,
00494 msg='Unexpected exception was thrown: %s'%(str(e)))
00495
00496 def test304(self):
00497 """Test 304: 2D array ([nrow,1]) factor with Tsys scaling"""
00498 factor = [[2.0],[3.0]]
00499 scaletsys=True
00500 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00501 self.assertEqual(res,None,
00502 msg='Any error occurred during calibration')
00503 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00504
00505 def test305(self):
00506 """Test 305: 2D array ([nrow,1]) factor without Tsys scaling"""
00507 factor = [[2.0],[3.0]]
00508 scaletsys=False
00509 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00510 self.assertEqual(res,None,
00511 msg='Any error occurred during calibration')
00512 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00513
00514 def test306(self):
00515 """Test 306: 2D array ([nrow,nchan]) factor with Tsys scaling"""
00516 factor = [[2.0,4.0,6.0,8.0],[3.0]]
00517 scaletsys=True
00518 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00519 self.assertEqual(res,None,
00520 msg='Any error occurred during calibration')
00521 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00522
00523 def test307(self):
00524 """Test 307: 2D array ([nrow,nchan]) factor without Tsys scaling"""
00525 factor = [[2.0,4.0,6.0,8.0],[3.0]]
00526 scaletsys=False
00527 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00528 self.assertEqual(res,None,
00529 msg='Any error occurred during calibration')
00530 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00531
00532
00533
00534
00535 class sdscale_test4(unittest.TestCase,sdscale_unittest_base):
00536 """
00537 Test on actual scaling
00538
00539 Test data, sdscale3.asap, is artificial data with the following
00540 status:
00541
00542 - nrow = 2
00543 - nchan = 4 in row0, 1 in row1
00544 - 1 Tsys value for each spectrum
00545 - all spectral values are 1.0
00546 - all Tsys values are 1.0
00547
00548 scaletsys=True should be working.
00549
00550 """
00551
00552 rawfile='sdscale3.asap'
00553 prefix=sdscale_unittest_base.taskname+'Test4'
00554 outfile=prefix+'.asap'
00555
00556 def setUp(self):
00557 self.res=None
00558 if (not os.path.exists(self.rawfile)):
00559 shutil.copytree(self.datapath+self.rawfile, self.rawfile)
00560
00561 default(sdscale)
00562
00563 def tearDown(self):
00564 if (os.path.exists(self.rawfile)):
00565 shutil.rmtree(self.rawfile)
00566 os.system( 'rm -rf '+self.prefix+'*' )
00567
00568 def test400(self):
00569 """Test 400: scalar factor with Tsys scaling"""
00570 factor = 2.0
00571 scaletsys=True
00572 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00573 self.assertEqual(res,None,
00574 msg='Any error occurred during calibration')
00575 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00576
00577 def test401(self):
00578 """Test 401: scalar factor without Tsys scaling"""
00579 factor = 2.0
00580 scaletsys=False
00581 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00582 self.assertEqual(res,None,
00583 msg='Any error occurred during calibration')
00584 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00585
00586 def test402(self):
00587 """Test 402: 1D array factor with Tsys scaling (must fail)"""
00588 factor = [2.0,3.0,4.0,5.0]
00589 scaletsys=True
00590 try:
00591 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00592 self.assertTrue(False,
00593 msg='The task must throw exception')
00594 except Exception, e:
00595 pos=str(e).find('ArrayColumn::getColumn cannot be done for column SPECTRA; the array shapes vary: Table array conformance error')
00596 self.assertNotEqual(pos,-1,
00597 msg='Unexpected exception was thrown: %s'%(str(e)))
00598
00599 def test403(self):
00600 """Test 403: 1D array factor without Tsys scaling (must fail)"""
00601 factor = [2.0,3.0,4.0,5.0]
00602 scaletsys=False
00603 try:
00604 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00605 self.assertTrue(False,
00606 msg='The task must throw exception')
00607 except Exception, e:
00608 pos=str(e).find('All spectra in the input scantable must have the same number of channel for vector operation.')
00609 self.assertNotEqual(pos,-1,
00610 msg='Unexpected exception was thrown: %s'%(str(e)))
00611
00612 def test404(self):
00613 """Test 404: 2D array ([nrow,1]) factor with Tsys scaling"""
00614 factor = [[2.0],[3.0]]
00615 scaletsys=True
00616 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00617 self.assertEqual(res,None,
00618 msg='Any error occurred during calibration')
00619 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00620
00621 def test405(self):
00622 """Test 405: 2D array ([nrow,1]) factor without Tsys scaling"""
00623 factor = [[2.0],[3.0]]
00624 scaletsys=False
00625 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00626 self.assertEqual(res,None,
00627 msg='Any error occurred during calibration')
00628 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00629
00630 def test406(self):
00631 """Test 406: 2D array ([nrow,nchan]) factor with Tsys scaling (must fail)"""
00632 factor = [[2.0,4.0,6.0,8.0],[3.0]]
00633 scaletsys=True
00634 try:
00635 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00636 self.assertTrue(False,
00637 msg='The task must throw exception')
00638 except Exception, e:
00639 pos=str(e).find('SPECTRA and TSYS must conform in shape if you want to apply operation on Tsys.')
00640 self.assertNotEqual(pos,-1,
00641 msg='Unexpected exception was thrown: %s'%(str(e)))
00642
00643 def test407(self):
00644 """Test 407: 2D array ([nrow,nchan]) factor without Tsys scaling"""
00645 factor = [[2.0,4.0,6.0,8.0],[3.0]]
00646 scaletsys=False
00647 res=sdscale(infile=self.rawfile,factor=factor,scaletsys=scaletsys,outfile=self.outfile)
00648 self.assertEqual(res,None,
00649 msg='Any error occurred during calibration')
00650 self._compare(self.outfile,self.rawfile,factor,scaletsys)
00651
00652
00653 def suite():
00654 return [sdscale_test0,sdscale_test1,
00655 sdscale_test2,sdscale_test3,
00656 sdscale_test4]