casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
test_task_cvel.py
Go to the documentation of this file.
00001 # unit test for the cvel task
00002 
00003 myname = 'test_task_cvel'
00004 
00005 import os
00006 vis_a = 'ngc4826.ms'
00007 vis_b = 'test.ms'
00008 vis_c = 'jupiter6cm.demo.ms'
00009 vis_d = 'ngc4826.tutorial.ngc4826.ll.5.ms'
00010 vis_e = 'g19_d2usb_targets_line-shortened.ms'
00011 
00012 if(not os.path.exists(vis_a)):
00013     importuvfits(fitsfile=os.environ['CASAPATH'].split()[0]+'/data/regression/ngc4826/fitsfiles/ngc4826.ll.fits5', vis=vis_a)
00014 if(not os.path.exists(vis_b)):
00015     os.system('cp -R '+os.environ['CASAPATH'].split()[0]+'/data/regression/fits-import-export/input/test.ms .')
00016 if(not os.path.exists(vis_c)):
00017     importuvfits(fitsfile=os.environ['CASAPATH'].split()[0]+'/data/regression/jupiter6cm/jupiter6cm.fits', vis=vis_c)
00018 if(not os.path.exists(vis_d)):
00019     importuvfits(fitsfile=os.environ['CASAPATH'].split()[0]+'/data/regression/ngc4826/fitsfiles/ngc4826.ll.fits5', vis=vis_d)
00020 if(not os.path.exists(vis_e)):
00021     os.system('cp -R '+os.environ['CASAPATH'].split()[0]+'/data/regression/cvel/input/g19_d2usb_targets_line-shortened.ms .')
00022 
00023 def verify_ms(msname, expnumspws, expnumchan, inspw):
00024     tb.open(msname+'/SPECTRAL_WINDOW')
00025     nc = tb.getcell("NUM_CHAN", inspw)
00026     nr = tb.nrows()
00027     tb.close()
00028     tb.open(msname)
00029     dimdata = tb.getcell("FLAG", 0)[0].size
00030     tb.close()
00031     if not (nr==expnumspws):
00032         print "Found "+str(nr)+", expected "+str(expnumspws)+" spectral windows in "+msname
00033         raise Exception
00034     if not (nc == expnumchan):
00035         print "Found "+ str(nc) +", expected "+str(expnumchan)+" channels in spw "+str(inspw)+" in "+msname
00036         raise Exception
00037     if not (dimdata == expnumchan):
00038         print "Found "+ str(nc) +", expected "+str(expnumchan)+" channels in FLAG column in "+msname
00039         raise Exception
00040     return True
00041 
00042 keeptestlist = True
00043 
00044 try:
00045     print "List of tests to be executed ...", testlist
00046 except:
00047     print "Global variable testlist not set."
00048     testlist = []
00049 if (testlist==[]):
00050     print "testlist empty. Executing all tests."
00051     testlist = range(0,100)
00052     keeptestlist = False
00053 
00054 total = 0
00055 failures = 0
00056 rval = False
00057 
00058 testnumber = 1
00059 if (testnumber in testlist):
00060     myvis = vis_b
00061     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00062     os.system('cp -R ' + myvis + ' myinput.ms')
00063     default('cvel')
00064     total += 1
00065     try:
00066         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00067         print "Testing default."
00068         rval = cvel()
00069         if not rval:
00070             print myname, ': *** Error as expected ***'   
00071         else:
00072             print "Failed ..."
00073             failures +=1
00074     except:
00075         print myname, ': *** Unexpected error ***'   
00076         failures += 1
00077 
00078 testnumber = 2
00079 if (testnumber in testlist):
00080     myvis = vis_b
00081     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00082     os.system('cp -R ' + myvis + ' myinput.ms')
00083     default('cvel')
00084     total += 1
00085     try:
00086         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00087         print "Only input vis set ..."
00088         rval = cvel(vis = 'myinput.ms')
00089         if not rval:
00090             print myname, ': *** Error as expected ***'   
00091         else:
00092             print "Failed ..."
00093             failures += 1
00094     except:
00095         print myname, ': *** Unexpected error ***'   
00096         failures += 1
00097 
00098 testnumber = 3
00099 if (testnumber in testlist):
00100     myvis = vis_b
00101     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00102     os.system('cp -R ' + myvis + ' myinput.ms')
00103     default('cvel')
00104     total += 1
00105     try:
00106         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00107         print "Input and output vis set ..."
00108         rval = cvel(vis = 'myinput.ms', outputvis = 'cvel-output.ms')
00109         if not rval:
00110             raise Exception
00111         omsname = "test"+str(testnumber)+'cvel-output.ms'
00112         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00113         verify_ms(omsname, 1, 64, 0)
00114     except:
00115         print myname, ': *** Unexpected error ***'   
00116         failures += 1
00117 
00118 testnumber = 4
00119 if (testnumber in testlist):
00120     myvis = vis_a        
00121     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00122     os.system('cp -R ' + myvis + ' myinput.ms')
00123     default('cvel')
00124     total += 1
00125     try:
00126         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00127         print "Input and output vis set, more complex input vis, one field selected ..."
00128         rval = cvel(vis = 'myinput.ms', outputvis = 'cvel-output.ms', field = '1')
00129         if not rval:
00130             raise Exception
00131         omsname = "test"+str(testnumber)+'cvel-output.ms'
00132         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00133         verify_ms(omsname, 1, 64, 0)
00134     except:
00135         print myname, ': *** Unexpected error ***'   
00136         failures += 1
00137 
00138 testnumber = 5
00139 if (testnumber in testlist):
00140     myvis = vis_a
00141     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00142     os.system('cp -R ' + myvis + ' myinput.ms')
00143     default('cvel')
00144     total += 1
00145     try:
00146         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00147         print "Input and output vis set, more complex input vis, one field selected, passall = True ..."
00148         rval = cvel(
00149                 vis = 'myinput.ms',
00150                 outputvis = 'cvel-output.ms',
00151                 field = '1',
00152                 passall = True
00153                 )
00154         if not rval:
00155             raise Exception
00156         omsname = "test"+str(testnumber)+'cvel-output.ms'
00157         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00158         verify_ms(omsname, 2, 64, 0)
00159     except:
00160         print myname, ': *** Unexpected error ***'   
00161         failures += 1
00162 
00163 testnumber = 6
00164 if (testnumber in testlist):
00165     myvis = vis_a
00166     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00167     os.system('cp -R ' + myvis + ' myinput.ms')
00168     default('cvel')
00169     total += 1
00170     try:
00171         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00172         print "Input and output vis set, more complex input vis, one field selected, one spw selected, passall = True ..."
00173         rval = cvel(
00174             vis = 'myinput.ms',
00175             outputvis = 'cvel-output.ms',
00176             field = '1',
00177             spw = '0',
00178             passall = True
00179             )
00180         if not rval:
00181             raise Exception
00182         omsname = "test"+str(testnumber)+'cvel-output.ms'
00183         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00184         verify_ms(omsname, 2, 64, 0)
00185     except:
00186         print myname, ': *** Unexpected error ***'   
00187         failures += 1
00188 
00189 ## # Tests with more than one spectral window ###################
00190 
00191 testnumber = 7
00192 if (testnumber in testlist):
00193     myvis = vis_c
00194     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00195     os.system('cp -R ' + myvis + ' myinput.ms')
00196     default('cvel')
00197     total += 1
00198     try:
00199         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00200         print "Input and output vis set, input vis with two spws, one field selected, 2 spws selected, passall = False ..."
00201         rval = cvel(
00202                 vis = 'myinput.ms',
00203                 outputvis = 'cvel-output.ms',
00204                 field = '12', # select Jupiter
00205                 spw = '0,1',  # both available SPWs
00206                 passall = False
00207                 )
00208         if not rval:
00209             raise Exception
00210         omsname = "test"+str(testnumber)+'cvel-output.ms'
00211         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00212         verify_ms(omsname, 1, 2, 0)
00213     except:
00214         print myname, ': *** Unexpected error ***'   
00215         failures += 1
00216 
00217 testnumber = 8
00218 if (testnumber in testlist):
00219     myvis = vis_c
00220     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00221     os.system('cp -R ' + myvis + ' myinput.ms')
00222     default('cvel')
00223     total += 1
00224     try:
00225         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00226         print "Input and output vis set, input vis with two spws, one field selected, 2 spws selected, passall = False, regridding 1..."
00227         rval = cvel(
00228             vis = 'myinput.ms',
00229             outputvis = 'cvel-output.ms',
00230             field = '11',    # select some other field
00231             spw = '0,1',    # both available SPWs
00232             passall = False,    # regrid
00233             nchan = 1,
00234             width = 2
00235             )
00236         if not rval:
00237             raise Exception
00238         omsname = "test"+str(testnumber)+'cvel-output.ms'
00239         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00240         verify_ms(omsname, 1, 1, 0)
00241     except:
00242         print myname, ': *** Unexpected error ***'   
00243         failures += 1
00244 
00245 testnumber = 9
00246 if (testnumber in testlist):
00247     myvis = vis_c
00248     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00249     os.system('cp -R ' + myvis + ' myinput.ms')
00250     default('cvel')
00251     total += 1
00252     try:
00253         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00254         print "Input and output vis set, input vis with two spws, one field selected, 2 spws selected, passall = False, regridding 2..."
00255         rval = cvel(
00256             vis = 'myinput.ms',
00257             outputvis = 'cvel-output.ms',
00258             field = '10',
00259             spw = '0,1',
00260             passall = False,
00261             mode='channel',
00262             nchan = 1,
00263             start = 1
00264             )
00265         if not rval:
00266             raise Exception
00267         omsname = "test"+str(testnumber)+'cvel-output.ms'
00268         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00269         verify_ms(omsname, 1, 1, 0)
00270     except:
00271         print myname, ': *** Unexpected error ***'   
00272         failures += 1
00273 
00274 testnumber = 10
00275 if (testnumber in testlist):
00276     myvis = vis_c
00277     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00278     os.system('cp -R ' + myvis + ' myinput.ms')
00279     default('cvel')
00280     total += 1
00281     try:
00282         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00283         print "Input and output vis set, input vis with two spws, one field selected, 2 spws selected, passall = False, regridding 3..."
00284         rval = cvel(
00285             vis = 'myinput.ms',
00286             outputvis = 'cvel-output.ms',
00287             field = '9',
00288             spw = '0,1',
00289             passall = False,
00290             mode='frequency',
00291             nchan = 1,
00292             start = '4.8351GHz',
00293             width = '50MHz'
00294             )
00295         if not rval:
00296             raise Exception
00297         omsname = "test"+str(testnumber)+'cvel-output.ms'
00298         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00299         verify_ms(omsname, 1, 1, 0)
00300     except:
00301         print myname, ': *** Unexpected error ***'   
00302         failures += 1
00303 
00304 testnumber = 11
00305 if (testnumber in testlist):
00306     myvis = vis_c
00307     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00308     os.system('cp -R ' + myvis + ' myinput.ms')
00309     default('cvel')
00310     total += 1
00311     try:
00312         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00313         print "Input and output vis set, input vis with two spws, one field selected, 2 spws selected, passall = False, regridding 4..."
00314         rval = cvel(
00315             vis = 'myinput.ms',
00316             outputvis = 'cvel-output.ms',
00317             field = '10',
00318             spw = '0,1',
00319             passall = False,
00320             mode='channel',
00321             nchan = 1,
00322             start = 1,
00323             outframe = 'lsrk'
00324             )
00325         if not rval:
00326             raise Exception
00327         omsname = "test"+str(testnumber)+'cvel-output.ms'
00328         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00329         verify_ms(omsname, 1, 1, 0)
00330     except:
00331         print myname, ': *** Unexpected error ***'   
00332         failures += 1
00333 
00334 testnumber = 12
00335 if (testnumber in testlist):
00336     myvis = vis_c
00337     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00338     os.system('cp -R ' + myvis + ' myinput.ms')
00339     default('cvel')
00340     total += 1
00341     try:
00342         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00343         print "Input and output vis set, input vis with two spws, two fields selected, 2 spws selected, passall = False, regridding 5..."
00344         rval = cvel(
00345             vis = 'myinput.ms',
00346             outputvis = 'cvel-output.ms',
00347             field = '5,6',
00348             spw = '0,1',
00349             passall = False,
00350             mode='frequency',
00351             nchan = 2,
00352             start = '4.8351 GHz',
00353             width = '50 MHz',
00354             outframe = ''
00355             )
00356         if not rval:
00357             raise Exception
00358         omsname = "test"+str(testnumber)+'cvel-output.ms'
00359         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00360         verify_ms(omsname, 1, 2, 0)
00361     except:
00362         print myname, ': *** Unexpected error ***'   
00363         failures += 1
00364 
00365 testnumber = 13
00366 if (testnumber in testlist):
00367     myvis = vis_a
00368     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00369     os.system('cp -R ' + myvis + ' myinput.ms')
00370     default('cvel')
00371     total += 1
00372     try:
00373         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00374         print "Input and output vis set, input vis with one spws, one field selected, one spws selected, passall = False, regridding 6..."
00375         rval = cvel(
00376             vis = 'myinput.ms',
00377             outputvis = 'cvel-output.ms',
00378             field = '1',
00379             spw = '0',
00380             passall = False,
00381             mode='frequency',
00382             nchan = 2,
00383             start = '115GHz',
00384             width = '3MHz',
00385             outframe = 'BARY',
00386             phasecenter = 1
00387             )
00388         if not rval:
00389             raise Exception
00390         omsname = "test"+str(testnumber)+'cvel-output.ms'
00391         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00392         verify_ms(omsname, 1, 2, 0)
00393     except:
00394         print myname, ': *** Unexpected error ***'   
00395         failures += 1
00396 
00397 testnumber = 14
00398 if (testnumber in testlist):
00399     myvis = vis_a
00400     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00401     os.system('cp -R ' + myvis + ' myinput.ms')
00402     default('cvel')
00403     total += 1
00404     try:
00405         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00406         print "Input and output vis set, input vis with one spws, one field selected, one spws selected, passall = False, non-existing phase center..."
00407         rval = cvel(
00408             vis = 'myinput.ms',
00409             outputvis = 'cvel-output.ms',
00410             field = '1',
00411             spw = '0',
00412             passall = False,
00413             mode='frequency',
00414             nchan = 2,
00415             start = '150GHz',
00416             width = '3MHz',
00417             outframe = 'BARY',
00418             phasecenter = 12
00419             )
00420         if not rval:
00421             raise Exception
00422         omsname = "test"+str(testnumber)+'cvel-output.ms'
00423         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00424         verify_ms(omsname, 1, 2, 0)
00425         failures += 1
00426     except:
00427         print myname, ': *** Expected error ***'   
00428 
00429 testnumber = 15
00430 if (testnumber in testlist):
00431     myvis = vis_c
00432     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00433     os.system('cp -R ' + myvis + ' myinput.ms')
00434     default('cvel')
00435     total += 1
00436     try:
00437         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00438         print "Input and output vis set, input vis with two spws, one field selected, 2 spws selected, passall = False, regridding 8..."
00439         rval = cvel(
00440             vis = 'myinput.ms',
00441             outputvis = 'cvel-output.ms',
00442             field = '12',
00443             spw = '0,1',
00444             passall = False,
00445             mode='frequency',
00446             nchan = 1,
00447             start = '4.850GHz',
00448             width = '50MHz',
00449             outframe = ''
00450             )
00451         if not rval:
00452             raise Exception
00453         omsname = "test"+str(testnumber)+'cvel-output.ms'
00454         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00455         verify_ms(omsname, 1, 1, 0)
00456     except:
00457         print myname, ': *** Unexpected error ***'   
00458         failures += 1
00459 
00460 testnumber = 16
00461 if (testnumber in testlist):
00462     myvis = vis_d
00463     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00464     os.system('cp -R ' + myvis + ' myinput.ms')
00465     default('cvel')
00466     total += 1
00467     try:
00468         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00469         print "Input and output vis set, input vis with one spw, two fields selected, passall = False, regridding 9..."
00470         rval = cvel(
00471             vis = 'myinput.ms',
00472             outputvis = 'cvel-output.ms',
00473             field = '2,3',
00474             spw = '0',
00475             passall = False,
00476             mode='channel',
00477             nchan = 10,
00478             start = 2,
00479             outframe = 'lsrd',
00480             phasecenter = 2
00481             )
00482         if not rval:
00483             raise Exception
00484         omsname = "test"+str(testnumber)+'cvel-output.ms'
00485         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00486         verify_ms(omsname, 1, 10, 0)
00487     except:
00488         print myname, ': *** Unexpected error ***'   
00489         failures += 1
00490 
00491 testnumber = 17
00492 if (testnumber in testlist):
00493     myvis = vis_d
00494     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00495     os.system('cp -R ' + myvis + ' myinput.ms')
00496     default('cvel')
00497     total += 1
00498     try:
00499         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00500         print "Input and output vis set, input vis with one spw, two fields selected, passall = False, regridding 9..."
00501         rval = cvel(
00502                 vis = 'myinput.ms',
00503                 outputvis = 'cvel-output.ms',
00504                 field = '2,3',
00505                 spw = '0',
00506                 passall = False,
00507                 mode='frequency',
00508                 nchan = 10,
00509                 start = '114.9527GHz',
00510                 width = '3.125MHz',
00511                 outframe = 'lsrd',
00512                 phasecenter = 2
00513             )
00514         if not rval:
00515             raise Exception
00516         omsname = "test"+str(testnumber)+'cvel-output.ms'
00517         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00518         verify_ms(omsname, 1, 10, 0)
00519     except:
00520         print myname, ': *** Unexpected error ***'   
00521         failures += 1
00522 
00523 testnumber = 18
00524 if (testnumber in testlist):
00525     myvis = vis_d
00526     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00527     os.system('cp -R ' + myvis + ' myinput.ms')
00528     default('cvel')
00529     total += 1
00530     try:
00531         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00532         print "Input and output vis set, input vis with one spw, two fields selected, passall = False, regridding 9..."
00533         rval = cvel(
00534             vis = 'myinput.ms',
00535             outputvis = 'cvel-output.ms',
00536             field = '2,3',
00537             spw = '0',
00538             passall = False,
00539             mode='frequency',
00540             nchan = 10,
00541             start = '114.9527GHz',
00542             width = '3.125MHz',
00543             outframe = 'lsrd',
00544             phasecenter = 'J2000 12h56m43.88s +21d41m00.1s'
00545             )
00546         if not rval:
00547             raise Exception
00548         omsname = "test"+str(testnumber)+'cvel-output.ms'
00549         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00550         verify_ms(omsname, 1, 10, 0)
00551     except:
00552         print myname, ': *** Unexpected error ***'   
00553         failures += 1
00554 
00555 testnumber = 19
00556 if (testnumber in testlist):
00557     myvis = vis_e
00558     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00559     os.system('cp -R ' + myvis + ' myinput.ms')
00560     default('cvel')
00561     total += 1
00562     try:
00563         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00564         print "SMA input MS, 24 spws to combine, channel mode, 10 output channels"
00565         rval = cvel(
00566             vis = 'myinput.ms',
00567             outputvis = 'cvel-output.ms',
00568             mode='channel',
00569             nchan = 10,
00570             start = 100,
00571             width = 2,
00572             phasecenter = "J2000 18h25m56.09 -12d04m28.20"
00573             )
00574         if not rval:
00575             raise Exception
00576         omsname = "test"+str(testnumber)+'cvel-output.ms'
00577         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00578         verify_ms(omsname, 1, 10, 0)
00579     except:
00580         print myname, ': *** Unexpected error ***'   
00581         failures += 1
00582 
00583 testnumber = 20
00584 if (testnumber in testlist):
00585     myvis = vis_e
00586     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00587     os.system('cp -R ' + myvis + ' myinput.ms')
00588     default('cvel')
00589     total += 1
00590     try:
00591         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00592         print "SMA input MS, 24 spws to combine, channel mode, 111 output channels"
00593         rval = cvel(
00594             vis = 'myinput.ms',
00595             outputvis = 'cvel-output.ms',
00596             mode='channel',
00597             nchan = 111,
00598             start = 201,
00599             width = 3,
00600             phasecenter = "J2000 18h25m56.09 -12d04m28.20"
00601             )
00602         if not rval:
00603             raise Exception
00604         omsname = "test"+str(testnumber)+'cvel-output.ms'
00605         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00606         verify_ms(omsname, 1, 111, 0)
00607     except:
00608         print myname, ': *** Unexpected error ***'   
00609         failures += 1
00610 
00611 testnumber = 21
00612 if (testnumber in testlist):
00613     myvis = vis_e
00614     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00615     os.system('cp -R ' + myvis + ' myinput.ms')
00616     default('cvel')
00617     total += 1
00618     try:
00619         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00620         print "SMA input MS, 24 spws to combine, frequency mode, 21 output channels"
00621         rval = cvel(
00622             vis = 'myinput.ms',
00623             outputvis = 'cvel-output.ms',
00624             mode='frequency',
00625             nchan = 21,
00626             start = '229587.0MHz',
00627             width = '1600kHz',
00628             phasecenter = "J2000 18h25m56.09 -12d04m28.20"
00629             )
00630         if not rval:
00631             raise Exception
00632         omsname = "test"+str(testnumber)+'cvel-output.ms'
00633         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00634         verify_ms(omsname, 1, 21, 0)
00635     except:
00636         print myname, ': *** Unexpected error ***'   
00637         failures += 1
00638 
00639 testnumber = 22
00640 if (testnumber in testlist):
00641     myvis = vis_e
00642     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00643     os.system('cp -R ' + myvis + ' myinput.ms')
00644     default('cvel')
00645     total += 1
00646     try:
00647         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00648         print "SMA input MS, 24 spws to combine, frequency mode, 210 output channels, negative width (sign will be ignored)"
00649         rval = cvel(
00650             vis = 'myinput.ms',
00651             outputvis = 'cvel-output.ms',
00652             mode='frequency',
00653             nchan = 210,
00654             start = '229588.0MHz',
00655             width = '-2400kHz',
00656             phasecenter = "J2000 18h25m56.09 -12d04m28.20"
00657             )
00658         if not rval:
00659             raise Exception
00660         omsname = "test"+str(testnumber)+'cvel-output.ms'
00661         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00662         verify_ms(omsname, 1, 210, 0)
00663     except:
00664         print myname, ': *** Unexpected error ***'   
00665         failures += 1
00666 
00667 testnumber = 23
00668 if (testnumber in testlist):
00669     myvis = vis_e
00670     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00671     os.system('cp -R ' + myvis + ' myinput.ms')
00672     default('cvel')
00673     total += 1
00674     try:
00675         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00676         print "SMA input MS, 24 spws to combine, radio velocity mode, 30 output channels"
00677         print "start = ", start, ", width = ", width
00678         vrad = (220398.676E6 - 229586E6)/220398.676E6 * 2.99792E8
00679         vwidth = ((220398.676E6 - 229586E6+1600E3)/220398.676E6 * 2.99792E8) - vrad
00680         vrad = vrad-vwidth/2.
00681         rval = cvel(
00682             vis = 'myinput.ms',
00683             outputvis = 'cvel-output.ms',
00684             mode='velocity',
00685             nchan = 30,
00686             restfreq = '220398.676MHz',
00687             start = str(vrad)+'m/s',
00688             width = str(vwidth)+'m/s',
00689             phasecenter = "J2000 18h25m56.09 -12d04m28.20",
00690             veltype = 'radio'
00691             )
00692         if not rval:
00693             raise Exception
00694         omsname = "test"+str(testnumber)+'cvel-output.ms'
00695         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00696         verify_ms(omsname, 1, 30, 0)
00697     except:
00698         print myname, ': *** Unexpected error ***'   
00699         failures += 1
00700 
00701 testnumber = 24
00702 if (testnumber in testlist):
00703     myvis = vis_e
00704     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00705     os.system('cp -R ' + myvis + ' myinput.ms')
00706     default('cvel')
00707     total += 1
00708     try:
00709         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00710         print "SMA input MS, 24 spws to combine, radio velocity mode, 35 output channels"
00711         vrad = (220398.676E6 - 229586E6)/220398.676E6 * 2.99792E8
00712         vwidth = ((220398.676E6 - 229586E6+3200E3)/220398.676E6 * 2.99792E8) - vrad
00713         vrad = vrad-vwidth/2.
00714         rval = cvel(
00715             vis = 'myinput.ms',
00716             outputvis = 'cvel-output.ms',
00717             mode='velocity',
00718             nchan = 35,
00719             restfreq = '220398.676MHz',
00720             start = str(vrad)+'m/s',
00721             width = str(vwidth)+'m/s',
00722             phasecenter = "J2000 18h25m56.09 -12d04m28.20",
00723             veltype = 'radio'
00724             )
00725         if not rval:
00726             raise Exception
00727         omsname = "test"+str(testnumber)+'cvel-output.ms'
00728         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00729         verify_ms(omsname, 1, 35, 0)
00730     except:
00731         print myname, ': *** Unexpected error ***'   
00732         failures += 1
00733 
00734 testnumber = 25
00735 if (testnumber in testlist):
00736     myvis = vis_e
00737     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00738     os.system('cp -R ' + myvis + ' myinput.ms')
00739     default('cvel')
00740     total += 1
00741     try:
00742         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00743         print "SMA input MS, 24 spws to combine, optical velocity mode, 40 output channels"
00744         lambda0 = 2.99792E8/220398.676E6
00745         lambda1 = 2.99792E8/229586E6
00746         lambda2 = 2.99792E8/(229586E6+1600E3)
00747         vopt = (lambda1-lambda0)/lambda0 * 2.99792E8
00748         vwidth = vopt - (lambda2-lambda0)/lambda0 * 2.99792E8
00749         vopt = vopt-vwidth/2.
00750         rval = cvel(
00751             vis = 'myinput.ms',
00752             outputvis = 'cvel-output.ms',
00753             mode='velocity',
00754             nchan = 40,
00755             restfreq = '220398.676MHz',
00756             start = str(vopt)+'m/s',
00757             width = str(vwidth)+'m/s',
00758             phasecenter = "J2000 18h25m56.09 -12d04m28.20",
00759             veltype = 'optical'
00760             )
00761         if not rval:
00762             raise Exception
00763         omsname = "test"+str(testnumber)+'cvel-output.ms'
00764         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00765         verify_ms(omsname, 1, 40, 0)
00766     except:
00767         print myname, ': *** Unexpected error ***'   
00768         failures += 1
00769 
00770 testnumber = 26
00771 if (testnumber in testlist):
00772     myvis = vis_e
00773     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00774     os.system('cp -R ' + myvis + ' myinput.ms')
00775     default('cvel')
00776     total += 1
00777     try:
00778         lambda0 = 2.99792E8/220398.676E6
00779         lambda1 = 2.99792E8/229586E6
00780         vopt = (lambda1-lambda0)/lambda0 * 2.99792E8
00781         lambda2 = 2.99792E8/(229586E6+1200E3)
00782         vwidth = vopt - (lambda2-lambda0)/lambda0 * 2.99792E8
00783         vopt = vopt-vwidth/2.
00784         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00785         print "SMA input MS, 24 spws to combine, optical velocity mode, 40 output channels"
00786         rval = cvel(
00787             vis = 'myinput.ms',
00788             outputvis = 'cvel-output.ms',
00789             mode='velocity',
00790             nchan = 41,
00791             restfreq = '220398.676MHz',
00792             start = str(vopt)+'m/s',
00793             width = str(vwidth)+'m/s',
00794             phasecenter = "J2000 18h25m56.09 -12d04m28.20",
00795             veltype = 'optical'
00796             )
00797         if not rval:
00798             raise Exception
00799         omsname = "test"+str(testnumber)+'cvel-output.ms'
00800         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00801         verify_ms(omsname, 1, 41, 0)
00802     except:
00803         print myname, ': *** Unexpected error ***'   
00804         failures += 1
00805 
00806 testnumber = 27
00807 if (testnumber in testlist):
00808     myvis = vis_e
00809     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00810     os.system('cp -R ' + myvis + ' myinput.ms')
00811     default('cvel')
00812     # no regrid
00813     total += 1
00814     try:
00815         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00816         print "SMA input MS, 24 spws to combine, scratch columns, no regridding"
00817         rval = cvel(
00818             vis = 'myinput.ms',
00819             outputvis = 'cvel-output.ms'
00820             )
00821         if not rval:
00822             raise Exception
00823         omsname = "test"+str(testnumber)+'cvel-output.ms'
00824         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00825         verify_ms(omsname, 1, 2440, 0)
00826     except:
00827         print myname, ': *** Unexpected error ***'   
00828         failures += 1
00829 
00830 testnumber = 28
00831 if (testnumber in testlist):
00832     myvis = vis_e
00833     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00834     os.system('cp -R ' + myvis + ' myinput.ms')
00835     default('cvel')
00836     total += 1
00837     try:
00838         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00839         print "SMA input MS, 24 spws to combine, scratch columns, channel mode, 30 channels "
00840         rval = cvel(
00841             vis = 'myinput.ms',
00842             outputvis = 'cvel-output.ms',
00843             mode="channel",
00844             start=1500,
00845             width=2,
00846             nchan=30
00847             )
00848         if not rval:
00849             raise Exception
00850         omsname = "test"+str(testnumber)+'cvel-output.ms'
00851         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00852         verify_ms(omsname, 1, 30, 0)
00853     except:
00854         print myname, ': *** Unexpected error ***'   
00855         failures += 1
00856         
00857 testnumber = 29
00858 if (testnumber in testlist):
00859     myvis = vis_e
00860     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00861     os.system('cp -R ' + myvis + ' myinput.ms')
00862     default('cvel')
00863     total += 1
00864     try:
00865         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00866         print "SMA input MS, 24 spws to combine, scratch columns, channel mode, 31 channels "
00867         rval = cvel(
00868             vis = 'myinput.ms',
00869             outputvis = 'cvel-output.ms',
00870             mode="channel",
00871             start=1500,
00872             width=2,
00873             nchan=31
00874             )
00875         if not rval:
00876             raise Exception
00877         omsname = "test"+str(testnumber)+'cvel-output.ms'
00878         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00879         verify_ms(omsname, 1, 31, 0)
00880     except:
00881         print myname, ': *** Unexpected error ***'   
00882         failures += 1
00883 
00884 testnumber = 30
00885 if (testnumber in testlist):
00886     myvis = vis_e
00887     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00888     os.system('cp -R ' + myvis + ' myinput.ms')
00889     default('cvel')
00890     total += 1
00891     try:
00892         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00893         print "SMA input MS, 24 spws to combine, scratch columns, mode channel_b, no regridding"
00894         rval = cvel(
00895             vis = 'myinput.ms',
00896             outputvis = 'cvel-output.ms',
00897             mode="channel_b"
00898             )
00899         if not rval:
00900             raise Exception
00901         omsname = "test"+str(testnumber)+'cvel-output.ms'
00902         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00903         verify_ms(omsname, 1, 2443, 0)
00904     except:
00905         print myname, ': *** Unexpected error ***'   
00906         failures += 1
00907 
00908 testnumber = 31
00909 if (testnumber in testlist):
00910     myvis = vis_e
00911     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00912     os.system('cp -R ' + myvis + ' myinput.ms')
00913     default('cvel')
00914     total += 1
00915     try:
00916         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00917         print "SMA input MS, 24 spws to combine, scratch columns, mode channel, frame trafo"
00918         rval = cvel(
00919             vis = 'myinput.ms',
00920             outputvis = 'cvel-output.ms',
00921             mode="channel",
00922             outframe = "BARY",
00923             phasecenter = "J2000 18h25m56.09 -12d04m28.20"
00924             )
00925         if not rval:
00926             raise Exception
00927         omsname = "test"+str(testnumber)+'cvel-output.ms'
00928         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00929         verify_ms(omsname, 1, 2440, 0)
00930     except:
00931         print myname, ': *** Unexpected error ***'   
00932         failures += 1
00933 
00934 testnumber = 32
00935 if (testnumber in testlist):
00936     myvis = vis_e
00937     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00938     os.system('cp -R ' + myvis + ' myinput.ms')
00939     default('cvel')
00940     total += 1
00941     try:
00942         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00943         print "SMA input MS, 24 spws to combine, scratch columns, mode channel, frame trafo, Hanning smoothing"
00944         rval = cvel(
00945             vis = 'myinput.ms',
00946             outputvis = 'cvel-output.ms',
00947             mode="channel",
00948             outframe = "BARY",
00949             phasecenter = "J2000 18h25m56.09 -12d04m28.20",
00950             hanning = True
00951             )
00952         if not rval:
00953             raise Exception
00954         omsname = "test"+str(testnumber)+'cvel-output.ms'
00955         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00956         verify_ms(omsname, 1, 2440, 0)
00957     except:
00958         print myname, ': *** Unexpected error ***'   
00959         failures += 1
00960 
00961 testnumber = 33
00962 if (testnumber in testlist):
00963     myvis = vis_e
00964     os.system('rm -rf cvel-output.ms cvel-output.ms.deselected myinput.ms')
00965     os.system('cp -R ' + myvis + ' myinput.ms')
00966     default('cvel')
00967     total += 1
00968     try:
00969         print "\n>>>> Test ", testnumber, ", input MS: ", myvis
00970         print "SMA input MS, 1 spw, scratch columns, mode channel, no trafo, Hanning smoothing"
00971         rval = cvel(
00972             vis = 'myinput.ms',
00973             spw='1',
00974             outputvis = 'cvel-output.ms',
00975             mode="channel",
00976             outframe = "",
00977             hanning = True
00978             )
00979         if not rval:
00980             raise Exception
00981         omsname = "test"+str(testnumber)+'cvel-output.ms'
00982         os.system('rm -rf '+omsname+'; mv cvel-output.ms '+omsname)
00983         verify_ms(omsname, 1, 128, 0)
00984     except:
00985         print myname, ': *** Unexpected error ***'   
00986         failures += 1
00987 
00988 
00989 
00990 
00991 # Summary ########################################
00992 print "Tests = ", total    
00993 print "Failures = ", failures
00994 
00995 # empty test list if it was empty to start with
00996 if not keeptestlist:
00997     testlist = []