00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 import shutil
00070 import casac
00071 from tasks import *
00072 from taskinit import *
00073 from __main__ import *
00074 import unittest
00075 import numpy
00076
00077 fixture = os.environ.get('CASAPATH').split()[0]+'/data/regression/unittest/MSMetaData/MSMetaData.ms'
00078
00079 class msmd_test(unittest.TestCase):
00080
00081 def setUp(self):
00082 self.md = msmdtool()
00083 self.md.open(fixture)
00084
00085 def tearDown(self):
00086 self.md.done()
00087
00088 def test_antennaname_and_antennaid(self):
00089 """Test antennaname() and antennaid"""
00090 names = [
00091 "DA43", "DA44", "DV02", "DV03", "DV05",
00092 "DV07", "DV08", "DV10", "DV12", "DV13",
00093 "DV14", "DV15", "DV16", "DV17", "DV18"
00094 ]
00095 for i in range(self.md.nantennas()):
00096 got = self.md.antennaname(i)
00097 self.assertTrue(got == names[i])
00098 got = self.md.antennaid(names[i])
00099 self.assertTrue(got == i)
00100
00101 def test_chanavgspws(self):
00102 """Test chanavgspws()"""
00103 got = self.md.chanavgspws()
00104 expec = numpy.array([
00105 2, 4, 6, 8, 10, 12, 14,
00106 16, 18, 20, 22, 24
00107 ])
00108 self.assertTrue((got == expec).all())
00109
00110
00111 def test_fdmspws(self):
00112 """Test fdmspws()"""
00113 got = self.md.fdmspws()
00114 expec = numpy.array([17, 19, 21, 23])
00115 self.assertTrue((got == expec).all())
00116
00117 def test_fieldsforintent(self):
00118 """Test fieldsforintent()"""
00119 for intent in self.md.intents():
00120 if intent=="CALIBRATE_AMPLI#ON_SOURCE":
00121 expec = numpy.array([2])
00122 elif [
00123 "CALIBRATE_BANDPASS#ON_SOURCE",
00124 "CALIBRATE_SIDEBAND_RATIO#OFF_SOURCE",
00125 "CALIBRATE_SIDEBAND_RATIO#ON_SOURCE"
00126 ].count(intent) > 0:
00127 expec = numpy.array([0])
00128 elif [
00129 "CALIBRATE_ATMOSPHERE#OFF_SOURCE",
00130 "CALIBRATE_ATMOSPHERE#ON_SOURCE",
00131 "CALIBRATE_WVR#OFF_SOURCE"
00132 ].count(intent) > 0:
00133 expec = numpy.array([0, 2, 3, 4, 5])
00134 elif intent=="CALIBRATE_PHASE#ON_SOURCE":
00135 expec = numpy.array([0, 2, 3])
00136 elif intent=="CALIBRATE_POINTING#ON_SOURCE":
00137 expec = numpy.array([0, 1, 3])
00138 elif intent=="CALIBRATE_WVR#ON_SOURCE":
00139 expec = numpy.array([0, 1, 2, 3, 4, 5])
00140 else:
00141 expec = numpy.array([4, 5])
00142 got = self.md.fieldsforintent(intent)
00143 self.assertTrue((got == expec).all())
00144
00145 def test_fieldsforname(self):
00146 """Test fieldforname()"""
00147 names = ["3C279", "J1337-129", "Titan", "J1625-254", "V866 Sco", "RNO 90"]
00148 for i in range(self.md.nfields()):
00149 expec = numpy.array([i])
00150 got = self.md.fieldsforname(names[i])
00151 self.assertTrue((got==expec).all())
00152
00153 def test_fieldsforscan(self):
00154 """Test fieldsforscan() and fieldsforscans()"""
00155 expec2 = numpy.array([], dtype="int")
00156 scans = numpy.array([], dtype="int")
00157 names = numpy.array([
00158 "3C279", "J1337-129", "Titan",
00159 "J1625-254", "V866 Sco", "RNO 90"
00160 ])
00161 for scan in self.md.scannumbers():
00162 if scan <= 4:
00163 expec = numpy.array([0])
00164 elif scan == 5:
00165 expec = numpy.array([1])
00166 elif scan <= 7:
00167 expec = numpy.array([2])
00168 elif [8, 9, 10, 13, 14, 17, 18, 21, 24, 25, 28, 31, 32].count(scan) > 0:
00169 expec = numpy.array([3])
00170 elif [11, 12, 19, 20, 26, 27].count(scan) > 0:
00171 expec = numpy.array([4])
00172 else:
00173 expec = numpy.array([5])
00174 expec2 = numpy.unique(numpy.append(expec2, expec))
00175 got = self.md.fieldsforscan(scan, False)
00176 self.assertTrue((got==expec).all())
00177 got = self.md.fieldsforscan(scan, True)
00178 scans = numpy.append(scans, scan)
00179 self.assertTrue((got==names[expec]).all())
00180 got = self.md.fieldsforscans(scans, False)
00181 self.assertTrue((got==expec2).all())
00182 got = self.md.fieldsforscans(scans, True)
00183 self.assertTrue((got==names[expec2]).all())
00184
00185 def test_fieldsforspw(self):
00186 """Test fieldsforspw()"""
00187 for i in range(self.md.nspw()):
00188 if (i==0):
00189 expids = [0, 1, 2, 3, 4, 5]
00190 expnames = [
00191 "3C279", "J1337-129", "Titan", "J1625-254",
00192 "V866 Sco", "RNO 90"
00193 ]
00194 elif (i<9):
00195 expids = [0, 1, 3]
00196 expnames = ["3C279", "J1337-129", "J1625-254"]
00197 elif (i<25):
00198 expids = [0, 2, 3, 4, 5]
00199 expnames = [
00200 "3C279", "Titan", "J1625-254",
00201 "V866 Sco", "RNO 90"
00202 ]
00203 else:
00204 expids = []
00205 expnames = []
00206 if i < 25:
00207 got = self.md.fieldsforspw(i, false)
00208 self.assertTrue((got == expids).all())
00209 got = self.md.fieldsforspw(i, true)
00210 self.assertTrue((got == expnames).all())
00211 else:
00212 got = self.md.fieldsforspw(i, false)
00213 self.assertTrue(len(got) == 0)
00214 got = self.md.fieldsforspw(i, true)
00215 self.assertTrue(len(got) == 0)
00216
00217 def test_fieldsfortimes(self):
00218 """Test fieldsfortimes()"""
00219 got = self.md.fieldsfortimes(4842824746, 10)
00220 expec = numpy.array([0])
00221 self.assertTrue((got == expec).all())
00222 got = self.md.fieldsfortimes(4842824746, 10000)
00223 expec = numpy.array([0, 1, 2, 3, 4, 5])
00224 self.assertTrue((got == expec).all())
00225
00226 def test_intents(self):
00227 """Test intents()"""
00228 got = self.md.intents()
00229 expec = numpy.array(
00230 [
00231 "CALIBRATE_AMPLI#ON_SOURCE",
00232 "CALIBRATE_ATMOSPHERE#OFF_SOURCE",
00233 "CALIBRATE_ATMOSPHERE#ON_SOURCE",
00234 "CALIBRATE_BANDPASS#ON_SOURCE",
00235 "CALIBRATE_PHASE#ON_SOURCE",
00236 "CALIBRATE_POINTING#ON_SOURCE",
00237 "CALIBRATE_SIDEBAND_RATIO#OFF_SOURCE",
00238 "CALIBRATE_SIDEBAND_RATIO#ON_SOURCE",
00239 "CALIBRATE_WVR#OFF_SOURCE",
00240 "CALIBRATE_WVR#ON_SOURCE",
00241 "OBSERVE_TARGET#ON_SOURCE"
00242 ]
00243 )
00244 self.assertTrue((got == expec).all())
00245
00246 def test_intentsforscan(self):
00247 """Test intentsforscan()"""
00248 for scan in self.md.scannumbers():
00249 got = self.md.intentsforscan(scan);
00250 if [1, 5, 8].count(scan) > 0:
00251 expec = numpy.array(
00252 ["CALIBRATE_POINTING#ON_SOURCE", "CALIBRATE_WVR#ON_SOURCE"]
00253 )
00254 elif scan==2:
00255 expec = numpy.array(
00256 [
00257 "CALIBRATE_SIDEBAND_RATIO#OFF_SOURCE",
00258 "CALIBRATE_SIDEBAND_RATIO#ON_SOURCE",
00259 "CALIBRATE_WVR#OFF_SOURCE",
00260 "CALIBRATE_WVR#ON_SOURCE"
00261 ]
00262 )
00263 elif [3, 6, 9, 11, 13, 15, 17, 19, 22, 24, 26, 29, 31].count(scan) > 0:
00264 expec = numpy.array(
00265 [
00266 "CALIBRATE_ATMOSPHERE#OFF_SOURCE",
00267 "CALIBRATE_ATMOSPHERE#ON_SOURCE",
00268 "CALIBRATE_WVR#OFF_SOURCE",
00269 "CALIBRATE_WVR#ON_SOURCE"
00270 ]
00271 )
00272 elif scan == 4:
00273 expec = numpy.array(
00274 [
00275 "CALIBRATE_BANDPASS#ON_SOURCE",
00276 "CALIBRATE_PHASE#ON_SOURCE",
00277 "CALIBRATE_WVR#ON_SOURCE"
00278 ]
00279 )
00280 elif scan==7:
00281 expec = numpy.array(
00282 [
00283 "CALIBRATE_AMPLI#ON_SOURCE",
00284 "CALIBRATE_PHASE#ON_SOURCE",
00285 "CALIBRATE_WVR#ON_SOURCE"
00286 ]
00287 )
00288 elif [10, 14, 18, 21, 25, 28, 32].count(scan) > 0:
00289 expec = numpy.array(
00290 [
00291 "CALIBRATE_PHASE#ON_SOURCE",
00292 "CALIBRATE_WVR#ON_SOURCE"
00293 ]
00294 )
00295 elif [12, 16, 20, 23, 27, 30].count(scan) > 0:
00296 expec = numpy.array(["OBSERVE_TARGET#ON_SOURCE"])
00297 self.assertTrue((got == expec).all())
00298
00299 def test_intentsforspw(self):
00300 """Test intentsforspw()"""
00301 for spw in range(self.md.nspw()):
00302 got = self.md.intentsforspw(spw)
00303 if spw == 0:
00304 expec = numpy.array(
00305 [
00306 "CALIBRATE_AMPLI#ON_SOURCE",
00307 "CALIBRATE_ATMOSPHERE#OFF_SOURCE",
00308 "CALIBRATE_ATMOSPHERE#ON_SOURCE",
00309 "CALIBRATE_BANDPASS#ON_SOURCE",
00310 "CALIBRATE_PHASE#ON_SOURCE",
00311 "CALIBRATE_POINTING#ON_SOURCE",
00312 "CALIBRATE_SIDEBAND_RATIO#OFF_SOURCE",
00313 "CALIBRATE_SIDEBAND_RATIO#ON_SOURCE",
00314 "CALIBRATE_WVR#OFF_SOURCE",
00315 "CALIBRATE_WVR#ON_SOURCE",
00316 "OBSERVE_TARGET#ON_SOURCE"
00317 ]
00318 )
00319 elif spw < 9:
00320 expec = numpy.array(
00321 [
00322 "CALIBRATE_POINTING#ON_SOURCE",
00323 "CALIBRATE_WVR#ON_SOURCE"
00324 ]
00325 )
00326 elif (spw < 17):
00327 expec = numpy.array(
00328 [
00329 "CALIBRATE_ATMOSPHERE#OFF_SOURCE",
00330 "CALIBRATE_ATMOSPHERE#ON_SOURCE",
00331 "CALIBRATE_SIDEBAND_RATIO#OFF_SOURCE",
00332 "CALIBRATE_SIDEBAND_RATIO#ON_SOURCE",
00333 "CALIBRATE_WVR#OFF_SOURCE",
00334 "CALIBRATE_WVR#ON_SOURCE"
00335 ]
00336 )
00337 elif (spw < 25):
00338 expec = numpy.array(
00339 [
00340 "CALIBRATE_AMPLI#ON_SOURCE",
00341 "CALIBRATE_BANDPASS#ON_SOURCE",
00342 "CALIBRATE_PHASE#ON_SOURCE",
00343 "CALIBRATE_WVR#ON_SOURCE",
00344 "OBSERVE_TARGET#ON_SOURCE"
00345 ]
00346 )
00347 else:
00348 expec = numpy.array([])
00349 self.assertTrue((got == expec).all())
00350
00351 def test_nameforfield(self):
00352 """Test nameforfield()"""
00353 names = [
00354 "3C279", "J1337-129", "Titan",
00355 "J1625-254", "V866 Sco", "RNO 90"
00356 ]
00357 for i in range(self.md.nfields()):
00358 got = self.md.nameforfield(i)
00359 self.assertTrue(got == names[i])
00360
00361 def test_nantennas(self):
00362 """ Test nantennas()"""
00363 self.assertTrue(self.md.nantennas() == 15)
00364
00365 def test_nfields(self):
00366 """ Test nfields()"""
00367 self.assertTrue(self.md.nfields() == 6)
00368
00369 def test_nscans(self):
00370 """ Test nscans()"""
00371 self.assertTrue(self.md.nscans() == 32)
00372
00373 def test_nspw(self):
00374 """ Test nspw()"""
00375 self.assertTrue(self.md.nspw() == 40)
00376
00377 def test_nstates(self):
00378 """ Test nstates()"""
00379 self.assertTrue(self.md.nstates() == 43)
00380
00381 def test_nvis(self):
00382 """ Test nvis()"""
00383 self.assertTrue(self.md.nvis() == 15363)
00384
00385 def test_scannumbers(self):
00386 """ Test scannumbers()"""
00387 expec = numpy.array(range(1, 33))
00388 self.assertTrue((self.md.scannumbers()==expec).all())
00389
00390 def test_scansforfield(self):
00391 """Test scansforfield()"""
00392 names = ["3C279", "J1337-129", "Titan", "J1625-254", "V866 Sco", "RNO 90"]
00393 for i in range(self.md.nfields()):
00394 if i == 0:
00395 expec = numpy.array([1, 2, 3, 4])
00396 elif i == 1:
00397 expec = numpy.array([5])
00398 elif i == 2:
00399 expec = numpy.array([6, 7])
00400 elif i == 3:
00401 expec = numpy.array([
00402 8, 9, 10, 13, 14, 17, 18,
00403 21, 24, 25, 28, 31, 32
00404 ])
00405 elif i == 4:
00406 expec = numpy.array([11, 12, 19, 20, 26, 27])
00407 elif i == 5:
00408 expec = numpy.array([15, 16, 22, 23, 29, 30])
00409 got = self.md.scansforfield(i)
00410 self.assertTrue((got==expec).all())
00411 got = self.md.scansforfield(names[i])
00412 self.assertTrue((got==expec).all())
00413
00414 def test_scansforintent(self):
00415 """Test scansforintent()"""
00416 for i in self.md.intents():
00417 if i=="CALIBRATE_AMPLI#ON_SOURCE":
00418 expec = numpy.array([7])
00419 elif ["CALIBRATE_ATMOSPHERE#OFF_SOURCE", "CALIBRATE_ATMOSPHERE#ON_SOURCE"].count(i) > 0:
00420 expec = numpy.array([
00421 3, 6, 9, 11, 13, 15, 17,
00422 19, 22, 24, 26, 29, 31
00423 ])
00424 elif i=="CALIBRATE_BANDPASS#ON_SOURCE":
00425 expec = numpy.array([4])
00426 elif i=="CALIBRATE_PHASE#ON_SOURCE":
00427 expec = numpy.array([4, 7, 10, 14, 18, 21, 25, 28, 32])
00428 elif i=="CALIBRATE_POINTING#ON_SOURCE":
00429 expec = numpy.array([1, 5, 8])
00430 elif ["CALIBRATE_SIDEBAND_RATIO#OFF_SOURCE", "CALIBRATE_SIDEBAND_RATIO#ON_SOURCE"].count(i) > 0:
00431 expec = numpy.array([2])
00432 elif i == "CALIBRATE_WVR#OFF_SOURCE":
00433 expec = numpy.array([
00434 2, 3, 6, 9, 11, 13, 15, 17,
00435 19, 22, 24, 26, 29, 31
00436 ])
00437 elif i=="CALIBRATE_WVR#ON_SOURCE":
00438 expec = numpy.array([
00439 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
00440 11, 13, 14, 15, 17, 18, 19, 21,
00441 22, 24, 25, 26, 28, 29, 31, 32
00442 ])
00443 else:
00444 expec = numpy.array([12, 16, 20, 23, 27, 30])
00445 got = self.md.scansforintent(i)
00446 self.assertTrue((got == expec).all())
00447
00448 def test_scansforspw(self):
00449 """Test scansforspw()"""
00450 for i in range(self.md.nspw()):
00451 if (i==0):
00452 expec = numpy.array([
00453 1, 2, 3, 4, 5, 6, 7, 8, 9,
00454 10, 11, 12, 13, 14, 15, 16, 17, 18,
00455 19, 20, 21, 22, 23, 24, 25, 26, 27,
00456 28, 29, 30, 31, 32
00457 ])
00458 elif (i<9):
00459 expec = numpy.array([1, 5, 8])
00460 elif (i<17):
00461 expec = numpy.array([
00462 2, 3, 6, 9, 11, 13, 15,
00463 17, 19, 22, 24, 26, 29, 31
00464 ])
00465 elif (i<25):
00466 expec = numpy.array([
00467 4, 7, 10, 12, 14, 16, 18,
00468 20, 21, 23, 25, 27, 28, 30, 32
00469 ])
00470 got = self.md.scansforspw(i)
00471 if (i<25):
00472 self.assertTrue((got == expec).all())
00473 else:
00474 self.assertTrue(len(got) == 0)
00475
00476 def test_scansforstate(self):
00477 """ Test scansforstate()"""
00478 for state in range(self.md.nstates()):
00479 got = self.md.scansforstate(state)
00480 if (state < 5):
00481 expec = numpy.array([1, 5, 8])
00482 elif (state < 7):
00483 expec = numpy.array([2])
00484 elif (state < 10):
00485 expec = numpy.array(
00486 [3, 6, 9, 11, 13, 15, 17, 19, 22, 24, 26, 29, 31]
00487 )
00488 elif (state < 26):
00489 expec = numpy.array([4])
00490 elif (state < 32):
00491 expec = numpy.array([7])
00492 elif (state < 33):
00493 expec = numpy.array([10, 14, 18, 21, 25, 28, 32])
00494 elif (state < 37):
00495 expec = numpy.array([12, 16, 20, 23, 27, 30])
00496 else:
00497 expec = numpy.array([12, 16, 20, 23])
00498 self.assertTrue((got == expec).all())
00499
00500 def test_scansfortimes(self):
00501 """Test scansfortimes()"""
00502 expec = numpy.array([27])
00503 got = self.md.scansfortimes(4.84282937e+09,20)
00504 self.assertTrue((got == expec).all())
00505 expec = numpy.array([24, 25, 26, 27, 28])
00506 got = self.md.scansfortimes(4.84282937e+09,200)
00507 self.assertTrue((got == expec).all())
00508
00509 def test_spwsforfield(self):
00510 """Test spwsforfield()"""
00511 names = [
00512 "3C279", "J1337-129", "Titan",
00513 "J1625-254", "V866 Sco", "RNO 90"
00514 ]
00515 for i in range(self.md.nfields()):
00516 if (i==0 or i==3):
00517 expec = numpy.array(
00518 [
00519 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
00520 10, 11, 12, 13, 14, 15, 16, 17,
00521 18, 19, 20, 21, 22, 23, 24
00522 ]
00523 )
00524 elif (i == 1):
00525 expec = numpy.array([0, 1, 2, 3, 4, 5, 6, 7, 8])
00526 elif (i==2 or i==4 or i==5):
00527 expec = numpy.array(
00528 [
00529 0, 9, 10, 11, 12, 13, 14, 15, 16,
00530 17, 18, 19, 20, 21, 22, 23, 24
00531 ]
00532 )
00533 got = self.md.spwsforfield(i)
00534 self.assertTrue((got == expec).all())
00535 got = self.md.spwsforfield(names[i])
00536 self.assertTrue((got == expec).all())
00537
00538 def test_spwsforintent(self):
00539 """Test spwsforintent()"""
00540 for intent in self.md.intents():
00541 got = self.md.spwsforintent(intent)
00542 if [
00543 "CALIBRATE_AMPLI#ON_SOURCE",
00544 "CALIBRATE_BANDPASS#ON_SOURCE",
00545 "CALIBRATE_PHASE#ON_SOURCE",
00546 "OBSERVE_TARGET#ON_SOURCE"
00547 ].count(intent) > 0:
00548
00549 expec = numpy.array([0, 17, 18, 19, 20, 21, 22, 23, 24])
00550 elif [
00551 "CALIBRATE_ATMOSPHERE#OFF_SOURCE",
00552 "CALIBRATE_ATMOSPHERE#ON_SOURCE",
00553 "CALIBRATE_SIDEBAND_RATIO#OFF_SOURCE",
00554 "CALIBRATE_SIDEBAND_RATIO#ON_SOURCE",
00555 "CALIBRATE_WVR#OFF_SOURCE"
00556 ].count(intent) > 0:
00557 expec = numpy.array([0, 9, 10, 11, 12, 13, 14, 15, 16])
00558 elif intent == "CALIBRATE_POINTING#ON_SOURCE":
00559 expec = numpy.array([0, 1, 2, 3, 4, 5, 6, 7, 8])
00560 elif intent == "CALIBRATE_WVR#ON_SOURCE":
00561 expec = numpy.array(
00562 [
00563 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
00564 10, 11, 12, 13, 14, 15, 16,
00565 17, 18, 19, 20, 21, 22, 23, 24
00566 ]
00567 )
00568 self.assertTrue((got == expec).all())
00569
00570 def test_spwsforscan(self):
00571 """Test spwsforscan()"""
00572 for i in self.md.scannumbers():
00573 if [1, 5, 8].count(i) > 0:
00574 expec = numpy.array([0, 1, 2, 3, 4, 5, 6, 7, 8])
00575 elif [2, 3, 6, 9, 11, 13, 15, 17, 19, 22, 24, 26, 29, 31].count(i) > 0:
00576 expec = numpy.array([0, 9, 10, 11, 12, 13, 14, 15, 16])
00577 elif [4, 7, 10, 12, 14, 16, 18, 20, 21, 23, 25, 27, 28, 30, 32].count(i) > 0:
00578 expec = numpy.array([0, 17, 18, 19, 20, 21, 22, 23, 24])
00579 got = self.md.spwsforscan(i)
00580 self.assertTrue((got == expec).all())
00581
00582 def test_statesforscan(self):
00583 """Test statesforscan()"""
00584 for i in self.md.scannumbers():
00585 if [1, 5, 8].count(i) > 0:
00586 expec = numpy.array([0, 1, 2, 3, 4])
00587 elif i == 2:
00588 expec = numpy.array([5, 6])
00589 elif [3, 6, 9, 11, 13, 15, 17, 19, 22, 24, 26, 29, 31].count(i) > 0:
00590 expec = numpy.array([7, 8, 9])
00591 elif i == 4:
00592 expec = numpy.array([
00593 10, 11, 12, 13, 14, 15, 16, 17, 18,
00594 19, 20, 21, 22, 23, 24, 25
00595 ])
00596 elif i == 7:
00597 expec = numpy.array([26, 27, 28, 29, 30, 31])
00598 elif [10, 14, 18, 21, 25, 28, 32].count(i) > 0:
00599 expec = numpy.array([32])
00600 elif [12, 16, 20, 23].count(i) > 0:
00601 expec = numpy.array([33, 34, 35, 36, 37, 38, 39, 40, 41, 42])
00602 else:
00603 expec = numpy.array([33, 34, 35, 36])
00604 got = self.md.statesforscan(i)
00605 self.assertTrue((got == expec).all())
00606
00607
00608 def test_tdmspws(self):
00609 """Test tdmspws()"""
00610 got = self.md.tdmspws()
00611 expec = numpy.array([1, 3, 5, 7, 9, 11, 13, 15])
00612 self.assertTrue((got == expec).all())
00613
00614 def test_timesforfield(self):
00615 """Test timesforfield()"""
00616 for i in range(self.md.nfields()):
00617 if i == 0:
00618 expec = 818
00619 if i == 1:
00620 expec = 81
00621 if i == 2:
00622 expec = 248
00623 if i == 3:
00624 expec = 402
00625 if i == 4:
00626 expec = 963
00627 if i == 5:
00628 expec = 965
00629 got = len(self.md.timesforfield(i))
00630 self.assertTrue(got == expec)
00631
00632 def test_timesforscan(self):
00633 """Test timesforscan()"""
00634 expec = numpy.array([
00635 4842825003.6,
00636 4842825004.0, 4842825004.5,
00637 4842825004.8, 4842825005.0,
00638 4842825016.3, 4842825016.6,
00639 4842825017.1, 4842825017.5,
00640 4842825017.6, 4842825029.0,
00641 4842825029.3, 4842825029.8,
00642 4842825030.1, 4842825030.3
00643 ])
00644 expec.sort()
00645 got = self.md.timesforscans(3)
00646 self.assertTrue((abs(got - expec)).all() < 0.1)
00647
00648
00649 def test_timesforscans(self):
00650 """Test timesforscans()"""
00651 expec = numpy.array([
00652 4842825928.7, 4842825929.5,
00653 4842825930.0,
00654 4842825930.6, 4842825941.4,
00655 4842825942.2, 4842825942.5,
00656 4842825942.7, 4842825943.2,
00657 4842825954.0, 4842825954.9,
00658 4842825955.2, 4842825955.4,
00659 4842825955.9, 4842825003.6,
00660 4842825004.0, 4842825004.5,
00661 4842825004.8, 4842825005.0,
00662 4842825016.3, 4842825016.6,
00663 4842825017.1, 4842825017.5,
00664 4842825017.6, 4842825029.0,
00665 4842825029.3, 4842825029.8,
00666 4842825030.1, 4842825030.3
00667 ])
00668 expec.sort()
00669 got = self.md.timesforscans([3, 6])
00670 self.assertTrue((abs(got - expec)).all() < 0.1)
00671
00672 def test_wvrspws(self):
00673 """Test wvrspws()"""
00674 got = self.md.wvrspws()
00675 expec = numpy.array([
00676 0, 25, 26, 27, 28, 29, 30, 31,
00677 32, 33, 34, 35, 36, 37, 38, 39
00678 ])
00679 self.assertTrue((got == expec).all())
00680
00681
00682 def suite():
00683 return [msmd_test]