Commits
267 267 | self.assertTrue((gflag == eflag).all(), 'FLAG comparison failed') |
268 268 | self.assertTrue((gfrow == efrow).all(), 'FLAG_ROW comparison failed') |
269 269 | # all flags must be True where wtsp = 0 |
270 270 | self.assertTrue(np.extract(gwtsp == 0, gflag).all()) |
271 271 | self.assertTrue(np.allclose(gsigma, esigma), 'SIGMA comparison failed') |
272 272 | if type(gsisp) != type(None) and type(esisp) != type(None): |
273 273 | self.assertTrue(np.allclose( |
274 274 | gsisp, esisp), 'SIGMA_SPECTRUM comparison failed' |
275 275 | ) |
276 276 | |
277 - | skip("temporary skip for debugging one test") | .
278 277 | def test_algorithm(self): |
279 278 | """ Test the algorithm, includes excludechans tests""" |
280 279 | dst = "ngc5921.split.ms" |
281 280 | cflags = np.array(63 * [False]) |
282 281 | cflags[10:21] = True |
283 282 | """ |
284 283 | row_to_rows = [] |
285 284 | for row in range(60): |
286 285 | row_to_rows.append((row, row+1)) |
287 286 | """ |
304 303 | ref = 'ngc5921_statwt_ref_test_algorithm_sep_corr_fitspw.ms' |
305 304 | else: |
306 305 | if fitspw == '': |
307 306 | ref = 'ngc5921_statwt_ref_test_algorithm_combine_corr_no_fitspw.ms' |
308 307 | else: |
309 308 | ref = 'ngc5921_statwt_ref_test_algorithm_combine_corr_has_fitspw.ms' |
310 309 | self.compare(dst, ref) |
311 310 | shutil.rmtree(dst) |
312 311 | c += 1 |
313 312 | |
314 - | skip("temporary skip for debugging one test") | .
315 313 | def test_timebin(self): |
316 314 | """Test time binning""" |
317 315 | dst = "ngc5921.split.timebin.ms" |
318 316 | combine = "corr" |
319 317 | for timebin in ["300s", 10]: |
320 318 | shutil.copytree(src, dst) |
321 319 | myms.open(dst, nomodify=False) |
322 320 | myms.statwt(timebin=timebin, combine=combine) |
323 321 | myms.done() |
324 322 | ref = 'ngc5921_statwt_ref_test_timebin_' + str(timebin) + '.ms' |
325 323 | self.compare(dst, ref) |
326 324 | shutil.rmtree(dst) |
327 325 | |
328 - | skip("temporary skip for debugging one test") | .
329 326 | def test_chanbin(self): |
330 327 | """Test channel binning""" |
331 328 | dst = "ngc5921.split.chanbin_0.ms" |
332 329 | row_to_rows = [] |
333 330 | for i in range(60): |
334 331 | row_to_rows.append([i, i+1]) |
335 332 | bins = [ |
336 333 | [0, 8], [8, 16], [16, 24], [24, 32], [32, 40], [40, 48], |
337 334 | [48, 56], [56,63] |
338 335 | ] |
360 357 | self.assertTrue(y == x-1, "wrong number of columns") |
361 358 | mytb.done() |
362 359 | myms.open(dst, nomodify=False) |
363 360 | myms.statwt(chanbin=chanbin, combine=combine) |
364 361 | myms.done() |
365 362 | if combine == '': |
366 363 | ref = refdir + 'ngc5921_statwt_ref_test_chanbin_sep_corr.ms' |
367 364 | ref = refdir + 'ngc5921_statwt_ref_test_chanbin_combine_corr.ms' |
368 365 | shutil.rmtree(dst) |
369 366 | |
370 - | skip("temporary skip for debugging one test") | .
371 367 | def test_minsamp(self): |
372 368 | """Test minimum number of points""" |
373 369 | dst = "ngc5921.split.minsamp.ms" |
374 370 | combine = "corr" |
375 371 | trow = 12 |
376 372 | for minsamp in [60, 80]: |
377 373 | shutil.copytree(src, dst) |
378 374 | myms.open(dst, nomodify=False) |
379 375 | myms.statwt(minsamp=minsamp, combine=combine) |
380 376 | myms.done() |
403 399 | "Incorrect weight spectrum row " + str(trow) |
404 400 | ) |
405 401 | self.assertTrue( |
406 402 | flag[:,:,trow].all(), "Incorrect flag row " + str(trow) |
407 403 | ) |
408 404 | self.assertTrue( |
409 405 | frow[trow], "Incorrect flagrow row " + str(trow) |
410 406 | ) |
411 407 | shutil.rmtree(dst) |
412 408 | |
413 - | skip("temporary skip for debugging one test") | .
414 409 | def test_default_boundaries(self): |
415 410 | """Test default scan, field, etc boundaries""" |
416 411 | dst = "ngc5921.split.normalbounds.ms" |
417 412 | ref = 'ngc5921_statwt_ref_test_default_boundaries.ms' |
418 413 | timebin = "6000s" |
419 414 | # there are three field_ids, and there is a change in field_id when |
420 415 | # there is a change in scan number, so specifying combine="field" in the |
421 416 | # absence of "scan" will give the same result as combine="" |
422 417 | row_to_rows = [] |
423 418 | for i in range(12): |
435 430 | for i in range(56, 60): |
436 431 | row_to_rows.append([56, 60]) |
437 432 | for combine in ["corr", "corr,field"]: |
438 433 | shutil.copytree(src, dst) |
439 434 | myms.open(dst, nomodify=False) |
440 435 | myms.statwt(timebin=timebin, combine=combine) |
441 436 | myms.done() |
442 437 | self.compare(dst, ref) |
443 438 | shutil.rmtree(dst) |
444 439 | |
445 - | skip("temporary skip for debugging one test") | .
446 440 | def test_no_scan_boundaries(self): |
447 441 | """Test no scan boundaries""" |
448 442 | dst = "ngc5921.no_scan_bounds.ms" |
449 443 | timebin = "6000s" |
450 444 | # ref = os.path.join(datadir, 'ngc5921_statwt_ref_test_no_scan_bounds.ms') |
451 445 | ref = 'ngc5921_statwt_ref_test_no_scan_bounds.ms' |
452 446 | combine = "corr, scan" |
453 447 | shutil.copytree(src, dst) |
454 448 | myms.open(dst, nomodify=False) |
455 449 | myms.statwt(timebin=timebin, combine=combine) |
456 450 | myms.done() |
457 451 | self.compare(dst, ref) |
458 452 | shutil.rmtree(dst) |
459 453 | |
460 - | skip("temporary skip for debugging one test") | .
461 454 | def test_no_scan_nor_field_boundaries(self): |
462 455 | """Test no scan nor field boundaries""" |
463 456 | dst = "ngc5921.no_scan_nor_field_bounds.ms" |
464 457 | timebin = "6000s" |
465 458 | # ref = os.path.join(datadir, 'ngc5921_statwt_ref_test_no_scan_nor_field_bounds.ms') |
466 459 | ref = 'ngc5921_statwt_ref_test_no_scan_nor_field_bounds.ms' |
467 460 | for combine in ["corr,scan,field", "corr,field,scan"]: |
468 461 | shutil.copytree(src, dst) |
469 462 | myms.open(dst, nomodify=False) |
470 463 | myms.statwt(timebin=timebin, combine=combine) |
471 464 | myms.done() |
472 465 | self.compare(dst, ref) |
473 466 | shutil.rmtree(dst) |
474 467 | |
475 - | skip("temporary skip for debugging one test") | .
476 468 | def test_statalg(self): |
477 469 | """Test statalg""" |
478 470 | # just testing inputs |
479 471 | dst = "ngc5921.split.statalg.ms" |
480 472 | for statalg in ["cl", "ch", "h", "f", "bogus"]: |
481 473 | shutil.copytree(src, dst) |
482 474 | myms.open(dst, nomodify=False) |
483 475 | if statalg == "cl": |
484 476 | self.assertTrue(myms.statwt(statalg=statalg)) |
485 477 | elif statalg == "ch": |
508 500 | shutil.copytree(src, dst) |
509 501 | myms.open(dst, nomodify=False) |
510 502 | myms.statwt(timebin=timebin, combine=combine, wtrange=wtrange) |
511 503 | myms.done() |
512 504 | self.compare(dst, ref) |
513 505 | # self._check_weights( |
514 506 | # dst, row_to_rows, 'c', None, True, None, wtrange |
515 507 | # ) |
516 508 | shutil.rmtree(dst) |
517 509 | |
518 - | skip("temporary skip for debugging one test") | .
519 510 | def test_preview(self): |
520 511 | """Test preview mode""" |
521 512 | dst = "ngc5921.split.preview.ms" |
522 513 | [refwt, refwtsp, refflag, reffrow, refdata] = _get_dst_cols(src) |
523 514 | combine = "corr" |
524 515 | timebin = "300s" |
525 516 | wtrange = [1, 2] |
526 517 | preview = True |
527 518 | shutil.copytree(src, dst) |
528 519 | myms.open(dst, nomodify=False) |
534 525 | self.assertTrue(np.all(tstflag == refflag), "FLAGs don't match") |
535 526 | self.assertTrue(np.all(tstfrow == reffrow), "FLAG_ROWs don't match") |
536 527 | self.assertTrue( |
537 528 | np.all(np.isclose(tstwt, refwt)), "WEIGHTs don't match" |
538 529 | ) |
539 530 | self.assertTrue( |
540 531 | np.all(np.isclose(tstwtsp, refwtsp)), "WEIGHT_SPECTRUMs don't match" |
541 532 | ) |
542 533 | shutil.rmtree(dst) |
543 534 | |
544 - | skip("temporary skip for debugging one test") | .
545 535 | def test_data_col(self): |
546 536 | """Test using data column""" |
547 537 | dst = "ngc5921.split.data.ms" |
548 538 | ref = 'ngc5921_statwt_ref_test_data_col.ms' |
549 539 | combine = "corr" |
550 540 | timebin = 1 |
551 541 | data = "data" |
552 542 | """ |
553 543 | row_to_rows = [] |
554 544 | for i in range(60): |
559 549 | self.assertTrue(mytb.removecols("DATA")) |
560 550 | self.assertTrue(mytb.renamecol("CORRECTED_DATA", "DATA")) |
561 551 | mytb.done() |
562 552 | myms.open(dst, nomodify=False) |
563 553 | myms.statwt(timebin=timebin, combine=combine, datacolumn=data) |
564 554 | myms.done() |
565 555 | # self._check_weights(dst, row_to_rows, 'd', None, True, None, None) |
566 556 | self.compare(dst, ref) |
567 557 | shutil.rmtree(dst) |
568 558 | |
569 - | skip("temporary skip for debugging one test") | .
570 559 | def test_sliding_time_window(self): |
571 560 | """Test sliding time window""" |
572 561 | dst = "ngc5921.split.sliding_time_window.ms" |
573 562 | ref = 'ngc5921_statwt_ref_test_sliding_time_window.ms' |
574 563 | timebin = "300s" |
575 564 | """ |
576 565 | row_to_rows = [] |
577 566 | row_to_rows.append([0, 6]) |
578 567 | row_to_rows.append([0, 7]) |
579 568 | row_to_rows.append([0, 8]) |
638 627 | shutil.copytree(src, dst) |
639 628 | myms.open(dst, nomodify=False) |
640 629 | myms.statwt(timebin=timebin, slidetimebin=True) |
641 630 | myms.done() |
642 631 | # self._check_weights( |
643 632 | # dst, row_to_rows, 'c', None, False, None, None |
644 633 | # ) |
645 634 | self.compare(dst, ref) |
646 635 | shutil.rmtree(dst) |
647 636 | |
648 - | skip("temporary skip for debugging one test") | .
649 637 | def test_sliding_window_timebin_int(self): |
650 638 | """Test sliding window with timebin as int specified""" |
651 639 | dst = "ngc5921.split.sliding_time_window.ms" |
652 640 | # row_to_rows = [] |
653 641 | """ |
654 642 | # odd int, timebin = 5 |
655 643 | row_to_rows.append([0, 5]) |
656 644 | row_to_rows.append([0, 5]) |
657 645 | row_to_rows.append([0, 5]) |
658 646 | row_to_rows.append([1, 6]) |
794 782 | shutil.copytree(src, dst) |
795 783 | myms.open(dst, nomodify=False) |
796 784 | myms.statwt(timebin=timebin, slidetimebin=True) |
797 785 | myms.done() |
798 786 | #self._check_weights( |
799 787 | # dst, row_to_rows, 'c', None, False, None, None |
800 788 | #) |
801 789 | self.compare(dst, ref) |
802 790 | shutil.rmtree(dst) |
803 791 | |
804 - | skip("temporary skip for debugging one test") | .
805 792 | def test_residual(self): |
806 793 | """Test using corrected_data - model_data column""" |
807 794 | dst = "ngc5921.split.residualwmodel.ms" |
808 795 | ref = 'ngc5921_statwt_ref_test_residual.ms' |
809 796 | data = "residual" |
810 797 | # row_to_rows = [] |
811 798 | # for i in range(60): |
812 799 | # row_to_rows.append([i, i+1]) |
813 800 | shutil.copytree(src, dst) |
814 801 | myms.open(dst, nomodify=False) |
815 802 | myms.statwt(datacolumn=data) |
816 803 | myms.done() |
817 804 | # self._check_weights( |
818 805 | # dst, row_to_rows, data, None, False, None, None |
819 806 | # ) |
820 807 | self.compare(dst, ref) |
821 808 | shutil.rmtree(dst) |
822 809 | |
823 - | skip("temporary skip for debugging one test") | .
824 810 | def test_residual_no_model(self): |
825 811 | """Test datacolumn='residual' in the absence of a MODEL_DATA column""" |
826 812 | dst = "ngc5921.split.residualwoutmodel.ms" |
827 813 | ref = 'ngc5921_statwt_ref_test_residual_no_model.ms' |
828 814 | data = "residual" |
829 815 | shutil.copytree(src, dst) |
830 816 | self.assertTrue(mytb.open(dst, nomodify=False)) |
831 817 | self.assertTrue(mytb.removecols("MODEL_DATA")) |
832 818 | mytb.done() |
833 819 | myms.open(dst, nomodify=False) |
834 820 | myms.statwt(datacolumn=data) |
835 821 | myms.done() |
836 822 | # self._check_weights( |
837 823 | # dst, row_to_rows, data, None, False, None, None |
838 824 | # ) |
839 825 | self.compare(dst, ref) |
840 826 | shutil.rmtree(dst) |
841 827 | |
842 - | skip("temporary skip for debugging one test") | .
843 828 | def test_residual_data(self): |
844 829 | """Test using data - model_data column""" |
845 830 | dst = "ngc5921.split.residualdatawmodel.ms" |
846 831 | ref = 'ngc5921_statwt_ref_test_residual_data.ms' |
847 832 | data = "residual_data" |
848 833 | # row_to_rows = [] |
849 834 | # for i in range(60): |
850 835 | # row_to_rows.append([i, i+1]) |
851 836 | shutil.copytree(src, dst) |
852 837 | myms.open(dst, nomodify=False) |
853 838 | myms.statwt(datacolumn=data) |
854 839 | myms.done() |
855 840 | # self._check_weights( |
856 841 | # dst, row_to_rows, data, None, False, None, None |
857 842 | # ) |
858 843 | self.compare(dst, ref) |
859 844 | shutil.rmtree(dst) |
860 845 | |
861 - | skip("temporary skip for debugging one test") | .
862 846 | def test_residual_data_no_model(self): |
863 847 | """Test using residual data in absence of MODEL_DATA""" |
864 848 | dst = "ngc5921.split.residualdatawoutmodel.ms" |
865 849 | ref = 'ngc5921_statwt_ref_test_residual_data_no_model.ms' |
866 850 | data = "residual_data" |
867 851 | # row_to_rows = [] |
868 852 | # for i in range(60): |
869 853 | # row_to_rows.append([i, i+1]) |
870 854 | shutil.copytree(src, dst) |
871 855 | self.assertTrue(mytb.open( |
877 861 | mytb.done() |
878 862 | myms.open(dst, nomodify=False) |
879 863 | myms.statwt(datacolumn=data) |
880 864 | myms.done() |
881 865 | # self._check_weights( |
882 866 | # dst, row_to_rows, data, None, False, None, None |
883 867 | # ) |
884 868 | self.compare(dst, ref) |
885 869 | shutil.rmtree(dst) |
886 870 | |
887 - | skip("temporary skip for debugging one test") | .
888 871 | def test_returned_stats(self): |
889 872 | """Test returned stats, CAS-10881""" |
890 873 | dst = "ngc5921.split.statstest.ms" |
891 874 | shutil.copytree(src, dst) |
892 875 | myms.open(dst, nomodify=False) |
893 876 | res = myms.statwt() |
894 877 | myms.done() |
895 878 | self.assertTrue( |
896 879 | np.isclose(res['mean'], 3.691224144843796), |
897 880 | "mean is incorrect" |
898 881 | ) |
899 882 | self.assertTrue( |
900 883 | np.isclose(res['variance'], 6.860972180192186), |
901 884 | "variance is incorrect" |
902 885 | ) |
903 886 | shutil.rmtree(dst) |
904 887 | |
905 - | skip("temporary skip for debugging one test") | .
906 888 | def test_multi_spw_no_spectrum_columns(self): |
907 889 | "Test multi spw with no sigma nor weight spectrum columns works" |
908 890 | for tb in [1, "5s"]: |
909 891 | dst = "statwt_test_vlass_timebin" + str(tb) + ".ms" |
910 892 | shutil.copytree(vlass, dst) |
911 893 | myms.open(dst, nomodify=False) |
912 894 | res = myms.statwt( |
913 895 | combine='scan,field,state', timebin=tb, |
914 896 | datacolumn='residual_data' |
915 897 | ) |