00001
00002
00003 import os
00004 import shutil
00005 from __main__ import default
00006 from tasks import *
00007 from taskinit import *
00008 import unittest
00009 import numpy as np
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 tests_to_do = []
00029
00030 mytotal = 0
00031 myfailures = 0
00032 failed = []
00033
00034 def testit():
00035 global mymode, mycase, myspwids, mynchan, mystart, mywidth, myexpectation, mytotal, myfailures
00036 global tests_to_do, failed
00037 if (mycase in tests_to_do) or (tests_to_do==[]):
00038 try:
00039 outf = ms.cvelfreqs(spwids=myspwids,mode=mymode,nchan=mynchan,start=mystart,width=mywidth)
00040 if not type(outf)==type([]):
00041 outf = list(outf)
00042 print mycase
00043 print outf
00044 print myexpectation
00045 if outf != myexpectation:
00046 print "Test failed for case ", mycase
00047 print "spwids=", myspwids,", mode=",mymode,",nchan=",mynchan,", start=",mystart,", width=",mywidth
00048 myfailures = myfailures + 1
00049 failed.append(mycase)
00050 else:
00051 print mycase, " OK"
00052 except:
00053 print "Test failed with exception for case ", mycase
00054 print "spwids=", myspwids,", mode=",mymode,",nchan=",mynchan,", start=",mystart,", width=",mywidth
00055 myfailures = myfailures + 1
00056 failed.append(mycase)
00057 mytotal = mytotal + 1
00058
00059 def v_iseq(a,b,tol):
00060 if(len(a)!=len(b)):
00061 print len(a), len(b)
00062 return False
00063 for i in range(0,len(a)):
00064 if(abs(a[i]-b[i])>tol):
00065 print i, a[i], b[i]
00066 return False
00067 return True
00068
00069 def vopt(f):
00070 global myrestfrq
00071 return (myrestfrq/f - 1.) * qa.constants('c')['value']
00072
00073 def freq_from_vopt(v):
00074 global myrestfrq
00075 return myrestfrq/(1. + v/qa.constants('c')['value'])
00076
00077 def vrad(f):
00078 global myrestfrq
00079 return qa.constants('c')['value'] * (1. - f/myrestfrq)
00080
00081 def freq_from_vrad(v):
00082 global myrestfrq
00083 return myrestfrq * (1. - v/qa.constants('c')['value'])
00084
00085 def testitb():
00086
00087 global mymode, mycase, myspwids, mynchan, mystart, mywidth, myveltype, myrestfrq, myexpectation, mytotal, myfailures
00088 global tests_to_do, failed
00089 if (mycase in tests_to_do) or (tests_to_do==[]):
00090 try:
00091 outf = ms.cvelfreqs(spwids=myspwids,mode=mymode,nchan=mynchan,start=mystart,width=mywidth, veltype=myveltype, restfreq=str(myrestfrq)+'Hz')
00092 print mycase
00093 print outf
00094 if not type(outf)==type([]):
00095 outf = list(outf)
00096 fexpectation = []
00097 vexpectation = []
00098 vout = []
00099 for i in range(0,len(myexpectation)):
00100 fexpectation.append(freq_from_vopt(myexpectation[i]))
00101 vexpectation.append(vopt(fexpectation[i]))
00102 vout = []
00103 for i in range(0,len(outf)):
00104 vout.append(vopt(outf[i]))
00105 print "expected: ", myexpectation
00106 print "exp freq: ", fexpectation
00107 print "output v: ", vout
00108 print "exp v: ", vexpectation
00109 if not v_iseq(outf,fexpectation,10.0):
00110 print "Test failed for case ", mycase
00111 print "spwids=", myspwids,", mode=",mymode,",nchan=",mynchan,", start=",mystart,","
00112 print " width=",mywidth,", veltype=",myveltype, ", restfreq=", str(myrestfrq)+'Hz'
00113 myfailures = myfailures + 1
00114 failed.append(mycase)
00115 else:
00116 print mycase, " OK"
00117 except:
00118 print "Test failed with exception ", sys.exc_info()," for case ", mycase
00119 print "spwids=", myspwids,", mode=",mymode,",nchan=",mynchan,", start=",mystart,", width=",mywidth,", veltype=",myveltype
00120 myfailures = myfailures + 1
00121 failed.append(mycase)
00122 mytotal = mytotal + 1
00123
00124 def testitc():
00125
00126 global mymode, mycase, myspwids, mynchan, mystart, mywidth, myveltype, myrestfrq, myexpectation, mytotal, myfailures
00127 global tests_to_do, failed
00128 if (mycase in tests_to_do) or (tests_to_do==[]):
00129 try:
00130 outf = ms.cvelfreqs(spwids=myspwids,mode=mymode,nchan=mynchan,start=mystart,width=mywidth, veltype=myveltype, restfreq=str(myrestfrq)+'Hz')
00131 print mycase
00132 print outf
00133 if not type(outf)==type([]):
00134 outf = list(outf)
00135 fexpectation = []
00136 vexpectation = []
00137 vout = []
00138 for i in range(0,len(myexpectation)):
00139 fexpectation.append(freq_from_vrad(myexpectation[i]))
00140 vexpectation.append(vrad(fexpectation[i]))
00141 vout = []
00142 for i in range(0,len(outf)):
00143 vout.append(vrad(outf[i]))
00144 print "expected: ", myexpectation
00145 print "exp freq: ", fexpectation
00146 print "output v: ", vout
00147 print "exp v: ", vexpectation
00148 if not v_iseq(outf,fexpectation,10.0):
00149 print "Test failed for case ", mycase
00150 print "spwids=", myspwids,", mode=",mymode,",nchan=",mynchan,", start=",mystart,","
00151 print " width=",mywidth,", veltype=",myveltype, ", restfreq=", str(myrestfrq)+'Hz'
00152 myfailures = myfailures + 1
00153 failed.append(mycase)
00154 else:
00155 print mycase, " OK"
00156 except:
00157 print "Test failed with exception ", sys.exc_info()," for case ", mycase
00158 print "spwids=", myspwids,", mode=",mymode,",nchan=",mynchan,", start=",mystart,", width=",mywidth,", veltype=",myveltype
00159 myfailures = myfailures + 1
00160 failed.append(mycase)
00161 mytotal = mytotal + 1
00162
00163
00164 def testchannelmode(caseoffset, isDesc):
00165 global mymode, mycase, myspwids, mynchan, mystart, mywidth, myexpectation, mytotal, myfailures
00166 global tests_to_do, failed
00167
00168
00169 mymode = 'channel'
00170 mycase = caseoffset + 0
00171 myspwids = [0]
00172 mynchan = -1
00173 mystart = 0
00174 mywidth = 1
00175 myexpectation = [1,2,3,4,5,6,7,8,9,10]
00176 if(isDesc):
00177 myexpectation.reverse()
00178
00179 testit()
00180
00181
00182 mycase = caseoffset + 1
00183 myspwids = [0]
00184 mynchan = 10
00185 mystart = 0
00186 mywidth = 1
00187 myexpectation = [1,2,3,4,5,6,7,8,9,10]
00188
00189 if(isDesc):
00190 myexpectation.reverse()
00191 testit()
00192
00193
00194 mycase = caseoffset + 2
00195 myspwids = [0]
00196 mynchan = 5
00197 mystart = 0
00198 mywidth = 1
00199 myexpectation = [1,2,3,4,5]
00200
00201 if(isDesc):
00202 myexpectation = [10,9,8,7,6]
00203 testit()
00204
00205
00206 mycase = caseoffset + 3
00207 myspwids = [0]
00208 mynchan = 6
00209 mystart = 0
00210 mywidth = 1
00211 myexpectation = [1,2,3,4,5,6]
00212
00213 if(isDesc):
00214 myexpectation = [10,9,8,7,6,5]
00215 testit()
00216
00217
00218
00219 mycase = caseoffset + 4
00220 myspwids = [1]
00221 mynchan = -1
00222 mystart = 0
00223 mywidth = 1
00224 myexpectation = [10,11,12,13,14,15,16,17,18,19]
00225
00226 if(isDesc):
00227 myexpectation.reverse()
00228 testit()
00229
00230
00231 mycase = caseoffset + 5
00232 myspwids = [1]
00233 mynchan = 10
00234 mystart = 0
00235 mywidth = 1
00236 myexpectation = [10,11,12,13,14,15,16,17,18,19]
00237
00238 if(isDesc):
00239 myexpectation.reverse()
00240 testit()
00241
00242
00243 mycase = caseoffset + 6
00244 myspwids = [1]
00245 mynchan = 5
00246 mystart = 0
00247 mywidth = 1
00248 myexpectation = [10,11,12,13,14]
00249
00250 if(isDesc):
00251 myexpectation = [19,18,17,16,15]
00252 testit()
00253
00254
00255 mycase = caseoffset + 7
00256 myspwids = [1]
00257 mynchan = 6
00258 mystart = 0
00259 mywidth = 1
00260 myexpectation = [10,11,12,13,14,15]
00261
00262 if(isDesc):
00263 myexpectation = [19,18,17,16,15,14]
00264 testit()
00265
00266
00267 mycase = caseoffset + 8
00268 myspwids = [0,1]
00269 mynchan = -1
00270 mystart = 0
00271 mywidth = 1
00272 myexpectation = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
00273
00274 testit()
00275
00276
00277 mycase = caseoffset + 9
00278 myspwids = [0,1]
00279 mynchan = 10
00280 mystart = 0
00281 mywidth = 1
00282 myexpectation = [1,2,3,4,5,6,7,8,9,10]
00283
00284 testit()
00285
00286
00287 mycase = caseoffset + 10
00288 myspwids = [0,1]
00289 mynchan = 5
00290 mystart = 0
00291 mywidth = 1
00292 myexpectation = [1,2,3,4,5]
00293
00294 testit()
00295
00296
00297 mycase = caseoffset + 11
00298 myspwids = [0,1]
00299 mynchan = 6
00300 mystart = 0
00301 mywidth = 1
00302 myexpectation = [1,2,3,4,5,6]
00303
00304 testit()
00305
00306
00307
00308 mycase = caseoffset + 12
00309 myspwids = [1,2]
00310 mynchan = -1
00311 mystart = 0
00312 mywidth = 1
00313 myexpectation = [10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]
00314
00315 testit()
00316
00317
00318 mycase = caseoffset + 13
00319 myspwids = [1,2]
00320 mynchan = 10
00321 mystart = 0
00322 mywidth = 1
00323 myexpectation = [10,11,12,13,14,15,16,17,18,19]
00324
00325 testit()
00326
00327
00328 mycase = caseoffset + 14
00329 myspwids = [1,2]
00330 mynchan = 5
00331 mystart = 0
00332 mywidth = 1
00333 myexpectation = [10,11,12,13,14]
00334
00335 testit()
00336
00337
00338 mycase = caseoffset + 15
00339 myspwids = [1,2]
00340 mynchan = 6
00341 mystart = 0
00342 mywidth = 1
00343 myexpectation = [10,11,12,13,14,15]
00344
00345 testit()
00346
00347
00348 mycase = caseoffset + 16
00349 myspwids = [0,1,2]
00350 mynchan = -1
00351 mystart = 0
00352 mywidth = 1
00353 myexpectation = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]
00354
00355 testit()
00356
00357
00358 mycase = caseoffset + 17
00359 myspwids = [0,1,2]
00360 mynchan = 10
00361 mystart = 0
00362 mywidth = 1
00363 myexpectation = [1,2,3,4,5,6,7,8,9,10]
00364
00365 testit()
00366
00367
00368 mycase = caseoffset + 18
00369 myspwids = [0,1,2]
00370 mynchan = 5
00371 mystart = 0
00372 mywidth = 1
00373 myexpectation = [1,2,3,4,5]
00374
00375 testit()
00376
00377
00378 mycase = caseoffset + 19
00379 myspwids = [0,1,2]
00380 mynchan = 6
00381 mystart = 0
00382 mywidth = 1
00383 myexpectation = [1,2,3,4,5,6]
00384
00385 testit()
00386
00387
00388
00389
00390
00391 mystart = 1
00392
00393 mycase = caseoffset + 20
00394 myspwids = [0]
00395 mynchan = -1
00396
00397 mywidth = 1
00398 myexpectation = [2,3,4,5,6,7,8,9,10]
00399
00400 if(isDesc):
00401 myexpectation = [9,8,7,6,5,4,3,2,1]
00402 testit()
00403
00404
00405 mycase = caseoffset + 21
00406 myspwids = [0]
00407 mynchan = 10
00408
00409 mywidth = 1
00410 myexpectation = [2,3,4,5,6,7,8,9,10,11]
00411
00412 if(isDesc):
00413 myexpectation = [9,8,7,6,5,4,3,2,1,0]
00414 testit()
00415
00416
00417 mycase = caseoffset + 22
00418 myspwids = [0]
00419 mynchan = 5
00420
00421 mywidth = 1
00422 myexpectation = [2,3,4,5,6]
00423
00424 if(isDesc):
00425 myexpectation = [9,8,7,6,5]
00426 testit()
00427
00428
00429 mycase = caseoffset + 23
00430 myspwids = [0]
00431 mynchan = 6
00432
00433 mywidth = 1
00434 myexpectation = [2,3,4,5,6,7]
00435
00436 if(isDesc):
00437 myexpectation = [9,8,7,6,5,4]
00438 testit()
00439
00440
00441
00442 mycase = caseoffset + 24
00443 myspwids = [1]
00444 mynchan = -1
00445
00446 mywidth = 1
00447 myexpectation = [11,12,13,14,15,16,17,18,19]
00448
00449 if(isDesc):
00450 myexpectation = [18,17,16,15,14,13,12,11,10]
00451 testit()
00452
00453
00454 mycase = caseoffset + 25
00455 myspwids = [1]
00456 mynchan = 10
00457
00458 mywidth = 1
00459 myexpectation = [11,12,13,14,15,16,17,18,19,20]
00460
00461 if(isDesc):
00462 myexpectation = [18,17,16,15,14,13,12,11,10,9]
00463 testit()
00464
00465
00466 mycase = caseoffset + 26
00467 myspwids = [1]
00468 mynchan = 5
00469
00470 mywidth = 1
00471 myexpectation = [11,12,13,14,15]
00472
00473 if(isDesc):
00474 myexpectation = [18,17,16,15,14]
00475 testit()
00476
00477
00478 mycase = caseoffset + 27
00479 myspwids = [1]
00480 mynchan = 6
00481
00482 mywidth = 1
00483 myexpectation = [11,12,13,14,15,16]
00484
00485 if(isDesc):
00486 myexpectation = [18,17,16,15,14,13]
00487 testit()
00488
00489
00490 mycase = caseoffset + 28
00491 myspwids = [0,1]
00492 mynchan = -1
00493
00494 mywidth = 1
00495 myexpectation = [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
00496
00497 testit()
00498
00499
00500 mycase = caseoffset + 29
00501 myspwids = [0,1]
00502 mynchan = 10
00503
00504 mywidth = 1
00505 myexpectation = [2,3,4,5,6,7,8,9,10,11]
00506
00507 testit()
00508
00509
00510 mycase = caseoffset + 30
00511 myspwids = [0,1]
00512 mynchan = 5
00513
00514 mywidth = 1
00515 myexpectation = [2,3,4,5,6]
00516
00517 testit()
00518
00519
00520 mycase = caseoffset + 31
00521 myspwids = [0,1]
00522 mynchan = 6
00523
00524 mywidth = 1
00525 myexpectation = [2,3,4,5,6,7]
00526
00527 testit()
00528
00529
00530
00531 mycase = caseoffset + 32
00532 myspwids = [1,2]
00533 mynchan = -1
00534
00535 mywidth = 1
00536 myexpectation = [11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]
00537
00538 testit()
00539
00540
00541 mycase = caseoffset + 33
00542 myspwids = [1,2]
00543 mynchan = 10
00544
00545 mywidth = 1
00546 myexpectation = [11,12,13,14,15,16,17,18,19,20]
00547
00548 testit()
00549
00550
00551 mycase = caseoffset + 34
00552 myspwids = [1,2]
00553 mynchan = 5
00554
00555 mywidth = 1
00556 myexpectation = [11,12,13,14,15]
00557
00558 testit()
00559
00560
00561 mycase = caseoffset + 35
00562 myspwids = [1,2]
00563 mynchan = 6
00564
00565 mywidth = 1
00566 myexpectation = [11,12,13,14,15,16]
00567
00568 testit()
00569
00570
00571 mycase = caseoffset + 36
00572 myspwids = [0,1,2]
00573 mynchan = -1
00574
00575 mywidth = 1
00576 myexpectation = [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]
00577
00578 testit()
00579
00580
00581 mycase = caseoffset + 37
00582 myspwids = [0,1,2]
00583 mynchan = 10
00584
00585 mywidth = 1
00586 myexpectation = [2,3,4,5,6,7,8,9,10,11]
00587
00588 testit()
00589
00590
00591 mycase = caseoffset + 38
00592 myspwids = [0,1,2]
00593 mynchan = 5
00594
00595 mywidth = 1
00596 myexpectation = [2,3,4,5,6]
00597
00598 testit()
00599
00600
00601 mycase = caseoffset + 39
00602 myspwids = [0,1,2]
00603 mynchan = 6
00604
00605 mywidth = 1
00606 myexpectation = [2,3,4,5,6,7]
00607
00608 testit()
00609
00610
00611
00612
00613
00614 mystart = 15
00615
00616 mycase = caseoffset + 40
00617 myspwids = [0]
00618 mynchan = -1
00619
00620 mywidth = 1
00621 myexpectation = [1,2,3,4,5,6,7,8,9,10]
00622
00623 if(isDesc):
00624 myexpectation.reverse()
00625 testit()
00626
00627
00628 mycase = caseoffset + 41
00629 myspwids = [0]
00630 mynchan = 10
00631
00632 mywidth = 1
00633 myexpectation = [1,2,3,4,5,6,7,8,9,10]
00634
00635 if(isDesc):
00636 myexpectation.reverse()
00637 testit()
00638
00639
00640 mycase = caseoffset + 42
00641 myspwids = [0]
00642 mynchan = 5
00643
00644 mywidth = 1
00645 myexpectation = [1,2,3,4,5]
00646
00647 if(isDesc):
00648 myexpectation.reverse()
00649 testit()
00650
00651
00652 mycase = caseoffset + 43
00653 myspwids = [0]
00654 mynchan = 6
00655
00656 mywidth = 1
00657 myexpectation = [1,2,3,4,5,6]
00658
00659 if(isDesc):
00660 myexpectation.reverse()
00661 testit()
00662
00663
00664
00665 mycase = caseoffset + 44
00666 myspwids = [1]
00667 mynchan = -1
00668
00669 mywidth = 1
00670 myexpectation = [10,11,12,13,14,15,16,17,18,19]
00671
00672 if(isDesc):
00673 myexpectation.reverse()
00674 testit()
00675
00676
00677 mycase = caseoffset + 45
00678 myspwids = [1]
00679 mynchan = 10
00680
00681 mywidth = 1
00682 myexpectation = [10,11,12,13,14,15,16,17,18,19]
00683
00684 if(isDesc):
00685 myexpectation.reverse()
00686 testit()
00687
00688
00689 mycase = caseoffset + 46
00690 myspwids = [1]
00691 mynchan = 5
00692
00693 mywidth = 1
00694 myexpectation = [10,11,12,13,14]
00695
00696 if(isDesc):
00697 myexpectation.reverse()
00698 testit()
00699
00700
00701 mycase = caseoffset + 47
00702 myspwids = [1]
00703 mynchan = 6
00704
00705 mywidth = 1
00706 myexpectation = [10,11,12,13,14,15]
00707
00708 if(isDesc):
00709 myexpectation.reverse()
00710 testit()
00711
00712
00713 mycase = caseoffset + 48
00714 myspwids = [0,1]
00715 mynchan = -1
00716
00717 mywidth = 1
00718 myexpectation = [16,17,18,19]
00719
00720 testit()
00721
00722
00723 mycase = caseoffset + 49
00724 myspwids = [0,1]
00725 mynchan = 10
00726
00727 mywidth = 1
00728 myexpectation = [16,17,18,19,20,21,22,23,24,25]
00729
00730 testit()
00731
00732
00733 mycase = caseoffset + 50
00734 myspwids = [0,1]
00735 mynchan = 5
00736
00737 mywidth = 1
00738 myexpectation = [16,17,18,19,20]
00739
00740 testit()
00741
00742
00743 mycase = caseoffset + 51
00744 myspwids = [0,1]
00745 mynchan = 6
00746
00747 mywidth = 1
00748 myexpectation = [16,17,18,19,20,21]
00749
00750 testit()
00751
00752
00753
00754 mycase = caseoffset + 52
00755 myspwids = [1,2]
00756 mynchan = -1
00757
00758 mywidth = 1
00759 myexpectation = [25,26,27,28]
00760
00761 testit()
00762
00763
00764 mycase = caseoffset + 53
00765 myspwids = [1,2]
00766 mynchan = 10
00767
00768 mywidth = 1
00769 myexpectation = [25,26,27,28,29,30,31,32,33,34]
00770
00771 testit()
00772
00773
00774 mycase = caseoffset + 54
00775 myspwids = [1,2]
00776 mynchan = 5
00777
00778 mywidth = 1
00779 myexpectation = [25,26,27,28,29]
00780
00781 testit()
00782
00783
00784 mycase = caseoffset + 55
00785 myspwids = [1,2]
00786 mynchan = 6
00787
00788 mywidth = 1
00789 myexpectation = [25,26,27,28,29,30]
00790
00791 testit()
00792
00793
00794 mycase = caseoffset + 56
00795 myspwids = [0,1,2]
00796 mynchan = -1
00797
00798 mywidth = 1
00799 myexpectation = [16,17,18,19,20,21,22,23,24,25,26,27,28]
00800
00801 testit()
00802
00803
00804 mycase = caseoffset + 57
00805 myspwids = [0,1,2]
00806 mynchan = 10
00807
00808 mywidth = 1
00809 myexpectation = [16,17,18,19,20,21,22,23,24,25]
00810
00811 testit()
00812
00813
00814 mycase = caseoffset + 58
00815 myspwids = [0,1,2]
00816 mynchan = 5
00817
00818 mywidth = 1
00819 myexpectation = [16,17,18,19,20]
00820
00821 testit()
00822
00823
00824 mycase = caseoffset + 59
00825 myspwids = [0,1,2]
00826 mynchan = 6
00827
00828 mywidth = 1
00829 myexpectation = [16,17,18,19,20,21]
00830
00831 testit()
00832
00833
00834
00835 mywidth = -1
00836
00837
00838 mycase = caseoffset + 60
00839 myspwids = [0]
00840 mynchan = -1
00841 mystart = 9
00842
00843 myexpectation = [1,2,3,4,5,6,7,8,9,10]
00844
00845 if(isDesc):
00846 myexpectation.reverse()
00847 testit()
00848
00849
00850 mycase = caseoffset + 60 + 1
00851 myspwids = [0]
00852 mynchan = 10
00853 mystart = 9
00854
00855 myexpectation = [1,2,3,4,5,6,7,8,9,10]
00856
00857 if(isDesc):
00858 myexpectation.reverse()
00859 testit()
00860
00861
00862 mycase = caseoffset + 60 + 2
00863 myspwids = [0]
00864 mynchan = 5
00865 mystart = 4
00866
00867 myexpectation = [1,2,3,4,5]
00868
00869 if(isDesc):
00870 myexpectation = [10,9,8,7,6]
00871 testit()
00872
00873
00874 mycase = caseoffset + 60 + 3
00875 myspwids = [0]
00876 mynchan = 6
00877 mystart = 5
00878
00879 myexpectation = [1,2,3,4,5,6]
00880
00881 if(isDesc):
00882 myexpectation = [10,9,8,7,6,5]
00883 testit()
00884
00885
00886
00887 mycase = caseoffset + 60 + 4
00888 myspwids = [1]
00889 mynchan = -1
00890 mystart = 9
00891
00892 myexpectation = [10,11,12,13,14,15,16,17,18,19]
00893
00894 if(isDesc):
00895 myexpectation.reverse()
00896 testit()
00897
00898
00899 mycase = caseoffset + 60 + 5
00900 myspwids = [1]
00901 mynchan = 10
00902 mystart = 9
00903
00904 myexpectation = [10,11,12,13,14,15,16,17,18,19]
00905
00906 if(isDesc):
00907 myexpectation.reverse()
00908 testit()
00909
00910
00911 mycase = caseoffset + 60 + 6
00912 myspwids = [1]
00913 mynchan = 5
00914 mystart = 4
00915
00916 myexpectation = [10,11,12,13,14]
00917
00918 if(isDesc):
00919 myexpectation = [19,18,17,16,15]
00920 testit()
00921
00922
00923 mycase = caseoffset + 60 + 7
00924 myspwids = [1]
00925 mynchan = 6
00926 mystart = 5
00927
00928 myexpectation = [10,11,12,13,14,15]
00929
00930 if(isDesc):
00931 myexpectation = [19,18,17,16,15,14]
00932 testit()
00933
00934
00935 mycase = caseoffset + 60 + 8
00936 myspwids = [0,1]
00937 mynchan = -1
00938 mystart = 18
00939
00940 myexpectation = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
00941
00942 testit()
00943
00944
00945 mycase = caseoffset + 60 + 9
00946 myspwids = [0,1]
00947 mynchan = 10
00948 mystart = 9
00949
00950 myexpectation = [1,2,3,4,5,6,7,8,9,10]
00951
00952 testit()
00953
00954
00955 mycase = caseoffset + 60 + 10
00956 myspwids = [0,1]
00957 mynchan = 5
00958 mystart = 4
00959
00960 myexpectation = [1,2,3,4,5]
00961
00962 testit()
00963
00964
00965 mycase = caseoffset + 60 + 11
00966 myspwids = [0,1]
00967 mynchan = 6
00968 mystart = 5
00969
00970 myexpectation = [1,2,3,4,5,6]
00971
00972 testit()
00973
00974
00975
00976 mycase = caseoffset + 60 + 12
00977 myspwids = [1,2]
00978 mynchan = -1
00979 mystart = 18
00980
00981 myexpectation = [10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]
00982
00983 testit()
00984
00985
00986 mycase = caseoffset + 60 + 13
00987 myspwids = [1,2]
00988 mynchan = 10
00989 mystart = 9
00990
00991 myexpectation = [10,11,12,13,14,15,16,17,18,19]
00992
00993 testit()
00994
00995
00996 mycase = caseoffset + 60 + 14
00997 myspwids = [1,2]
00998 mynchan = 5
00999 mystart = 4
01000
01001 myexpectation = [10,11,12,13,14]
01002
01003 testit()
01004
01005
01006 mycase = caseoffset + 60 + 15
01007 myspwids = [1,2]
01008 mynchan = 6
01009 mystart = 5
01010
01011 myexpectation = [10,11,12,13,14,15]
01012
01013 testit()
01014
01015
01016 mycase = caseoffset + 60 + 16
01017 myspwids = [0,1,2]
01018 mynchan = -1
01019 mystart = 27
01020
01021 myexpectation = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]
01022
01023 testit()
01024
01025
01026 mycase = caseoffset + 60 + 17
01027 myspwids = [0,1,2]
01028 mynchan = 10
01029 mystart = 9
01030
01031 myexpectation = [1,2,3,4,5,6,7,8,9,10]
01032
01033 testit()
01034
01035
01036 mycase = caseoffset + 60 + 18
01037 myspwids = [0,1,2]
01038 mynchan = 5
01039 mystart = 4
01040
01041 myexpectation = [1,2,3,4,5]
01042
01043 testit()
01044
01045
01046 mycase = caseoffset + 60 + 19
01047 myspwids = [0,1,2]
01048 mynchan = 6
01049 mystart = 5
01050
01051 myexpectation = [1,2,3,4,5,6]
01052
01053 testit()
01054
01055
01056
01057 def testvoptmode(caseoffset, isDesc):
01058 global mymode, mycase, myspwids, mynchan, mystart, mywidth, myveltype, myrestfrq, myexpectation, mytotal, myfailures
01059 global tests_to_do, failed
01060
01061
01062 myrestfrq = (-1000./299792458.0 + 1.) * (1E10 + 10.)
01063
01064
01065 mymode = 'velocity'
01066 myveltype = 'optical'
01067
01068
01069 mystart = "-1000m/s"
01070 mywidth = "-1m/s"
01071
01072
01073 mycase = caseoffset + 0
01074 myspwids = [0]
01075 mynchan = -1
01076
01077 myexpectation = [-1000,-1001,-1002,-1003,-1004,-1005,-1006,-1007,-1008,-1009]
01078
01079 if(isDesc):
01080 myexpectation.reverse()
01081
01082 testitb()
01083
01084
01085 mycase = caseoffset + 1
01086 myspwids = [0]
01087 mynchan = 10
01088
01089 myexpectation = [-1000,-1001,-1002,-1003,-1004,-1005,-1006,-1007,-1008,-1009]
01090
01091 if(isDesc):
01092 myexpectation.reverse()
01093
01094 testitb()
01095
01096
01097 mycase = caseoffset + 2
01098 myspwids = [0]
01099 mynchan = 5
01100
01101 myexpectation = [-1000,-1001,-1002,-1003,-1004]
01102
01103 if(isDesc):
01104 myexpectation.reverse()
01105
01106 testitb()
01107
01108
01109 mycase = caseoffset + 3
01110 myspwids = [0]
01111 mynchan = 6
01112
01113 myexpectation = [-1000,-1001,-1002,-1003,-1004,-1005]
01114
01115 if(isDesc):
01116 myexpectation.reverse()
01117
01118 testitb()
01119
01120
01121
01122 mycase = caseoffset + 4
01123 myspwids = [1]
01124 mynchan = -1
01125 mystart = "-1010m/s"
01126
01127 myexpectation = [-1010,-1011,-1012,-1013,-1014,-1015,-1016,-1017,-1018,-1019]
01128 if(isDesc):
01129 myexpectation.reverse()
01130
01131 testitb()
01132
01133
01134 mycase = caseoffset + 5
01135 myspwids = [1]
01136 mynchan = 10
01137
01138 myexpectation = [-1010,-1011,-1012,-1013,-1014,-1015,-1016,-1017,-1018,-1019]
01139 if(isDesc):
01140 myexpectation.reverse()
01141
01142 testitb()
01143
01144
01145 mycase = caseoffset + 6
01146 myspwids = [1]
01147 mynchan = 5
01148
01149 myexpectation = [-1010,-1011,-1012,-1013,-1014]
01150 if(isDesc):
01151 myexpectation.reverse()
01152
01153 testitb()
01154
01155
01156 mycase = caseoffset + 7
01157 myspwids = [1]
01158 mynchan = 6
01159
01160 myexpectation = [-1010,-1011,-1012,-1013,-1014,-1015]
01161 if(isDesc):
01162 myexpectation.reverse()
01163
01164 testitb()
01165
01166
01167 mycase = caseoffset + 8
01168 myspwids = [0,1]
01169 mynchan = -1
01170 mystart = "-1000m/s"
01171
01172 myexpectation = range(-1000,-1020,-1)
01173
01174 testitb()
01175
01176
01177 mycase = caseoffset + 9
01178 myspwids = [0,1]
01179 mynchan = 10
01180
01181 myexpectation = [-1000,-1001,-1002,-1003,-1004,-1005,-1006,-1007,-1008,-1009]
01182
01183 testitb()
01184
01185
01186 mycase = caseoffset + 10
01187 myspwids = [0,1]
01188 mynchan = 5
01189
01190 myexpectation = [-1000,-1001,-1002,-1003,-1004]
01191
01192 testitb()
01193
01194
01195 mycase = caseoffset + 11
01196 myspwids = [0,1]
01197 mynchan = 6
01198 mystart = "-1009m/s"
01199
01200 myexpectation = [-1009,-1010,-1011,-1012,-1013,-1014]
01201
01202 testitb()
01203
01204
01205
01206 mycase = caseoffset + 12
01207 myspwids = [1,2]
01208 mynchan = -1
01209 mystart = "-1010m/s"
01210
01211 myexpectation = range(-1010,-1030,-1)
01212
01213 testitb()
01214
01215
01216 mycase = caseoffset + 13
01217 myspwids = [1,2]
01218 mynchan = 10
01219 mystart = "-1010m/s"
01220
01221 myexpectation = [-1010,-1011,-1012,-1013,-1014,-1015,-1016,-1017,-1018,-1019]
01222
01223 testitb()
01224
01225
01226 mycase = caseoffset + 14
01227 myspwids = [1,2]
01228 mynchan = 5
01229 mystart = "-1010m/s"
01230
01231
01232 myexpectation = [-1010,-1011,-1012,-1013,-1014]
01233
01234 testitb()
01235
01236
01237 mycase = caseoffset + 15
01238 myspwids = [1,2]
01239 mynchan = 6
01240 mystart = "-1010m/s"
01241
01242 myexpectation = [-1010,-1011,-1012,-1013,-1014,-1015]
01243
01244 testitb()
01245
01246
01247 mycase = caseoffset + 16
01248 myspwids = [0,1,2]
01249 mynchan = -1
01250 mystart = "-1000m/s"
01251
01252 myexpectation = range(-1000,-1030,-1)
01253
01254 testitb()
01255
01256
01257 mycase = caseoffset + 17
01258 myspwids = [0,1,2]
01259 mynchan = 10
01260 mystart = "-1000m/s"
01261
01262 myexpectation = range(-1000,-1010,-1)
01263
01264 testitb()
01265
01266
01267 mycase = caseoffset + 18
01268 myspwids = [0,1,2]
01269 mynchan = 5
01270 mystart = "-1020m/s"
01271
01272 myexpectation = [-1020,-1021,-1022,-1023,-1024]
01273
01274 testitb()
01275
01276
01277 mycase = caseoffset + 19
01278 myspwids = [0,1,2]
01279 mynchan = 6
01280 mystart = "-1005m/s"
01281 mywidth = "1m/s"
01282
01283 myexpectation = [-1000,-1001,-1002,-1003,-1004,-1005]
01284
01285 testitb()
01286
01287
01288 mycase = caseoffset + 20
01289 myspwids = [0,1,2]
01290 mynchan = 6
01291 mystart = "-1018m/s"
01292 mywidth = "2m/s"
01293
01294 myexpectation = [-1008,-1010,-1012,-1014,-1016,-1018]
01295
01296 testitb()
01297
01298
01299
01300
01301 def testfreqmode(caseoffset, isDesc):
01302 global mymode, mycase, myspwids, mynchan, mystart, mywidth, myexpectation, mytotal, myfailures
01303 global tests_to_do, failed
01304
01305 mymode = 'frequency'
01306 mycase = caseoffset + 0
01307 myspwids = [0]
01308 mynchan = -1
01309 mystart = 1
01310 mywidth = 1
01311 myexpectation = [1,2,3,4,5,6,7,8,9,10]
01312 if(isDesc):
01313 myexpectation.reverse()
01314 testit()
01315
01316
01317 mycase = caseoffset + 1
01318 myspwids = [0]
01319 mynchan = 10
01320
01321 myexpectation = [1,2,3,4,5,6,7,8,9,10]
01322
01323 if(isDesc):
01324 myexpectation.reverse()
01325 testit()
01326
01327
01328 mycase = caseoffset + 2
01329 myspwids = [0]
01330 mynchan = 5
01331
01332 myexpectation = [1,2,3,4,5]
01333
01334 if(isDesc):
01335 myexpectation.reverse()
01336 testit()
01337
01338
01339 mycase = caseoffset + 3
01340 myspwids = [0]
01341 mynchan = 6
01342
01343 myexpectation = [1,2,3,4,5,6]
01344
01345 if(isDesc):
01346 myexpectation.reverse()
01347 testit()
01348
01349
01350
01351 mycase = caseoffset + 4
01352 myspwids = [1]
01353 mynchan = -1
01354 mystart = 10
01355
01356 myexpectation = [10,11,12,13,14,15,16,17,18,19]
01357
01358 if(isDesc):
01359 myexpectation.reverse()
01360 testit()
01361
01362
01363 mycase = caseoffset + 5
01364 myspwids = [1]
01365 mynchan = 10
01366 mystart = 10
01367 mywidth = 1
01368 myexpectation = [10,11,12,13,14,15,16,17,18,19]
01369
01370 if(isDesc):
01371 myexpectation.reverse()
01372 testit()
01373
01374
01375 mycase = caseoffset + 6
01376 myspwids = [1]
01377 mynchan = 5
01378 mystart = 10
01379 mywidth = 1
01380 myexpectation = [10,11,12,13,14]
01381
01382 if(isDesc):
01383 myexpectation.reverse()
01384 testit()
01385
01386
01387 mycase = caseoffset + 7
01388 myspwids = [1]
01389 mynchan = 6
01390 mystart = 10
01391 mywidth = 1
01392 myexpectation = [10,11,12,13,14,15]
01393
01394 if(isDesc):
01395 myexpectation.reverse()
01396 testit()
01397
01398
01399 mycase = caseoffset + 8
01400 myspwids = [0,1]
01401 mynchan = -1
01402 mystart = 1
01403 mywidth = 1
01404 myexpectation = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
01405
01406 testit()
01407
01408
01409 mycase = caseoffset + 9
01410 myspwids = [0,1]
01411 mynchan = 10
01412 mystart = 1
01413 mywidth = 1
01414 myexpectation = [1,2,3,4,5,6,7,8,9,10]
01415
01416 testit()
01417
01418
01419 mycase = caseoffset + 10
01420 myspwids = [0,1]
01421 mynchan = 5
01422 mystart = 1
01423 mywidth = 1
01424 myexpectation = [1,2,3,4,5]
01425
01426 testit()
01427
01428
01429 mycase = caseoffset + 11
01430 myspwids = [0,1]
01431 mynchan = 6
01432 mystart = 1
01433 mywidth = 1
01434 myexpectation = [1,2,3,4,5,6]
01435
01436 testit()
01437
01438
01439
01440 mycase = caseoffset + 12
01441 myspwids = [1,2]
01442 mynchan = -1
01443 mystart = 10
01444 mywidth = 1
01445 myexpectation = [10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]
01446
01447 testit()
01448
01449
01450 mycase = caseoffset + 13
01451 myspwids = [1,2]
01452 mynchan = 10
01453 mystart = 10
01454 mywidth = 1
01455 myexpectation = [10,11,12,13,14,15,16,17,18,19]
01456
01457 testit()
01458
01459
01460 mycase = caseoffset + 14
01461 myspwids = [1,2]
01462 mynchan = 5
01463 mystart = 10
01464 mywidth = 1
01465 myexpectation = [10,11,12,13,14]
01466
01467 testit()
01468
01469
01470 mycase = caseoffset + 15
01471 myspwids = [1,2]
01472 mynchan = 6
01473 mystart = 10
01474 mywidth = 1
01475 myexpectation = [10,11,12,13,14,15]
01476
01477 testit()
01478
01479
01480 mycase = caseoffset + 16
01481 myspwids = [0,1,2]
01482 mynchan = -1
01483 mystart = 1
01484 mywidth = 1
01485 myexpectation = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]
01486
01487 testit()
01488
01489
01490 mycase = caseoffset + 17
01491 myspwids = [0,1,2]
01492 mynchan = 10
01493 mystart = 1
01494 mywidth = 1
01495 myexpectation = [1,2,3,4,5,6,7,8,9,10]
01496
01497 testit()
01498
01499
01500 mycase = caseoffset + 18
01501 myspwids = [0,1,2]
01502 mynchan = 5
01503 mystart = 1
01504 mywidth = 1
01505 myexpectation = [1,2,3,4,5]
01506
01507 testit()
01508
01509
01510 mycase = caseoffset + 19
01511 myspwids = [0,1,2]
01512 mynchan = 6
01513 mystart = 1
01514 mywidth = 1
01515 myexpectation = [1,2,3,4,5,6]
01516
01517 testit()
01518
01519
01520 mycase = caseoffset + 20
01521 myspwids = [0]
01522 mynchan = -1
01523 mystart = 2
01524
01525 mywidth = 1
01526 myexpectation = [2,3,4,5,6,7,8,9,10]
01527
01528 if(isDesc):
01529 myexpectation.reverse()
01530 testit()
01531
01532
01533 mycase = caseoffset + 21
01534 myspwids = [0]
01535 mynchan = 10
01536 mystart = 2
01537
01538 mywidth = 1
01539 myexpectation = [2,3,4,5,6,7,8,9,10,11]
01540
01541 if(isDesc):
01542 myexpectation.reverse()
01543 testit()
01544
01545
01546 mycase = caseoffset + 22
01547 myspwids = [0]
01548 mynchan = 3
01549 mystart = 2
01550
01551 mywidth = 2
01552 myexpectation = [2,4,6]
01553
01554 if(isDesc):
01555 myexpectation.reverse()
01556 testit()
01557
01558
01559
01560
01561 def testvradmode(caseoffset, isDesc):
01562 global mymode, mycase, myspwids, mynchan, mystart, mywidth, myveltype, myrestfrq, myexpectation, mytotal, myfailures
01563 global tests_to_do, failed
01564
01565
01566
01567 myrestfrq = (1E10 + 10.) / (1 - (-1000./299792458.0))
01568
01569
01570 mymode = 'velocity'
01571 myveltype = 'radio'
01572
01573
01574 mystart = "-1000m/s"
01575 mywidth = "-1m/s"
01576
01577
01578 mycase = caseoffset + 0
01579 myspwids = [0]
01580 mynchan = -1
01581
01582 myexpectation = [-1000,-1001,-1002,-1003,-1004,-1005,-1006,-1007,-1008,-1009]
01583
01584 if(isDesc):
01585 myexpectation.reverse()
01586
01587 testitc()
01588
01589
01590 mycase = caseoffset + 1
01591 myspwids = [0]
01592 mynchan = 10
01593
01594 myexpectation = [-1000,-1001,-1002,-1003,-1004,-1005,-1006,-1007,-1008,-1009]
01595
01596 if(isDesc):
01597 myexpectation.reverse()
01598
01599 testitc()
01600
01601
01602 mycase = caseoffset + 2
01603 myspwids = [0]
01604 mynchan = 5
01605
01606 myexpectation = [-1000,-1001,-1002,-1003,-1004]
01607
01608 if(isDesc):
01609 myexpectation.reverse()
01610
01611 testitc()
01612
01613
01614 mycase = caseoffset + 3
01615 myspwids = [0]
01616 mynchan = 6
01617
01618 myexpectation = [-1000,-1001,-1002,-1003,-1004,-1005]
01619
01620 if(isDesc):
01621 myexpectation.reverse()
01622
01623 testitc()
01624
01625
01626
01627 mycase = caseoffset + 4
01628 myspwids = [1]
01629 mynchan = -1
01630 mystart = "-1010m/s"
01631
01632 myexpectation = [-1010,-1011,-1012,-1013,-1014,-1015,-1016,-1017,-1018,-1019]
01633 if(isDesc):
01634 myexpectation.reverse()
01635
01636 testitc()
01637
01638
01639 mycase = caseoffset + 5
01640 myspwids = [1]
01641 mynchan = 10
01642
01643 myexpectation = [-1010,-1011,-1012,-1013,-1014,-1015,-1016,-1017,-1018,-1019]
01644 if(isDesc):
01645 myexpectation.reverse()
01646
01647 testitc()
01648
01649
01650 mycase = caseoffset + 6
01651 myspwids = [1]
01652 mynchan = 5
01653
01654 myexpectation = [-1010,-1011,-1012,-1013,-1014]
01655 if(isDesc):
01656 myexpectation.reverse()
01657
01658 testitc()
01659
01660
01661 mycase = caseoffset + 7
01662 myspwids = [1]
01663 mynchan = 6
01664
01665 myexpectation = [-1010,-1011,-1012,-1013,-1014,-1015]
01666 if(isDesc):
01667 myexpectation.reverse()
01668
01669 testitc()
01670
01671
01672 mycase = caseoffset + 8
01673 myspwids = [0,1]
01674 mynchan = -1
01675 mystart = "-1000m/s"
01676
01677 myexpectation = range(-1000,-1020,-1)
01678
01679 testitc()
01680
01681
01682 mycase = caseoffset + 9
01683 myspwids = [0,1]
01684 mynchan = 10
01685
01686 myexpectation = [-1000,-1001,-1002,-1003,-1004,-1005,-1006,-1007,-1008,-1009]
01687
01688 testitc()
01689
01690
01691 mycase = caseoffset + 10
01692 myspwids = [0,1]
01693 mynchan = 5
01694
01695 myexpectation = [-1000,-1001,-1002,-1003,-1004]
01696
01697 testitc()
01698
01699
01700 mycase = caseoffset + 11
01701 myspwids = [0,1]
01702 mynchan = 6
01703 mystart = "-1009m/s"
01704
01705 myexpectation = [-1009,-1010,-1011,-1012,-1013,-1014]
01706
01707 testitc()
01708
01709
01710
01711 mycase = caseoffset + 12
01712 myspwids = [1,2]
01713 mynchan = -1
01714 mystart = "-1010m/s"
01715
01716 myexpectation = range(-1010,-1030,-1)
01717
01718 testitc()
01719
01720
01721 mycase = caseoffset + 13
01722 myspwids = [1,2]
01723 mynchan = 10
01724 mystart = "-1010m/s"
01725
01726 myexpectation = [-1010,-1011,-1012,-1013,-1014,-1015,-1016,-1017,-1018,-1019]
01727
01728 testitc()
01729
01730
01731 mycase = caseoffset + 14
01732 myspwids = [1,2]
01733 mynchan = 5
01734 mystart = "-1010m/s"
01735
01736
01737 myexpectation = [-1010,-1011,-1012,-1013,-1014]
01738
01739 testitc()
01740
01741
01742 mycase = caseoffset + 15
01743 myspwids = [1,2]
01744 mynchan = 6
01745 mystart = "-1010m/s"
01746
01747 myexpectation = [-1010,-1011,-1012,-1013,-1014,-1015]
01748
01749 testitc()
01750
01751
01752 mycase = caseoffset + 16
01753 myspwids = [0,1,2]
01754 mynchan = -1
01755 mystart = "-1000m/s"
01756
01757 myexpectation = range(-1000,-1030,-1)
01758
01759 testitc()
01760
01761
01762 mycase = caseoffset + 17
01763 myspwids = [0,1,2]
01764 mynchan = 10
01765 mystart = "-1000m/s"
01766
01767 myexpectation = range(-1000,-1010,-1)
01768
01769 testitc()
01770
01771
01772 mycase = caseoffset + 18
01773 myspwids = [0,1,2]
01774 mynchan = 5
01775 mystart = "-1020m/s"
01776
01777 myexpectation = [-1020,-1021,-1022,-1023,-1024]
01778
01779 testitc()
01780
01781
01782 mycase = caseoffset + 19
01783 myspwids = [0,1,2]
01784 mynchan = 6
01785 mystart = "-1005m/s"
01786 mywidth = "1m/s"
01787
01788 myexpectation = [-1000,-1001,-1002,-1003,-1004,-1005]
01789
01790 testitc()
01791
01792
01793 mycase = caseoffset + 20
01794 myspwids = [0,1,2]
01795 mynchan = 6
01796 mystart = "-1018m/s"
01797 mywidth = "2m/s"
01798
01799 myexpectation = [-1008,-1010,-1012,-1014,-1016,-1018]
01800
01801 testitc()
01802
01803
01804 mystart = "-1004m/s"
01805 mywidth = ""
01806
01807
01808 mycase = caseoffset + 21
01809 myspwids = [0]
01810 mynchan = 5
01811
01812 myexpectation = [-1000,-1001,-1002,-1003,-1004]
01813
01814 if(isDesc):
01815 myexpectation.reverse()
01816
01817 testitc()
01818
01819
01820
01821
01822
01823 class cvelfreqs_test(unittest.TestCase):
01824
01825 def setUp(self):
01826
01827
01828
01829
01830 if(not os.path.exists('test_uvcontsub2.ms')):
01831 print "Copying test data ..."
01832 os.system('cp -R '+os.environ['CASAPATH'].split()[0]+'/data/regression/unittest/cvel/test_uvcontsub2.ms .')
01833
01834 def tearDown(self):
01835 os.system('rm -rf sample.ms sample2.ms sample3.ms sample4.ms sampler.ms')
01836 pass
01837
01838 def test1(self):
01839
01840 '''cvelfreqs 1: test ascending frequencies, channel mode'''
01841
01842 global mytotal, myfailures, tests_to_do, failed
01843
01844 os.system('rm -rf sample.ms')
01845 shutil.copytree('test_uvcontsub2.ms','sample.ms')
01846 tb.open('sample.ms/SPECTRAL_WINDOW', nomodify=False)
01847
01848 spwid = 0
01849 newnumchan = 10
01850 newchanfreq = range(1,newnumchan+1)
01851 cw = newchanfreq[1] - newchanfreq[0]
01852 newchanwidth = []
01853 for i in range(0,newnumchan):
01854 newchanwidth.append(cw)
01855
01856 print spwid,': ', newchanfreq
01857 print ' ', newchanwidth
01858
01859 tb.putcell('NUM_CHAN', spwid, newnumchan)
01860 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
01861 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
01862 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
01863 tb.putcell('RESOLUTION', spwid, newchanwidth)
01864 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
01865 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
01866
01867
01868 spwid = 1
01869 newnumchan = 10
01870 newchanfreq = range(10,newnumchan+1+9)
01871 cw = newchanfreq[1] - newchanfreq[0]
01872 newchanwidth = []
01873 for i in range(0,newnumchan):
01874 newchanwidth.append(cw)
01875
01876 print spwid,': ', newchanfreq
01877 print ' ', newchanwidth
01878
01879 tb.putcell('NUM_CHAN', spwid, newnumchan)
01880 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
01881 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
01882 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
01883 tb.putcell('RESOLUTION', spwid, newchanwidth)
01884 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
01885 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
01886
01887
01888 spwid = 2
01889 newnumchan = 10
01890 newchanfreq = range(19,newnumchan+1+18)
01891 cw = newchanfreq[1] - newchanfreq[0]
01892 newchanwidth = []
01893 for i in range(0,newnumchan):
01894 newchanwidth.append(cw)
01895
01896 print spwid,': ', newchanfreq
01897 print ' ', newchanwidth
01898
01899 tb.putcell('NUM_CHAN', spwid, newnumchan)
01900 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
01901 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
01902 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
01903 tb.putcell('RESOLUTION', spwid, newchanwidth)
01904 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
01905 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
01906
01907 tb.close()
01908
01909
01910
01911 ms.open('sample.ms')
01912
01913 mytotal = 0
01914 myfailures = 0
01915 failed = []
01916
01917 testchannelmode(0,False)
01918
01919 ms.close()
01920
01921 print myfailures, " failures in ", mytotal, " subtests."
01922 if(myfailures>0):
01923 print "Failed cases: ", failed
01924
01925 self.assertEqual(myfailures,0)
01926
01927 def test2(self):
01928
01929 '''cvelfreqs 2: test descending frequencies, channel mode'''
01930
01931 global mytotal, myfailures, tests_to_do, failed
01932
01933 os.system('rm -rf sample-desc.ms')
01934 shutil.copytree('test_uvcontsub2.ms','sample-desc.ms')
01935 tb.open('sample-desc.ms/SPECTRAL_WINDOW', nomodify=False)
01936
01937 spwid = 0
01938 newnumchan = 10
01939 newchanfreq = range(newnumchan,0,-1)
01940 cw = newchanfreq[1] - newchanfreq[0]
01941 newchanwidth = []
01942 newabschanwidth = []
01943 for i in range(0,newnumchan):
01944 newchanwidth.append(cw)
01945 newabschanwidth.append(cw)
01946
01947 print spwid,': ', newchanfreq
01948 print ' ', newchanwidth
01949
01950 tb.putcell('NUM_CHAN', spwid, newnumchan)
01951 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
01952 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
01953 tb.putcell('EFFECTIVE_BW', spwid, newabschanwidth)
01954 tb.putcell('RESOLUTION', spwid, newabschanwidth)
01955 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
01956 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
01957
01958
01959 spwid = 1
01960 newnumchan = 10
01961 newchanfreq = range(newnumchan+9,9,-1)
01962 cw = newchanfreq[1] - newchanfreq[0]
01963 newchanwidth = []
01964 newabschanwidth = []
01965 for i in range(0,newnumchan):
01966 newchanwidth.append(cw)
01967 newabschanwidth.append(cw)
01968
01969 print spwid,': ', newchanfreq
01970 print ' ', newchanwidth
01971
01972 tb.putcell('NUM_CHAN', spwid, newnumchan)
01973 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
01974 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
01975 tb.putcell('EFFECTIVE_BW', spwid, newabschanwidth)
01976 tb.putcell('RESOLUTION', spwid, newabschanwidth)
01977 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
01978 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
01979
01980
01981 spwid = 2
01982 newnumchan = 10
01983 newchanfreq = range(newnumchan+18,18,-1)
01984 cw = newchanfreq[1] - newchanfreq[0]
01985 newchanwidth = []
01986 newabschanwidth = []
01987 for i in range(0,newnumchan):
01988 newchanwidth.append(cw)
01989 newabschanwidth.append(cw)
01990
01991 print spwid,': ', newchanfreq
01992 print ' ', newchanwidth
01993
01994 tb.putcell('NUM_CHAN', spwid, newnumchan)
01995 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
01996 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
01997 tb.putcell('EFFECTIVE_BW', spwid, newabschanwidth)
01998 tb.putcell('RESOLUTION', spwid, newabschanwidth)
01999 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02000 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02001
02002 tb.close()
02003
02004
02005
02006 ms.open('sample-desc.ms')
02007
02008 mytotal = 0
02009 myfailures = 0
02010 failed = []
02011
02012 testchannelmode(1000, True)
02013
02014 ms.close()
02015
02016 print myfailures, " failures in ", mytotal, " subtests."
02017 if(myfailures>0):
02018 print "Failed cases: ", failed
02019
02020 self.assertEqual(myfailures,0)
02021
02022 def test3(self):
02023
02024 '''cvelfreqs 3: test ascending frequencies, optical velocity mode'''
02025
02026 global mytotal, myfailures, tests_to_do, failed
02027
02028 os.system('rm -rf sample3.ms')
02029 shutil.copytree('test_uvcontsub2.ms','sample3.ms')
02030 tb.open('sample3.ms/SPECTRAL_WINDOW', nomodify=False)
02031
02032 spwid = 0
02033 newnumchan = 11
02034 newchanfreq = []
02035 cw = 33.
02036 newchanwidth = []
02037 for i in range(0,newnumchan):
02038 newchanfreq.append(1E10+i*cw)
02039 newchanwidth.append(cw)
02040
02041 print spwid,': ', newchanfreq
02042 print ' ', newchanwidth
02043
02044 tb.putcell('NUM_CHAN', spwid, newnumchan)
02045 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02046 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02047 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02048 tb.putcell('RESOLUTION', spwid, newchanwidth)
02049 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02050 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02051
02052 lastfreq = newchanfreq[newnumchan-1]
02053
02054
02055 spwid = 1
02056 newnumchan = 11
02057 newchanfreq = []
02058 cw = 33.
02059 newchanwidth = []
02060 for i in range(0,newnumchan):
02061 newchanfreq.append(lastfreq+i*cw)
02062 newchanwidth.append(cw)
02063
02064 print spwid,': ', newchanfreq
02065 print ' ', newchanwidth
02066
02067 tb.putcell('NUM_CHAN', spwid, newnumchan)
02068 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02069 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02070 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02071 tb.putcell('RESOLUTION', spwid, newchanwidth)
02072 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02073 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02074
02075 lastfreq = newchanfreq[newnumchan-1]
02076
02077
02078 spwid = 2
02079 newnumchan = 11
02080 newchanfreq = []
02081 cw = 33.
02082 newchanwidth = []
02083 for i in range(0,newnumchan):
02084 newchanfreq.append(lastfreq+i*cw)
02085 newchanwidth.append(cw)
02086
02087 print spwid,': ', newchanfreq
02088 print ' ', newchanwidth
02089
02090 tb.putcell('NUM_CHAN', spwid, newnumchan)
02091 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02092 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02093 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02094 tb.putcell('RESOLUTION', spwid, newchanwidth)
02095 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02096 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02097
02098 tb.close()
02099
02100
02101
02102 ms.open('sample3.ms')
02103
02104 mytotal = 0
02105 myfailures = 0
02106 failed = []
02107
02108 testvoptmode(2000,False)
02109
02110 ms.close()
02111
02112 print myfailures, " failures in ", mytotal, " subtests."
02113 if(myfailures>0):
02114 print "Failed cases: ", failed
02115
02116 self.assertEqual(myfailures,0)
02117
02118 def test4(self):
02119
02120 '''cvelfreqs 4: test descending frequencies, optical velocity mode'''
02121
02122 global mytotal, myfailures, tests_to_do, failed
02123
02124 os.system('rm -rf sample4.ms')
02125 shutil.copytree('test_uvcontsub2.ms','sample4.ms')
02126 tb.open('sample4.ms/SPECTRAL_WINDOW', nomodify=False)
02127
02128 spwid = 0
02129 newnumchan = 11
02130 newchanfreq = []
02131 cw = 33.
02132 newchanwidth = []
02133 for i in range(0,newnumchan):
02134 newchanfreq.append(1E10+i*cw)
02135 newchanwidth.append(-cw)
02136
02137 newchanfreq.reverse()
02138
02139 print spwid,': ', newchanfreq
02140 print ' ', newchanwidth
02141
02142 tb.putcell('NUM_CHAN', spwid, newnumchan)
02143 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02144 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02145 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02146 tb.putcell('RESOLUTION', spwid, newchanwidth)
02147 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02148 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02149
02150 lastfreq = newchanfreq[0]
02151
02152
02153 spwid = 1
02154 newnumchan = 11
02155 newchanfreq = []
02156 cw = 33.
02157 newchanwidth = []
02158 for i in range(0,newnumchan):
02159 newchanfreq.append(lastfreq+i*cw)
02160 newchanwidth.append(-cw)
02161
02162 newchanfreq.reverse()
02163
02164 print spwid,': ', newchanfreq
02165 print ' ', newchanwidth
02166
02167 tb.putcell('NUM_CHAN', spwid, newnumchan)
02168 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02169 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02170 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02171 tb.putcell('RESOLUTION', spwid, newchanwidth)
02172 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02173 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02174
02175 lastfreq = newchanfreq[0]
02176
02177
02178 spwid = 2
02179 newnumchan = 11
02180 newchanfreq = []
02181 cw = 33.
02182 newchanwidth = []
02183 for i in range(0,newnumchan):
02184 newchanfreq.append(lastfreq+i*cw)
02185 newchanwidth.append(-cw)
02186
02187 newchanfreq.reverse()
02188
02189 print spwid,': ', newchanfreq
02190 print ' ', newchanwidth
02191
02192 tb.putcell('NUM_CHAN', spwid, newnumchan)
02193 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02194 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02195 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02196 tb.putcell('RESOLUTION', spwid, newchanwidth)
02197 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02198 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02199
02200 tb.close()
02201
02202
02203
02204 ms.open('sample4.ms')
02205
02206 mytotal = 0
02207 myfailures = 0
02208 failed = []
02209
02210 testvoptmode(3000,True)
02211
02212 ms.close()
02213
02214 print myfailures, " failures in ", mytotal, " subtests."
02215 if(myfailures>0):
02216 print "Failed cases: ", failed
02217
02218 self.assertEqual(myfailures,0)
02219
02220
02221 def test5(self):
02222
02223 '''cvelfreqs 5: test ascending frequencies, frequency mode'''
02224
02225 global mytotal, myfailures, tests_to_do, failed
02226
02227 os.system('rm -rf sample.ms')
02228 shutil.copytree('test_uvcontsub2.ms','sample.ms')
02229 tb.open('sample.ms/SPECTRAL_WINDOW', nomodify=False)
02230
02231 spwid = 0
02232 newnumchan = 10
02233 newchanfreq = range(1,newnumchan+1)
02234 cw = newchanfreq[1] - newchanfreq[0]
02235 newchanwidth = []
02236 for i in range(0,newnumchan):
02237 newchanwidth.append(cw)
02238
02239 print spwid,': ', newchanfreq
02240 print ' ', newchanwidth
02241
02242 tb.putcell('NUM_CHAN', spwid, newnumchan)
02243 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02244 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02245 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02246 tb.putcell('RESOLUTION', spwid, newchanwidth)
02247 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02248 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02249
02250
02251 spwid = 1
02252 newnumchan = 10
02253 newchanfreq = range(10,newnumchan+1+9)
02254 cw = newchanfreq[1] - newchanfreq[0]
02255 newchanwidth = []
02256 for i in range(0,newnumchan):
02257 newchanwidth.append(cw)
02258
02259 print spwid,': ', newchanfreq
02260 print ' ', newchanwidth
02261
02262 tb.putcell('NUM_CHAN', spwid, newnumchan)
02263 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02264 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02265 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02266 tb.putcell('RESOLUTION', spwid, newchanwidth)
02267 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02268 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02269
02270
02271 spwid = 2
02272 newnumchan = 10
02273 newchanfreq = range(19,newnumchan+1+18)
02274 cw = newchanfreq[1] - newchanfreq[0]
02275 newchanwidth = []
02276 for i in range(0,newnumchan):
02277 newchanwidth.append(cw)
02278
02279 print spwid,': ', newchanfreq
02280 print ' ', newchanwidth
02281
02282 tb.putcell('NUM_CHAN', spwid, newnumchan)
02283 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02284 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02285 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02286 tb.putcell('RESOLUTION', spwid, newchanwidth)
02287 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02288 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02289
02290 tb.close()
02291
02292
02293
02294 ms.open('sample.ms')
02295
02296 mytotal = 0
02297 myfailures = 0
02298 failed = []
02299
02300 testfreqmode(4000,False)
02301
02302 ms.close()
02303
02304 print myfailures, " failures in ", mytotal, " subtests."
02305 if(myfailures>0):
02306 print "Failed cases: ", failed
02307
02308 self.assertEqual(myfailures,0)
02309
02310 def test6(self):
02311
02312 '''cvelfreqs 6: test descending frequencies, frequency mode'''
02313
02314 global mytotal, myfailures, tests_to_do, failed
02315
02316 os.system('rm -rf sample-desc.ms')
02317 shutil.copytree('test_uvcontsub2.ms','sample-desc.ms')
02318 tb.open('sample-desc.ms/SPECTRAL_WINDOW', nomodify=False)
02319
02320 spwid = 0
02321 newnumchan = 10
02322 newchanfreq = range(newnumchan,0,-1)
02323 cw = newchanfreq[1] - newchanfreq[0]
02324 newchanwidth = []
02325 newabschanwidth = []
02326 for i in range(0,newnumchan):
02327 newchanwidth.append(cw)
02328 newabschanwidth.append(cw)
02329
02330 print spwid,': ', newchanfreq
02331 print ' ', newchanwidth
02332
02333 tb.putcell('NUM_CHAN', spwid, newnumchan)
02334 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02335 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02336 tb.putcell('EFFECTIVE_BW', spwid, newabschanwidth)
02337 tb.putcell('RESOLUTION', spwid, newabschanwidth)
02338 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02339 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02340
02341
02342 spwid = 1
02343 newnumchan = 10
02344 newchanfreq = range(newnumchan+9,9,-1)
02345 cw = newchanfreq[1] - newchanfreq[0]
02346 newchanwidth = []
02347 newabschanwidth = []
02348 for i in range(0,newnumchan):
02349 newchanwidth.append(cw)
02350 newabschanwidth.append(cw)
02351
02352 print spwid,': ', newchanfreq
02353 print ' ', newchanwidth
02354
02355 tb.putcell('NUM_CHAN', spwid, newnumchan)
02356 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02357 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02358 tb.putcell('EFFECTIVE_BW', spwid, newabschanwidth)
02359 tb.putcell('RESOLUTION', spwid, newabschanwidth)
02360 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02361 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02362
02363
02364 spwid = 2
02365 newnumchan = 10
02366 newchanfreq = range(newnumchan+18,18,-1)
02367 cw = newchanfreq[1] - newchanfreq[0]
02368 newchanwidth = []
02369 newabschanwidth = []
02370 for i in range(0,newnumchan):
02371 newchanwidth.append(cw)
02372 newabschanwidth.append(cw)
02373
02374 print spwid,': ', newchanfreq
02375 print ' ', newchanwidth
02376
02377 tb.putcell('NUM_CHAN', spwid, newnumchan)
02378 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02379 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02380 tb.putcell('EFFECTIVE_BW', spwid, newabschanwidth)
02381 tb.putcell('RESOLUTION', spwid, newabschanwidth)
02382 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02383 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02384
02385 tb.close()
02386
02387
02388
02389 ms.open('sample-desc.ms')
02390
02391 mytotal = 0
02392 myfailures = 0
02393 failed = []
02394
02395 testfreqmode(5000, True)
02396
02397 ms.close()
02398
02399 print myfailures, " failures in ", mytotal, " subtests."
02400 if(myfailures>0):
02401 print "Failed cases: ", failed
02402
02403 self.assertEqual(myfailures,0)
02404
02405 def test7(self):
02406
02407 '''cvelfreqs 7: test ascending frequencies, radio velocity mode'''
02408
02409 global mytotal, myfailures, tests_to_do, failed
02410
02411 os.system('rm -rf sample3.ms')
02412 shutil.copytree('test_uvcontsub2.ms','sample3.ms')
02413 tb.open('sample3.ms/SPECTRAL_WINDOW', nomodify=False)
02414
02415 spwid = 0
02416 newnumchan = 11
02417 newchanfreq = []
02418 cw = 33.
02419 newchanwidth = []
02420 for i in range(0,newnumchan):
02421 newchanfreq.append(1E10+i*cw)
02422 newchanwidth.append(cw)
02423
02424 print spwid,': ', newchanfreq
02425 print ' ', newchanwidth
02426
02427 tb.putcell('NUM_CHAN', spwid, newnumchan)
02428 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02429 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02430 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02431 tb.putcell('RESOLUTION', spwid, newchanwidth)
02432 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02433 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02434
02435 lastfreq = newchanfreq[newnumchan-1]
02436
02437
02438 spwid = 1
02439 newnumchan = 11
02440 newchanfreq = []
02441 cw = 33.
02442 newchanwidth = []
02443 for i in range(0,newnumchan):
02444 newchanfreq.append(lastfreq+i*cw)
02445 newchanwidth.append(cw)
02446
02447 print spwid,': ', newchanfreq
02448 print ' ', newchanwidth
02449
02450 tb.putcell('NUM_CHAN', spwid, newnumchan)
02451 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02452 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02453 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02454 tb.putcell('RESOLUTION', spwid, newchanwidth)
02455 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02456 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02457
02458 lastfreq = newchanfreq[newnumchan-1]
02459
02460
02461 spwid = 2
02462 newnumchan = 11
02463 newchanfreq = []
02464 cw = 33.
02465 newchanwidth = []
02466 for i in range(0,newnumchan):
02467 newchanfreq.append(lastfreq+i*cw)
02468 newchanwidth.append(cw)
02469
02470 print spwid,': ', newchanfreq
02471 print ' ', newchanwidth
02472
02473 tb.putcell('NUM_CHAN', spwid, newnumchan)
02474 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02475 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02476 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02477 tb.putcell('RESOLUTION', spwid, newchanwidth)
02478 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02479 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02480
02481 tb.close()
02482
02483
02484
02485 ms.open('sample3.ms')
02486
02487 mytotal = 0
02488 myfailures = 0
02489 failed = []
02490
02491 testvradmode(6000,False)
02492
02493 ms.close()
02494
02495 print myfailures, " failures in ", mytotal, " subtests."
02496 if(myfailures>0):
02497 print "Failed cases: ", failed
02498
02499 self.assertEqual(myfailures,0)
02500
02501 def test8(self):
02502
02503 '''cvelfreqs 8: test descending frequencies, radio velocity mode'''
02504
02505 global mytotal, myfailures, tests_to_do, failed
02506
02507 os.system('rm -rf sample4.ms')
02508 shutil.copytree('test_uvcontsub2.ms','sample4.ms')
02509 tb.open('sample4.ms/SPECTRAL_WINDOW', nomodify=False)
02510
02511 spwid = 0
02512 newnumchan = 11
02513 newchanfreq = []
02514 cw = 33.
02515 newchanwidth = []
02516 for i in range(0,newnumchan):
02517 newchanfreq.append(1E10+i*cw)
02518 newchanwidth.append(-cw)
02519
02520 newchanfreq.reverse()
02521
02522 print spwid,': ', newchanfreq
02523 print ' ', newchanwidth
02524
02525 tb.putcell('NUM_CHAN', spwid, newnumchan)
02526 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02527 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02528 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02529 tb.putcell('RESOLUTION', spwid, newchanwidth)
02530 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02531 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02532
02533 lastfreq = newchanfreq[0]
02534
02535
02536 spwid = 1
02537 newnumchan = 11
02538 newchanfreq = []
02539 cw = 33.
02540 newchanwidth = []
02541 for i in range(0,newnumchan):
02542 newchanfreq.append(lastfreq+i*cw)
02543 newchanwidth.append(-cw)
02544
02545 newchanfreq.reverse()
02546
02547 print spwid,': ', newchanfreq
02548 print ' ', newchanwidth
02549
02550 tb.putcell('NUM_CHAN', spwid, newnumchan)
02551 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02552 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02553 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02554 tb.putcell('RESOLUTION', spwid, newchanwidth)
02555 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02556 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02557
02558 lastfreq = newchanfreq[0]
02559
02560
02561 spwid = 2
02562 newnumchan = 11
02563 newchanfreq = []
02564 cw = 33.
02565 newchanwidth = []
02566 for i in range(0,newnumchan):
02567 newchanfreq.append(lastfreq+i*cw)
02568 newchanwidth.append(-cw)
02569
02570 newchanfreq.reverse()
02571
02572 print spwid,': ', newchanfreq
02573 print ' ', newchanwidth
02574
02575 tb.putcell('NUM_CHAN', spwid, newnumchan)
02576 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02577 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02578 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02579 tb.putcell('RESOLUTION', spwid, newchanwidth)
02580 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02581 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02582
02583 tb.close()
02584
02585
02586
02587 ms.open('sample4.ms')
02588
02589 mytotal = 0
02590 myfailures = 0
02591 failed = []
02592
02593 testvradmode(7000,True)
02594
02595 ms.close()
02596
02597 print myfailures, " failures in ", mytotal, " subtests."
02598 if(myfailures>0):
02599 print "Failed cases: ", failed
02600
02601 self.assertEqual(myfailures,0)
02602
02603 def test9(self):
02604
02605 '''cvelfreqs 9: test reproducibility'''
02606
02607 global mytotal, myfailures, tests_to_do, failed
02608
02609 os.system('rm -rf sampler.ms')
02610 shutil.copytree('test_uvcontsub2.ms','sampler.ms')
02611
02612 tb.open('sampler.ms/SPECTRAL_WINDOW', nomodify=False)
02613
02614 spwid = 0
02615 newnumchan = 11
02616 newchanfreq = []
02617 cw = 33.
02618 newchanwidth = []
02619 for i in range(0,newnumchan):
02620 newchanfreq.append(1E10+i*cw)
02621 newchanwidth.append(cw)
02622
02623 print spwid,': ', newchanfreq
02624 print ' ', newchanwidth
02625
02626 tb.putcell('NUM_CHAN', spwid, newnumchan)
02627 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02628 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02629 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02630 tb.putcell('RESOLUTION', spwid, newchanwidth)
02631 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02632 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02633
02634 lastfreq = newchanfreq[newnumchan-1]
02635
02636
02637 spwid = 1
02638 newnumchan = 11
02639 newchanfreq = []
02640 cw = 33.
02641 newchanwidth = []
02642 for i in range(0,newnumchan):
02643 newchanfreq.append(lastfreq-cw/2.+i*cw)
02644 newchanwidth.append(cw)
02645
02646 print spwid,': ', newchanfreq
02647 print ' ', newchanwidth
02648
02649 tb.putcell('NUM_CHAN', spwid, newnumchan)
02650 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02651 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02652 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02653 tb.putcell('RESOLUTION', spwid, newchanwidth)
02654 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02655 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02656
02657 lastfreq = newchanfreq[newnumchan-1]
02658
02659
02660 spwid = 2
02661 newnumchan = 11
02662 newchanfreq = []
02663 cw = 33.
02664 newchanwidth = []
02665 for i in range(0,newnumchan):
02666 newchanfreq.append(lastfreq - 0.3*cw +i*cw)
02667 newchanwidth.append(cw)
02668
02669 print spwid,': ', newchanfreq
02670 print ' ', newchanwidth
02671
02672 tb.putcell('NUM_CHAN', spwid, newnumchan)
02673 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02674 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02675 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02676 tb.putcell('RESOLUTION', spwid, newchanwidth)
02677 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02678 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]))
02679
02680 tb.close()
02681
02682
02683
02684 ms.open('sampler.ms')
02685
02686 channelfreqs = ms.cvelfreqs(mode='channel', spwids=[0,1,2], start=1, width=2, nchan=10)
02687 channelfreqs = list(channelfreqs)
02688 print "channel freqs ", channelfreqs
02689 frequencyfreqs = ms.cvelfreqs(mode='frequency', spwids=[0,1,2], start=str(1E9+60)+'Hz', width='100Hz', nchan=10)
02690 frequencyfreqs = list(frequencyfreqs)
02691 print "frequency freqs ", frequencyfreqs
02692 restfrqo = (-1000./299792458.0 + 1.) * (1E10 + 10.)
02693 opticalfreqs = ms.cvelfreqs(mode='velocity', veltype='optical', spwids=[0,1,2], start="-1001m/s", width='-2m/s', nchan=10, restfreq=restfrqo)
02694 opticalfreqs = list(opticalfreqs)
02695 print "optical freqs ", opticalfreqs
02696 restfrqr = (1E10 + 10.) / (1 - (-1000./299792458.0))
02697 radiofreqs = ms.cvelfreqs(mode='velocity', veltype='radio', spwids=[0,1,2], start="-1001m/s", width='-2m/s', nchan=10, restfreq=restfrqr)
02698 radiofreqs = list(radiofreqs)
02699 print "radio freqs ", radiofreqs
02700
02701 ms.close()
02702
02703 tb.open('sampler.ms/SPECTRAL_WINDOW', nomodify=False)
02704
02705 spwid = 3
02706 newnumchan = 10
02707 newchanfreq = channelfreqs
02708 newchanwidth = []
02709 for i in range(0,newnumchan-1):
02710 newchanwidth.append(newchanfreq[i+1]-newchanfreq[i])
02711 newchanwidth.append(newchanfreq[newnumchan-1]-newchanfreq[newnumchan-2])
02712
02713 print spwid,': ', newchanfreq
02714 print ' ', newchanwidth
02715
02716 tb.putcell('NUM_CHAN', spwid, newnumchan)
02717 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02718 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02719 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02720 tb.putcell('RESOLUTION', spwid, newchanwidth)
02721 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02722 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]/2.)+abs(newchanwidth[-1]/2.))
02723
02724
02725 spwid = 4
02726 newnumchan = 10
02727 newchanfreq = frequencyfreqs
02728 newchanwidth = []
02729 for i in range(0,newnumchan-1):
02730 newchanwidth.append(newchanfreq[i+1]-newchanfreq[i])
02731 newchanwidth.append(newchanfreq[newnumchan-1]-newchanfreq[newnumchan-2])
02732
02733 print spwid,': ', newchanfreq
02734 print ' ', newchanwidth
02735
02736 tb.putcell('NUM_CHAN', spwid, newnumchan)
02737 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02738 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02739 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02740 tb.putcell('RESOLUTION', spwid, newchanwidth)
02741 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02742 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]/2.)+abs(newchanwidth[-1]/2.))
02743
02744
02745 spwid = 5
02746 newnumchan = 10
02747 newchanfreq = opticalfreqs
02748 newchanwidth = []
02749 for i in range(0,newnumchan-1):
02750 newchanwidth.append(newchanfreq[i+1]-newchanfreq[i])
02751 newchanwidth.append(newchanfreq[newnumchan-1]-newchanfreq[newnumchan-2])
02752
02753 print spwid,': ', newchanfreq
02754 print ' ', newchanwidth
02755
02756 tb.putcell('NUM_CHAN', spwid, newnumchan)
02757 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02758 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02759 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02760 tb.putcell('RESOLUTION', spwid, newchanwidth)
02761 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02762 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]/2.)+abs(newchanwidth[-1]/2.))
02763
02764
02765 spwid = 6
02766 newnumchan = 10
02767 newchanfreq = radiofreqs
02768 newchanwidth = []
02769 for i in range(0,newnumchan-1):
02770 newchanwidth.append(newchanfreq[i+1]-newchanfreq[i])
02771 newchanwidth.append(newchanfreq[newnumchan-1]-newchanfreq[newnumchan-2])
02772
02773 print spwid,': ', newchanfreq
02774 print ' ', newchanwidth
02775
02776 tb.putcell('NUM_CHAN', spwid, newnumchan)
02777 tb.putcell('CHAN_FREQ', spwid, newchanfreq)
02778 tb.putcell('CHAN_WIDTH', spwid, newchanwidth)
02779 tb.putcell('EFFECTIVE_BW', spwid, newchanwidth)
02780 tb.putcell('RESOLUTION', spwid, newchanwidth)
02781 tb.putcell('REF_FREQUENCY', spwid, newchanfreq[0])
02782 tb.putcell('TOTAL_BANDWIDTH', spwid, abs(newchanfreq[-1]-newchanfreq[0])+abs(newchanwidth[0]/2.)+abs(newchanwidth[-1]/2.))
02783
02784 tb.close()
02785
02786
02787
02788 ms.open('sampler.ms')
02789
02790 mytotal = 0
02791 myfailures = 0
02792
02793 newchannelfreqs = ms.cvelfreqs(mode='channel', spwids=[3])
02794 newchannelfreqs = list(newchannelfreqs)
02795
02796 newfrequencyfreqs = ms.cvelfreqs(mode='frequency', spwids=[4], start=str(1E9+60)+'Hz', width='100Hz', nchan=10)
02797 newfrequencyfreqs = list(newfrequencyfreqs)
02798
02799 newopticalfreqs = ms.cvelfreqs(mode='velocity', veltype='optical', spwids=[5], start="-1001m/s", width='-2m/s', nchan=10, restfreq=restfrqo)
02800 newopticalfreqs = list(newopticalfreqs)
02801 newradiofreqs = ms.cvelfreqs(mode='velocity', veltype='radio', spwids=[6], start="-1001m/s", width='-2m/s', nchan=10, restfreq=restfrqr)
02802 newradiofreqs = list(newradiofreqs)
02803
02804 ms.close()
02805
02806 if not (newchannelfreqs == channelfreqs):
02807 print "channel output deviates: "
02808 print newchannelfreqs
02809 print " expected was:"
02810 print channelfreqs
02811 myfailures = myfailures + 1
02812 mytotal = mytotal + 1
02813 if not (newfrequencyfreqs == frequencyfreqs):
02814 print "frequency output deviates: "
02815 print newfrequencyfreqs
02816 print " expected was:"
02817 print frequencyfreqs
02818 myfailures = myfailures + 1
02819 mytotal = mytotal + 1
02820 if not (newopticalfreqs == opticalfreqs):
02821 print "optical output deviates: "
02822 print newopticalfreqs
02823 print " expected was:"
02824 print opticalfreqs
02825 myfailures = myfailures + 1
02826 mytotal = mytotal + 1
02827 if not (newradiofreqs == radiofreqs):
02828 print "radio output deviates: "
02829 print newradiofreqs
02830 print " expected was:"
02831 print radiofreqs
02832 myfailures = myfailures + 1
02833 mytotal = mytotal + 1
02834
02835 print myfailures, " failures in ", mytotal, " subtests."
02836
02837 self.assertEqual(myfailures,0)
02838
02839
02840
02841 class cleanup(unittest.TestCase):
02842 def setUp(self):
02843 pass
02844
02845 def tearDown(self):
02846
02847 shutil.rmtree('test_uvcontsub2.ms',ignore_errors=True)
02848
02849 def test_cleanup(self):
02850 '''Cvelfreqs: Cleanup'''
02851 pass
02852
02853
02854 def suite():
02855 return [cvelfreqs_test,cleanup]