LCOV - code coverage report
Current view: top level - mstransform/TVI - FreqAxisTVI.h (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 0 54 0.0 %
Date: 2023-11-02 14:27:30 Functions: 0 27 0.0 %

          Line data    Source code
       1             : //# FreqAxisTVI.h: This file contains the interface definition of the MSTransformManager class.
       2             : //#
       3             : //#  CASA - Common Astronomy Software Applications (http://casa.nrao.edu/)
       4             : //#  Copyright (C) Associated Universities, Inc. Washington DC, USA 2011, All rights reserved.
       5             : //#  Copyright (C) European Southern Observatory, 2011, All rights reserved.
       6             : //#
       7             : //#  This library is free software; you can redistribute it and/or
       8             : //#  modify it under the terms of the GNU Lesser General Public
       9             : //#  License as published by the Free software Foundation; either
      10             : //#  version 2.1 of the License, or (at your option) any later version.
      11             : //#
      12             : //#  This library is distributed in the hope that it will be useful,
      13             : //#  but WITHOUT ANY WARRANTY, without even the implied warranty of
      14             : //#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             : //#  Lesser General Public License for more details.
      16             : //#
      17             : //#  You should have received a copy of the GNU Lesser General Public
      18             : //#  License along with this library; if not, write to the Free Software
      19             : //#  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      20             : //#  MA 02111-1307  USA
      21             : //# $Id: $
      22             : 
      23             : #ifndef FreqAxisTVI_H_
      24             : #define FreqAxisTVI_H_
      25             : 
      26             : // Base class
      27             : #include <msvis/MSVis/TransformingVi2.h>
      28             : 
      29             : // VI/VB framework
      30             : #include <msvis/MSVis/VisBuffer2.h>
      31             : #include <msvis/MSVis/VisibilityIterator2.h>
      32             : 
      33             : // TVI framework
      34             : #include <mstransform/TVI/UtilsTVI.h>
      35             : 
      36             : // Measurement Set
      37             : #include <casacore/ms/MSSel/MSSelection.h>
      38             : 
      39             : // NOTE: See implementation include below
      40             : 
      41             : 
      42             : namespace casa { //# NAMESPACE CASA - BEGIN
      43             : 
      44             : namespace vi { //# NAMESPACE VI - BEGIN
      45             : 
      46             : //////////////////////////////////////////////////////////////////////////
      47             : // FreqAxisTVI class
      48             : //////////////////////////////////////////////////////////////////////////
      49             : 
      50             : template<class T> class FreqAxisTransformEngine; // Forward declaration
      51             : template<class T> class FreqAxisTransformEngine2; // Forward declaration
      52             : 
      53             : class FreqAxisTVI : public TransformingVi2
      54             : {
      55             : 
      56             : public:
      57             : 
      58             :         // Lifecycle
      59             :         FreqAxisTVI(ViImplementation2 * inputVii);
      60             :         ~FreqAxisTVI();
      61             : 
      62             :         // Navigation methods
      63             :         virtual void origin ();
      64             :         virtual void next ();
      65             : 
      66             :         // General TVI info (common for all sub-classes)
      67             :     casacore::Bool existsColumn (VisBufferComponent2 id) const;
      68           0 :     casacore::Bool flagCategoryExists () const {return false;}
      69             : 
      70             :         // casacore::List of methods that should be implemented by derived classes
      71             :     // virtual void flag(casacore::Cube<casacore::Bool>& flagCube) const = 0;
      72             :     // virtual void floatData (casacore::Cube<casacore::Float> & vis) const = 0;
      73             :     // virtual void visibilityObserved (casacore::Cube<casacore::Complex> & vis) const = 0;
      74             :     // virtual void visibilityCorrected (casacore::Cube<casacore::Complex> & vis) const = 0;
      75             :     // virtual void visibilityModel (casacore::Cube<casacore::Complex> & vis) const = 0;
      76             :     // virtual void weightSpectrum(casacore::Cube<casacore::Float> &weightSp) const = 0;
      77             :     // virtual void sigmaSpectrum (casacore::Cube<casacore::Float> &sigmaSp) const = 0;
      78             :     // virtual casacore::Vector<casacore::Double> getFrequencies (        casacore::Double time, casacore::Int frameOfReference,casacore::Int spectralWindowId, casacore::Int msId) const = 0;
      79             :     // virtual void writeFlag (const casacore::Cube<casacore::Bool> & flagCube) = 0;
      80             : 
      81             :     // Common transformation for all sub-classes
      82             :     void writeFlagRow (const casacore::Vector<casacore::Bool> & flag);
      83             :     casacore::Vector<casacore::Int> getChannels (casacore::Double time, casacore::Int frameOfReference,
      84             :                                                  casacore::Int spectralWindowId, casacore::Int msId) const;
      85             :     const casacore::Vector<casacore::Int>& nChannelsPerShape () const;
      86             : 
      87             :     void flagRow (casacore::Vector<casacore::Bool> & flagRow) const;
      88             :     void weight (casacore::Matrix<casacore::Float> & weight) const;
      89             :     void sigma (casacore::Matrix<casacore::Float> & sigma) const;
      90             : 
      91             : protected:
      92             : 
      93             :     // Method implementing main loop  (with auxiliary data)
      94           0 :         template <class T> void transformFreqAxis(        casacore::Cube<T> const &inputDataCube,
      95             :                                                                                                 casacore::Cube<T> &outputDataCube,
      96             :                                                                                                 FreqAxisTransformEngine<T> &transformer) const
      97             :         {
      98             :                 // Re-shape output data cube
      99           0 :                 outputDataCube.resize(getVisBuffer()->getShape(),false);
     100             : 
     101             :                 // Get data shape for iteration
     102           0 :                 const casacore::IPosition &inputShape = inputDataCube.shape();
     103           0 :                 casacore::rownr_t nRows = inputShape(2);
     104           0 :                 auto nCorrs = inputShape(0);
     105             : 
     106             :                 // Initialize input-output planes
     107           0 :                 casacore::Matrix<T> inputDataPlane;
     108           0 :                 casacore::Matrix<T> outputDataPlane;
     109             : 
     110             :                 // Initialize input-output vectors
     111           0 :                 casacore::Vector<T> inputDataVector;
     112           0 :                 casacore::Vector<T> outputDataVector;
     113             : 
     114           0 :                 for (casacore::rownr_t row=0; row < nRows; row++)
     115             :                 {
     116             :                         // Assign input-output planes by reference
     117           0 :                         transformer.setRowIndex(row);
     118           0 :                         inputDataPlane.reference(inputDataCube.xyPlane(row));
     119           0 :                         outputDataPlane.reference(outputDataCube.xyPlane(row));
     120             : 
     121           0 :                         for (ssize_t corr=0; corr < nCorrs; corr++)
     122             :                         {
     123             :                                 // Assign input-output vectors by reference
     124           0 :                                 transformer.setCorrIndex(corr);
     125           0 :                                 inputDataVector.reference(inputDataPlane.row(corr));
     126           0 :                                 outputDataVector.reference(outputDataPlane.row(corr));
     127             : 
     128             :                                 // Transform data
     129           0 :                                 transformer.transform(inputDataVector,outputDataVector);
     130             :                         }
     131             :                 }
     132             : 
     133           0 :                 return;
     134             :         }
     135             : 
     136             :     // Method implementing main loop  (with auxiliary data)
     137           0 :         template <class T> void transformFreqAxis2(       const casacore::IPosition &inputShape,
     138             :                                                                                                 FreqAxisTransformEngine2<T> &transformer,
     139             :                                                                                                 casacore::Int parallelCorrAxis=-1) const
     140             :         {
     141           0 :                 size_t nRows = inputShape(2);
     142           0 :                 if (parallelCorrAxis >= 0)
     143             :                 {
     144           0 :                         for (size_t row=0; row < nRows; row++)
     145             :                         {
     146           0 :                                 transformer.setRowIndex(row);
     147           0 :                                 transformer.setCorrIndex(parallelCorrAxis);
     148           0 :                                 transformer.transform();
     149             :                         }
     150             :                 }
     151             :                 else
     152             :                 {
     153           0 :                         size_t nCorrs = inputShape(0);
     154           0 :                         for (size_t row=0; row < nRows; row++)
     155             :                         {
     156           0 :                                 transformer.setRowIndex(row);
     157             : 
     158           0 :                                 for (size_t corr=0; corr < nCorrs; corr++)
     159             :                                 {
     160           0 :                                         transformer.setCorrIndex(corr);
     161             : 
     162             :                                         // jagonzal: Debug code
     163             :                                         /*
     164             :                                         VisBuffer2 *vb = getVii()->getVisBuffer();
     165             :                                         if (vb->rowIds()(row)==0 and corr==0)
     166             :                                         {
     167             :                                                 transformer.setDebug(True);
     168             :                                         }
     169             :                                         else
     170             :                                         {
     171             :                                                 transformer.setDebug(False);
     172             :                                         }
     173             :                                         */
     174           0 :                                         transformer.transform();
     175             :                                 }
     176             :                         }
     177             :                 }
     178             : 
     179           0 :                 return;
     180             :         }
     181             : 
     182             :         void initialize();
     183             : 
     184             :         // Form spwInpChanIdxMap_p via calls to underlying Vii
     185             :         void formChanMap();
     186             : 
     187             :     void configureShapes();
     188             : 
     189             :     casacore::Vector<casacore::Int> nChannPerShape_;
     190             : 
     191             :         mutable casacore::LogIO logger_p;
     192             :         mutable std::map<casacore::Int,casacore::uInt > spwOutChanNumMap_p; // Must be accessed from const methods
     193             :         mutable std::map<casacore::Int,std::vector<casacore::Int> > spwInpChanIdxMap_p; // Must be accessed from const methods
     194             : };
     195             : 
     196             : //////////////////////////////////////////////////////////////////////////
     197             : // FreqAxisTransformEngine class
     198             : //////////////////////////////////////////////////////////////////////////
     199             : 
     200             : template<class T> class FreqAxisTransformEngine
     201             : {
     202             : 
     203             : public:
     204             : 
     205           0 :         virtual void transform( casacore::Vector<T> &,casacore::Vector<T> &) {};
     206           0 :         virtual void setRowIndex(size_t row) {row_p = row;}
     207           0 :         virtual void setCorrIndex(size_t corr) {corr_p = corr;}
     208             : 
     209             : protected:
     210             : 
     211             :         size_t row_p;
     212             :         size_t corr_p;
     213             : 
     214             : };
     215             : 
     216             : //////////////////////////////////////////////////////////////////////////
     217             : // FreqAxisTransformEngine2 class
     218             : //////////////////////////////////////////////////////////////////////////
     219             : 
     220             : template<class T> class FreqAxisTransformEngine2
     221             : {
     222             : 
     223             : public:
     224             : 
     225           0 :         FreqAxisTransformEngine2(DataCubeMap *inputData,DataCubeMap *outputData)
     226           0 :         {
     227           0 :                 debug_p = false;
     228           0 :                 inputData_p = inputData;
     229           0 :                 outputData_p = outputData;
     230           0 :         }
     231             : 
     232           0 :         void setRowIndex(size_t row)
     233             :         {
     234           0 :                 rowIndex_p = row;
     235           0 :                 inputData_p->setMatrixIndex(row);
     236           0 :                 outputData_p->setMatrixIndex(row);
     237             : 
     238           0 :                 return;
     239             :         }
     240             : 
     241           0 :         void setCorrIndex(size_t corr)
     242             :         {
     243           0 :                 corrIndex_p = corr;
     244           0 :                 inputData_p->setVectorIndex(corr);
     245           0 :                 outputData_p->setVectorIndex(corr);
     246             : 
     247           0 :                 return;
     248             :         }
     249             : 
     250             :         void setDebug(bool debug) { debug_p = debug;}
     251             : 
     252           0 :         virtual void transform() {}
     253             : 
     254             : protected:
     255             : 
     256             :         casacore::Bool debug_p;
     257             :         size_t rowIndex_p;
     258             :         size_t corrIndex_p;
     259             :         DataCubeMap *inputData_p;
     260             :         DataCubeMap *outputData_p;
     261             : 
     262             : };
     263             : 
     264             : } //# NAMESPACE VI - END
     265             : 
     266             : } //# NAMESPACE CASA - END
     267             : 
     268             : #endif /* FreqAxisTVI_H_ */
     269             : 

Generated by: LCOV version 1.16