Commits

Mark Kettenis authored 2f3edc040b9 Merge
Merge branch 'master' into CAS-13622

casa5/code/mstransform/TVI/ChannelAverageTVI.cc

Modified
660 660 // Accumulate elapsed time
661 661 Tss_+=omp_get_wtime()-time0;
662 662 #endif
663 663
664 664 return;
665 665 }
666 666
667 667 // -----------------------------------------------------------------------
668 668 //
669 669 // -----------------------------------------------------------------------
670 -Vector<Double> ChannelAverageTVI::getFrequencies ( Double time,
671 - Int frameOfReference,
672 - Int spectralWindowId,
673 - Int msId) const
670 +Vector<Double> ChannelAverageTVI::getFrequencies ( Double time,
671 + Int frameOfReference,
672 + Int spectralWindowId,
673 + Int msId) const
674 674 {
675 675
676 - // Pass-thru for single-channel case or chanbin=1 case
677 - if (getVii()->visibilityShape()[1]==1 ||
678 - spwChanbinMap_p[spectralWindowId]==1) {
676 + // Pass-thru for chanbin=1 case
677 + if (spwChanbinMap_p[spectralWindowId]==1) {
679 678 return getVii()->getFrequencies(time,frameOfReference,spectralWindowId,msId);
680 679 }
681 680
682 - // Get frequencies from input VI
681 + // Get frequencies from input VI, which we will process
683 682 Vector<Double> inputFrequencies = getVii()->getFrequencies(time,frameOfReference,
684 - spectralWindowId,msId);
683 + spectralWindowId,msId);
684 +
685 + // Pass-thru for single-channel case
686 + // NB: This does NOT depend on current iteration having same spw as specified spectralWindowId
687 + // NB: Nor does it rely on sensing the apparent shape of the visibility data object (so that need not be pre-filled)
688 + if (inputFrequencies.nelements()==1)
689 + return inputFrequencies;
685 690
686 691 // Produce output (transformed) frequencies
687 692 Vector<Double> outputFrecuencies(spwOutChanNumMap_p[spectralWindowId],0);
688 693
689 694 // Gather input data
690 695 DataCubeMap inputData;
691 696 DataCubeHolder<Double> inputFrecuenciesHolder(inputFrequencies);
692 697 inputData.add(MS::DATA,inputFrecuenciesHolder);
693 698
694 699 // Gather output data
700 705 PlainChannelAverageKernel<Double> kernel;
701 706 uInt width = spwChanbinMap_p[spectralWindowId];
702 707 ChannelAverageTransformEngine<Double> transformer(&kernel,&inputData,&outputData,width);
703 708
704 709 // Transform data
705 710 transformer.transform();
706 711
707 712 return outputFrecuencies;
708 713 }
709 714
715 +Vector<Double> ChannelAverageTVI::getChanWidths ( Double time,
716 + Int frameOfReference,
717 + Int spectralWindowId,
718 + Int msId) const
719 +{
720 +
721 + // Pass-thru for chanbin=1 case
722 + if (spwChanbinMap_p[spectralWindowId]==1) {
723 + return getVii()->getChanWidths(time,frameOfReference,spectralWindowId,msId);
724 + }
725 +
726 + // Get widths from input VI
727 + Vector<Double> inputWidths = getVii()->getChanWidths(time,frameOfReference,
728 + spectralWindowId,msId);
729 + // Pass-thru for single-channel case
730 + // NB: This does NOT depend on current iteration having same spw as specified spectralWindowId
731 + // NB: Nor does it rely on sensing the apparent shape of the visibility data object (so that need not be pre-filled)
732 + if (inputWidths.nelements()==1)
733 + return inputWidths;
734 +
735 + // Produce output (summed) widths
736 + Vector<Double> outputWidths(spwOutChanNumMap_p[spectralWindowId],0);
737 +
738 + // Gather input data
739 + DataCubeMap inputData;
740 + DataCubeHolder<Double> inputWidthsHolder(inputWidths);
741 + inputData.add(MS::DATA,inputWidthsHolder);
742 + // We need flag vector (all false==unflagged) for ChannelAccumulationKernal (which just adds within bins)
743 + Vector<Bool> nonflagged(inputWidths.nelements(),false);
744 + DataCubeHolder<Bool> inputFlagHolder(nonflagged);
745 + inputData.add(MS::FLAG,inputFlagHolder);
746 +
747 + // Gather output data
748 + DataCubeMap outputData;
749 + DataCubeHolder<Double> outputWidthsHolder(outputWidths);
750 + outputData.add(MS::DATA,outputWidthsHolder);
751 +
752 + // Configure Transformation Engine
753 + //PlainChannelAverageKernel<Double> kernel;
754 + ChannelAccumulationKernel<Double> kernel;
755 + uInt width = spwChanbinMap_p[spectralWindowId];
756 + ChannelAverageTransformEngine<Double> transformer(&kernel,&inputData,&outputData,width);
757 +
758 + // Transform data
759 + transformer.transform();
760 +
761 + return outputWidths;
762 +}
763 +
710 764 // -----------------------------------------------------------------------
711 765 //
712 766 // -----------------------------------------------------------------------
713 767 void ChannelAverageTVI::writeFlag (const Cube<Bool> & flag)
714 768 {
715 769 // Create a flag cube with the input VI shape
716 770 Cube<Bool> propagatedFlagCube;
717 771 propagatedFlagCube = getVii()->getVisBuffer()->flagCube();
718 772
719 773 // Propagate flags from the input cube to the propagated flag cube

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

Add shortcut