Commits

George Moellenbrock authored 0d885ec30ff
For CAS-12735 (cal freq-meta), added machinery to serve nominal channel width info (alongside channel frequencies) via ViImplementation2::getChanWidths function (cf getFrequencies).

Requisite derivations also added to VisibilityIteratorImpl2, TransformingVi2, SimpleSimVi2, and (especially) ChannelAverageTVI. The getChanWidths function does not support arbitrary frame conversions on the widths (which would be very subtle, and which are not needed for the present context), and access is only available from the ViImplementation2 interface (no VisBuffer2 accessor, as yet). In ChannelAverageTVI, some adjustments made to make the bypass for the single-channel (degenerate) case in the getFrequencies and getChanWidths functions *not* depend on a call to visibilityShape() (which, in turn, depends on VI2 synchronization. This permits access to effective frequency and width info (including when averaging) for any spectral window outside the VI2 iteration loops in applications. (c++ unit tests for ChannelAverageTVI pending)

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 frequencies 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 (transformed) frequencies
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 + cout << "***** ChannelAverageTVI::getChanWidths *****" << endl;
762 +
763 + return outputWidths;
764 +}
765 +
710 766 // -----------------------------------------------------------------------
711 767 //
712 768 // -----------------------------------------------------------------------
713 769 void ChannelAverageTVI::writeFlag (const Cube<Bool> & flag)
714 770 {
715 771 // Create a flag cube with the input VI shape
716 772 Cube<Bool> propagatedFlagCube;
717 773 propagatedFlagCube = getVii()->getVisBuffer()->flagCube();
718 774
719 775 // 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