Commits

C. Enrique Garcia Dabo authored 2d4a38a6eee
Fix unit test with number of channels not divisible by chanbin

Fixes partially CAS-11988
No tags

code/mstransform/TVI/test/tChannelAverageTVI.cc

Modified
499 499 auto selections = std::make_shared<vi::FrequencySelections>();
500 500 selections->add(*freqSel);
501 501 diskItFac->setFrequencySelections(selections);
502 502 }
503 503 else
504 504 diskItFac.reset(new VisIterImpl2LayerFactory(ms_p.get(),ipar, false));
505 505
506 506 //Create a ChannelAverageTVI Factory
507 507 std::unique_ptr<ChannelAverageTVILayerFactory> chanAvgFac;
508 508 casacore::Record configuration;
509 - chanBinFirst_p = 5;
510 509 configuration.define ("chanbin", chanBinFirst_p);
511 510 chanAvgFac.reset(new ChannelAverageTVILayerFactory(configuration));
512 511
513 512 //Create a layered factory with all the layers of factories
514 513 //If requested a PassThroughTVI is added to test that ChannelAverage
515 514 //forwards properly all the information to layers above
516 515 std::vector<ViiLayerFactory*> factories;
517 516 factories.push_back(diskItFac.get());
518 517 factories.push_back(chanAvgFac.get());
519 518 std::unique_ptr<PassThroughTVILayerFactory> passThroughFactory;
648 647 //Check that the number of channels is correct.
649 648 //The +1 is to account for the last residual channel
650 649 auto & spwcols = vi_p->spectralWindowSubtablecols();
651 650 int nChannelNewSpw0 = nChannelsOrig_p[0] / chanBinFirst_p + 1;
652 651 int nChannelNewSpw1 = nChannelsOrig_p[1] / chanBinFirst_p + 1;
653 652 ASSERT_EQ(spwcols.nrow(), (unsigned int)4);
654 653 ASSERT_EQ(spwcols.numChan()(0), nChannelNewSpw0); //SPW0, old SPW0 already averaged
655 654 ASSERT_EQ(spwcols.numChan()(1), nChannelNewSpw1); //SPW1, old SPW1 already averaged
656 655
657 656 //Check that the last frequency width is less than the rest
658 - ASSERT_LT(spwcols.chanWidth()(0)(nChannelNewSpw0-1), spwcols.chanWidth()(0)(nChannelNewSpw0-2));
657 + Vector<double> chanWidths = spwcols.chanWidth()(0);
658 + ASSERT_LT(chanWidths(nChannelNewSpw0-1), chanWidths(nChannelNewSpw0-2));
659 659 }
660 660
661 661 TEST_F(ChannelAverageTVISpwChannTest, CheckMSSelOutputSpwChannels)
662 662 {
663 663 useMSSelection(true);
664 664 addPassThroughTVI(true);
665 665 createTVIs();
666 666 size_t nRows = 0;
667 667 size_t nRowsSpw0 = 0;
668 668 size_t nRowsSpw1 = 0;
669 669 //Check that after averaging with chanbin=5 and spw selection "0:1~40",
670 670 //the first spectral window has 8 channels
671 671 //and there are no rows with the second spectral window
672 672 visitIterator([&]() -> void {auto shape = vb_p->visCube().shape();
673 -
674 - std::cout<<vb_p->spectralWindows()<<vb_p->nChannels()<<std::endl;
675 - std::cout<<vb_p->antenna1()<<std::endl;
676 - std::cout<<vb_p->dataDescriptionIds()<<std::endl;
677 - std::cout<<shape<<std::endl;
678 -
673 +
679 674 if(allEQ(vb_p->spectralWindows(), 0)) //SPW0
680 675 {
681 676 nRowsSpw0+=shape[2];
682 677 ASSERT_EQ(vb_p->nChannels(), 8);
683 678 }
684 679 //The TVI duplicates the existing SPWs (CAS-10294)
685 680 ASSERT_EQ(vi_p->nSpectralWindows(), 4);
686 681 nRows+=vb_p->visCube().shape()[2];});
687 682
688 683 //After selection we have only half of the original rows

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut