LCOV - code coverage report
Current view: top level - flagging/Flagging - FlagDataHandler.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 91 133 68.4 %
Date: 2024-11-06 17:42:47 Functions: 34 52 65.4 %

          Line data    Source code
       1             : //# FlagDataHandler.h: This file contains the interface definition of the FlagDataHandler 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 FLAGDATAHANDLER_H_
      24             : #define FLAGDATAHANDLER_H_
      25             : 
      26             : // VI/VB infrastructure
      27             : #include <msvis/MSVis/VisibilityIterator2.h>
      28             : 
      29             : // TVI framework
      30             : #include <msvis/MSVis/AveragingVi2Factory.h>
      31             : 
      32             : // Records interface
      33             : #include <casacore/casa/Containers/Record.h>
      34             : 
      35             : // casacore::Data mapping
      36             : #include <map>
      37             : 
      38             : namespace casa {
      39             :   namespace vi {
      40             :     enum class VisBufferComponent2;
      41             :   }
      42             : }
      43             : 
      44             : namespace casacore {
      45             : 
      46             :   class MSSelection;
      47             :   template <class M> class ScalarMeasColumn;
      48             : }
      49             : 
      50             : namespace casa { //# NAMESPACE CASA - BEGIN
      51             : 
      52             : // Type definitions
      53             : typedef std::map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::uInt> >::iterator antennaPairMapIterator;
      54             : typedef std::map< casacore::Double,std::vector<casacore::uInt> >::iterator subIntegrationMapIterator;
      55             : typedef std::map< casacore::uShort,casacore::uShort >::iterator polartizationMapIterator;
      56             : typedef std::map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::uInt> > antennaPairMap;
      57             : typedef std::map< casacore::Double,std::vector<casacore::uInt> > subIntegrationMap;
      58             : typedef std::map< casacore::uShort,casacore::uShort > polarizationMap;
      59             : typedef std::map< casacore::uInt,casacore::String > polarizationIndexMap;
      60             : typedef std::vector< std::vector<casacore::Double> > antennaPointingMap;
      61             : typedef std::map< casacore::Int,std::vector<casacore::Double> > scanStartStopMap;
      62             : typedef std::map< casacore::Int,casacore::Double > lambdaMap;
      63             : 
      64             : const casacore::Complex ImaginaryUnit = casacore::Complex(0,1);
      65             : 
      66             : // We need to have the CubeView definition here because its type is used by FlagDataHandler class
      67             : template<class T> class CubeView
      68             : {
      69             : 
      70             : public:
      71             : 
      72     1224154 :         CubeView(casacore::Cube<T> *parentCube, std::vector<casacore::uInt> *rows = NULL, std::vector<casacore::uInt> *channels = NULL, std::vector<casacore::uInt> *polarizations = NULL)
      73     1224154 :         {
      74     1224154 :                 parentCube_p = parentCube;
      75     1224154 :                 casacore::IPosition baseCubeShape = parentCube_p->shape();
      76     1224154 :                 reducedLength_p = casacore::IPosition(3);
      77             : 
      78           0 :                 if (((polarizations != NULL) and (polarizations->size() > 0)) and
      79     1224154 :                         ((channels != NULL) and (channels->size() > 0)) and
      80           0 :                         ((rows != NULL) and (rows->size() > 0)))
      81             :                 {
      82           0 :                         access_p = &CubeView::accessMapped;
      83             :                 }
      84     1224154 :                 else if (((polarizations != NULL) and (polarizations->size() > 0)) and
      85           0 :                                 ((channels != NULL) and (channels->size() > 0)))
      86             :                 {
      87           0 :                         access_p = &CubeView::accessIndex12Mapped;
      88             :                 }
      89     1224154 :                 else if (((polarizations != NULL) and (polarizations->size() > 0)) and
      90           0 :                                 ((rows != NULL) and (rows->size() > 0)))
      91             :                 {
      92           0 :                         access_p = &CubeView::accessIndex13Mapped;
      93             :                 }
      94     1286851 :                 else if (((channels != NULL) and (channels->size() > 0)) and
      95       62697 :                                 ((rows != NULL) and (rows->size() > 0)))
      96             :                 {
      97       62697 :                         access_p = &CubeView::accessIndex23Mapped;
      98             :                 }
      99     1161457 :                 else if ((polarizations != NULL) and (polarizations->size() > 0))
     100             :                 {
     101           0 :                         access_p = &CubeView::accessIndex1Mapped;
     102             :                 }
     103     1161457 :                 else if ((channels != NULL) and (channels->size() > 0))
     104             :                 {
     105     1161457 :                         access_p = &CubeView::accessIndex2Mapped;
     106             :                 }
     107           0 :                 else if ((rows != NULL) and (rows->size() > 0))
     108             :                 {
     109           0 :                         access_p = &CubeView::accessIndex3Mapped;
     110             :                 }
     111             :                 else
     112             :                 {
     113           0 :                         access_p = &CubeView::accessUnmapped;
     114             :                 }
     115             : 
     116     1224154 :                 if ((polarizations != NULL) and (polarizations->size() > 0))
     117             :                 {
     118           0 :                         polarizations_p = polarizations;
     119           0 :                         reducedLength_p(0) = polarizations_p->size();
     120             :                 }
     121             :                 else
     122             :                 {
     123     1224154 :                         polarizations_p = NULL;
     124     1224154 :                         reducedLength_p(0) = baseCubeShape(0);
     125             :                 }
     126             : 
     127     1224154 :                 if ((channels != NULL) and (channels->size() > 0))
     128             :                 {
     129     1224154 :                         channels_p = channels;
     130     1224154 :                         reducedLength_p(1) = channels_p->size();
     131             :                 }
     132             :                 else
     133             :                 {
     134           0 :                         channels_p = NULL;
     135           0 :                         reducedLength_p(1) = baseCubeShape(1);
     136             :                 }
     137             : 
     138     1224154 :                 if ((rows != NULL) and (rows->size() > 0))
     139             :                 {
     140       62697 :                         rows_p = rows;
     141       62697 :                         reducedLength_p(2) = rows_p->size();
     142             :                 }
     143             :                 else
     144             :                 {
     145     1161457 :                         rows_p = NULL;
     146     1161457 :                         reducedLength_p(2) = baseCubeShape(2);
     147             :                 }
     148     1224154 :         }
     149             : 
     150  3429082924 :     T &operator()(casacore::uInt i1, casacore::uInt i2, casacore::uInt i3)
     151             :     {
     152  3429082924 :         return (*this.*access_p)(i1,i2,i3);
     153             :     }
     154             : 
     155      634021 :     const casacore::IPosition &shape() const
     156             :     {
     157      634021 :         return reducedLength_p;
     158             :     }
     159             : 
     160             :     void shape(casacore::Int &s1, casacore::Int &s2, casacore::Int &s3) const
     161             :     {
     162             :         s1 = reducedLength_p(0);
     163             :         s2 = reducedLength_p(1);
     164             :         s3 = reducedLength_p(2);
     165             :         return;
     166             :     }
     167             : 
     168             : protected:
     169             : 
     170             :     std::vector<casacore::uInt> *createIndex(casacore::uInt size)
     171             :     {
     172             :         std::vector<casacore::uInt> *index = new std::vector<casacore::uInt>(size);
     173             :         index->clear();
     174             :         for (casacore::uInt i=0; i<size; i++ )
     175             :         {
     176             :                 index->push_back(i);
     177             :         }
     178             :         return index;
     179             :     }
     180             : 
     181           0 :     T &accessUnmapped(casacore::uInt i1, casacore::uInt i2, casacore::uInt i3)
     182             :     {
     183           0 :         return (*parentCube_p)(i1,i2,i3);
     184             :     }
     185             : 
     186           0 :     T &accessMapped(casacore::uInt i1, casacore::uInt i2, casacore::uInt i3)
     187             :     {
     188           0 :         casacore::uInt i1_index = polarizations_p->at(i1);
     189           0 :         casacore::uInt i2_index = channels_p->at(i2);
     190           0 :         casacore::uInt i3_index = rows_p->at(i3);
     191           0 :         return (*parentCube_p)(i1_index,i2_index,i3_index);
     192             :     }
     193             : 
     194           0 :     T &accessIndex1Mapped(casacore::uInt i1, casacore::uInt i2, casacore::uInt i3)
     195             :     {
     196           0 :         casacore::uInt i1_index = polarizations_p->at(i1);
     197           0 :         return (*parentCube_p)(i1_index,i2,i3);
     198             :     }
     199             : 
     200  1923636870 :     T &accessIndex2Mapped(casacore::uInt i1, casacore::uInt i2, casacore::uInt i3)
     201             :     {
     202  1923636870 :         casacore::uInt i2_index = channels_p->at(i2);
     203  1923636870 :         return (*parentCube_p)(i1,i2_index,i3);
     204             :     }
     205             : 
     206           0 :     T &accessIndex3Mapped(casacore::uInt i1, casacore::uInt i2, casacore::uInt i3)
     207             :     {
     208           0 :         casacore::uInt i3_index = rows_p->at(i3);
     209           0 :         return (*parentCube_p)(i1,i2,i3_index);
     210             :     }
     211             : 
     212           0 :     T &accessIndex12Mapped(casacore::uInt i1, casacore::uInt i2, casacore::uInt i3)
     213             :     {
     214           0 :         casacore::uInt i1_index = polarizations_p->at(i1);
     215           0 :         casacore::uInt i2_index = channels_p->at(i2);
     216           0 :         return (*parentCube_p)(i1_index,i2_index,i3);
     217             :     }
     218             : 
     219           0 :     T &accessIndex13Mapped(casacore::uInt i1, casacore::uInt i2, casacore::uInt i3)
     220             :     {
     221           0 :         casacore::uInt i1_index = polarizations_p->at(i1);
     222           0 :         casacore::uInt i3_index = rows_p->at(i3);
     223           0 :         return (*parentCube_p)(i1_index,i2,i3_index);
     224             :     }
     225             : 
     226  1505446054 :     T &accessIndex23Mapped(casacore::uInt i1, casacore::uInt i2, casacore::uInt i3)
     227             :     {
     228  1505446054 :         casacore::uInt i2_index = channels_p->at(i2);
     229  1505446054 :         casacore::uInt i3_index = rows_p->at(i3);
     230  1505446054 :         return (*parentCube_p)(i1,i2_index,i3_index);
     231             :     }
     232             : 
     233             : private:
     234             :     casacore::Cube<T> *parentCube_p;
     235             :         std::vector<casacore::uInt> *rows_p;
     236             :         std::vector<casacore::uInt> *channels_p;
     237             :         std::vector<casacore::uInt> *polarizations_p;
     238             :         casacore::IPosition reducedLength_p;
     239             :         T &(casa::CubeView<T>::*access_p)(casacore::uInt,casacore::uInt,casacore::uInt);
     240             : };
     241             : 
     242             : template<class T> class VectorView
     243             : {
     244             : 
     245             : public:
     246     1173314 :         VectorView(casacore::Vector<T> *parentVector, std::vector<casacore::uInt> *rows = NULL)
     247     1173314 :         {
     248     1173314 :                 casacore::IPosition parentVectorShape = parentVector->shape();
     249     1173314 :                 parentVector_p = parentVector;
     250     1173314 :                 reducedLength_p = casacore::IPosition(1);
     251             : 
     252     1173314 :                 if ((rows != NULL) and (rows->size() > 0))
     253             :                 {
     254       44798 :                         access_p = &VectorView::accessMapped;
     255             :                 }
     256             :                 else
     257             :                 {
     258     1128516 :                         access_p = &VectorView::accessUnmapped;
     259             :                 }
     260             : 
     261     1173314 :                 if ((rows != NULL) and (rows->size() > 0))
     262             :                 {
     263       44798 :                         rows_p = rows;
     264       44798 :                         reducedLength_p(0) = rows_p->size();
     265             :                 }
     266             :                 else
     267             :                 {
     268     1128516 :                         rows_p = NULL;
     269     1128516 :                         reducedLength_p(0) = parentVectorShape(0);
     270             :                 }
     271     1173314 :         }
     272             : 
     273     7339218 :     T &operator()(casacore::uInt i1)
     274             :     {
     275     7339218 :         return (*this.*access_p)(i1);
     276             :     }
     277             : 
     278             :     const casacore::IPosition &shape() const
     279             :     {
     280             :         return reducedLength_p;
     281             :     }
     282             : 
     283             :     void shape(casacore::Int &s1) const
     284             :     {
     285             :         s1 = reducedLength_p(0);
     286             :         return;
     287             :     }
     288             : 
     289             : protected:
     290             : 
     291             :     std::vector<casacore::uInt> *createIndex(casacore::uInt size)
     292             :     {
     293             :         std::vector<casacore::uInt> *index = new std::vector<casacore::uInt>(size);
     294             :         index->clear();
     295             :         for (casacore::uInt i=0; i<size; i++ )
     296             :         {
     297             :                 index->push_back(i);
     298             :         }
     299             :         return index;
     300             :     }
     301             : 
     302     7336194 :     T &accessUnmapped(casacore::uInt i1)
     303             :     {
     304     7336194 :         return parentVector_p->operator()(i1);
     305             :     }
     306             : 
     307        3024 :     T &accessMapped(casacore::uInt i1)
     308             :     {
     309        3024 :         casacore::uInt i1_index = rows_p->at(i1);
     310        3024 :         return parentVector_p->operator()(i1_index);
     311             :     }
     312             : 
     313             : private:
     314             :     casacore::Vector<T> *parentVector_p;
     315             :         std::vector<casacore::uInt> *rows_p;
     316             :         casacore::IPosition reducedLength_p;
     317             :         T &(casa::VectorView<T>::*access_p)(casacore::uInt);
     318             : };
     319             : 
     320             : class VisMapper
     321             : {
     322             :         typedef casacore::Complex (casa::VisMapper::*corrProduct)(casacore::uInt,casacore::uInt);
     323             : 
     324             : public:
     325             : 
     326             :         enum calsolutions {
     327             : 
     328             :                 CALSOL1=casacore::Stokes::NumberOfTypes,
     329             :                 CALSOL2,
     330             :                 CALSOL3,
     331             :                 CALSOL4
     332             :         };
     333             : 
     334             :         VisMapper(casacore::String expression,polarizationMap *polMap,CubeView<casacore::Complex> *leftVis,CubeView<casacore::Complex> *rightVis=NULL);
     335             :         VisMapper(casacore::String expression,polarizationMap *polMap);
     336             :         ~VisMapper();
     337             : 
     338             :     void setParentCubes(CubeView<casacore::Complex> *leftVis,CubeView<casacore::Complex> *rightVis=NULL);
     339             : 
     340       30876 :     std::vector< std::vector<casacore::uInt> > getSelectedCorrelations() { return selectedCorrelations_p;}
     341           0 :     std::vector< string > getSelectedCorrelationStrings() { return selectedCorrelationStrings_p;}
     342             : 
     343             :         casacore::Float operator()(casacore::uInt chan, casacore::uInt row);
     344             :         casacore::Float operator()(casacore::uInt pol, casacore::uInt chan, casacore::uInt row);
     345             : 
     346             :         // Direct access to the complex correlation product
     347             :         casacore::Complex correlationProduct(casacore::uInt pol, casacore::uInt chan, casacore::uInt row);
     348             : 
     349             :     // NOTE: reducedLength_p is defined as [chan,row,pol]
     350       17682 :     const casacore::IPosition &shape() const
     351             :     {
     352       17682 :         return reducedLength_p;
     353             :     }
     354             : 
     355             :     void shape(casacore::Int &chan, casacore::Int &row) const
     356             :     {
     357             :         chan = reducedLength_p(0);
     358             :         row = reducedLength_p(1);
     359             :         return;
     360             :     }
     361             : 
     362     1356700 :     void shape(casacore::Int &pol, casacore::Int &chan, casacore::Int &row) const
     363             :     {
     364     1356700 :         chan = reducedLength_p(0);
     365     1356700 :         row = reducedLength_p(1);
     366     1356700 :         pol = reducedLength_p(2);
     367     1356700 :         return;
     368             :     }
     369             : 
     370             : 
     371             : protected:
     372             :     void setExpressionMapping(casacore::String expression,polarizationMap *polMap);
     373     6454790 :         casacore::Float real(casacore::Complex val) {return val.real();}
     374           0 :         casacore::Float imag(casacore::Complex val) {return val.imag();}
     375   148368433 :         casacore::Float abs(casacore::Complex val) {return std::abs(val);}
     376           0 :         casacore::Float arg(casacore::Complex val) {return std::arg(val);}
     377     2854278 :         casacore::Float norm(casacore::Complex val) {return std::norm(val);}
     378             :         casacore::Complex leftVis(casacore::uInt pol, casacore::uInt chan, casacore::uInt row);
     379             :         casacore::Complex diffVis(casacore::uInt pol, casacore::uInt chan, casacore::uInt row);
     380             :         casacore::Complex stokes_i(casacore::uInt pol, casacore::uInt chan);
     381             :         casacore::Complex stokes_q(casacore::uInt pol, casacore::uInt chan);
     382             :         casacore::Complex stokes_u(casacore::uInt pol, casacore::uInt chan);
     383             :         casacore::Complex stokes_v(casacore::uInt pol, casacore::uInt chan);
     384             :         casacore::Complex linear_xx(casacore::uInt pol, casacore::uInt chan);
     385             :         casacore::Complex linear_yy(casacore::uInt pol, casacore::uInt chan);
     386             :         casacore::Complex linear_xy(casacore::uInt pol, casacore::uInt chan);
     387             :         casacore::Complex linear_yx(casacore::uInt pol, casacore::uInt chan);
     388             :         casacore::Complex circular_rr(casacore::uInt pol, casacore::uInt chan);
     389             :         casacore::Complex circular_ll(casacore::uInt pol, casacore::uInt chan);
     390             :         casacore::Complex circular_rl(casacore::uInt pol, casacore::uInt chan);
     391             :         casacore::Complex circular_lr(casacore::uInt pol, casacore::uInt chan);
     392             :         casacore::Complex stokes_i_from_linear(casacore::uInt chan, casacore::uInt row);
     393             :         casacore::Complex stokes_q_from_linear(casacore::uInt chan, casacore::uInt row);
     394             :         casacore::Complex stokes_u_from_linear(casacore::uInt chan, casacore::uInt row);
     395             :         casacore::Complex stokes_v_from_linear(casacore::uInt chan, casacore::uInt row);
     396             :         casacore::Complex stokes_i_from_circular(casacore::uInt chan, casacore::uInt row);
     397             :         casacore::Complex stokes_q_from_circular(casacore::uInt chan, casacore::uInt row);
     398             :         casacore::Complex stokes_u_from_circular(casacore::uInt chan, casacore::uInt row);
     399             :         casacore::Complex stokes_v_from_circular(casacore::uInt chan, casacore::uInt row);
     400             :         casacore::Complex calsol1(casacore::uInt chan, casacore::uInt row);
     401             :         casacore::Complex calsol2(casacore::uInt chan, casacore::uInt row);
     402             :         casacore::Complex calsol3(casacore::uInt chan, casacore::uInt row);
     403             :         casacore::Complex calsol4(casacore::uInt chan, casacore::uInt row);
     404             : 
     405             : 
     406             : private:
     407             :         casacore::Float (casa::VisMapper::*applyVisExpr_p)(casacore::Complex);
     408             :         casacore::Complex (casa::VisMapper::*getVis_p)(casacore::uInt,casacore::uInt,casacore::uInt);
     409             :         // casacore::Complex (casa::VisMapper::*getCorr_p)(casacore::uInt,casacore::uInt);
     410             :     std::vector<corrProduct> selectedCorrelationProducts_p;
     411             :     std::vector< std::vector<casacore::uInt> > selectedCorrelations_p;
     412             :     std::vector<string> selectedCorrelationStrings_p;
     413             :         CubeView<casacore::Complex> *leftVis_p;
     414             :         CubeView<casacore::Complex> *rightVis_p;
     415             :         casacore::IPosition reducedLength_p;
     416             :         polarizationMap *polMap_p;
     417             :         casacore::String expression_p;
     418             : };
     419             : 
     420             : class FlagMapper
     421             : {
     422             : 
     423             : public:
     424             : 
     425             :         FlagMapper(casacore::Bool flag, std::vector < std::vector<casacore::uInt> > selectedCorrelations,
     426             :                                                         CubeView<casacore::Bool> *commonFlagsView,
     427             :                                                         CubeView<casacore::Bool> *originalFlagsView,
     428             :                                                         CubeView<casacore::Bool> *privateFlagsView=NULL,
     429             :                                                         VectorView<casacore::Bool> *commonFlagRowView=NULL,
     430             :                                                         VectorView<casacore::Bool> *originalFlagRowView=NULL,
     431             :                                                         VectorView<casacore::Bool> *privateFlagRowView=NULL);
     432             :         FlagMapper(casacore::Bool flag,std::vector< std::vector<casacore::uInt> > selectedCorrelations);
     433             :         ~FlagMapper();
     434             : 
     435             :         void setParentCubes(CubeView<casacore::Bool> *commonFlagsView,CubeView<casacore::Bool> *originalFlagsView,CubeView<casacore::Bool> *privateFlagsView=NULL);
     436             :         void setParentFlagRow(VectorView<casacore::Bool> *commonFlagRowView,VectorView<casacore::Bool> *originalFlagRowView,VectorView<casacore::Bool> *privateFlagRowView=NULL);
     437             : 
     438             :         void applyFlag(casacore::uInt chan, casacore::uInt row);
     439             :         void applyFlag(casacore::uInt pol, casacore::uInt channel, casacore::uInt row);
     440             :         void applyFlagRow(casacore::uInt row);
     441             :         void applyFlagInRow(casacore::uInt row);
     442             : 
     443             :         casacore::Bool getOriginalFlags(casacore::uInt chan, casacore::uInt row);
     444             :         casacore::Bool getModifiedFlags(casacore::uInt chan, casacore::uInt row);
     445             :         casacore::Bool getPrivateFlags(casacore::uInt chan, casacore::uInt row);
     446             : 
     447             :         casacore::Bool getOriginalFlags(casacore::uInt pol, casacore::uInt channel, casacore::uInt row);
     448             :         casacore::Bool getModifiedFlags(casacore::uInt pol, casacore::uInt channel, casacore::uInt row);
     449             :         casacore::Bool getPrivateFlags(casacore::uInt pol, casacore::uInt channel, casacore::uInt row);
     450             : 
     451             :         // These methods are needed for flag extension
     452             :         void setModifiedFlags(casacore::uInt pol, casacore::uInt channel, casacore::uInt row);
     453             :         void setPrivateFlags(casacore::uInt pol, casacore::uInt channel, casacore::uInt row);
     454             : 
     455             :         casacore::Bool getOriginalFlagRow(casacore::uInt row);
     456             :         casacore::Bool getModifiedFlagRow(casacore::uInt row);
     457             :         casacore::Bool getPrivateFlagRow(casacore::uInt row);
     458             : 
     459        4812 :     const casacore::IPosition &shape() const
     460             :     {
     461        4812 :         return reducedLength_p;
     462             :     }
     463             : 
     464     4661962 :     void shape(casacore::Int &chan, casacore::Int &row) const
     465             :     {
     466     4661962 :         chan = reducedLength_p(0);
     467     4661962 :         row = reducedLength_p(1);
     468     4661962 :         return;
     469             :     }
     470             : 
     471        4812 :     void shape(casacore::Int &pol, casacore::Int &chan, casacore::Int &row) const
     472             :     {
     473        4812 :         chan = reducedLength_p(0);
     474        4812 :         row = reducedLength_p(1);
     475        4812 :         pol = reducedLength_p(2);
     476        4812 :         return;
     477             :     }
     478             : 
     479     4661962 :     std::vector< std::vector<casacore::uInt> > getSelectedCorrelations() {return selectedCorrelations_p;}
     480             : 
     481           0 :     void activateCheckMode() {applyFlag_p = &FlagMapper::checkCommonFlags;}
     482             : 
     483             :     casacore::uInt nSelectedCorrelations() {return nSelectedCorrelations_p;}
     484     8686533 :     casacore::uInt flagsPerRow() {return flagsPerRow_p;}
     485             : 
     486             : protected:
     487             : 
     488             :         void setExpressionMapping(std::vector< std::vector<casacore::uInt> > selectedCorrelations);
     489             : 
     490             :         // Apply flags to common flag cube
     491             :         void applyCommonFlags(casacore::uInt pol, casacore::uInt channel, casacore::uInt row);
     492             :         // Apply flags to common and private flag cubes
     493             :         void applyPrivateFlags(casacore::uInt pol, casacore::uInt channel, casacore::uInt row);
     494             :         // Apply flags to common and private flag cubes
     495             :         void checkCommonFlags(casacore::uInt pol, casacore::uInt channel, casacore::uInt row);
     496             : 
     497             :         // Apply flags to common flag rows
     498             :         void applyCommonFlagRow(casacore::uInt row);
     499             :         // Apply flags to common and private flag rows
     500             :         void applyPrivateFlagRow(casacore::uInt row);
     501             : 
     502             : private:
     503             : 
     504             :         casacore::Bool flag_p;
     505             :     casacore::IPosition reducedLength_p;
     506             :         CubeView<casacore::Bool> *commonFlagsView_p;
     507             :         CubeView<casacore::Bool> *originalFlagsView_p;
     508             :         CubeView<casacore::Bool> *privateFlagsView_p;
     509             :         VectorView<casacore::Bool> *commonFlagRowView_p;
     510             :         VectorView<casacore::Bool> *originalFlagRowView_p;
     511             :         VectorView<casacore::Bool> *privateFlagRowView_p;
     512             :     std::vector< std::vector<casacore::uInt> > selectedCorrelations_p;
     513             :         casacore::uInt nSelectedCorrelations_p;
     514             :         casacore::uInt flagsPerRow_p;
     515             :         void (casa::FlagMapper::*applyFlag_p)(casacore::uInt,casacore::uInt,casacore::uInt);
     516             :         void (casa::FlagMapper::*applyFlagRow_p)(casacore::uInt);
     517             : };
     518             : 
     519             : // <summary>
     520             : // A top level class defining the data handling interface for the flagging module
     521             : // </summary>
     522             : //
     523             : // <use visibility=export>
     524             : //
     525             : // <prerequisite>
     526             : //   <li> <linkto class="VisBuffer:description">VisBuffer</linkto>
     527             : //   <li> <linkto class="FlagMapper:description">FlagMapper</linkto>
     528             : //   <li> <linkto class="VisMapper:description">VisMapper</linkto>
     529             : // </prerequisite>
     530             : //
     531             : // <etymology>
     532             : // FlagDataHandler stands for generic data handling (i.e. MSs, CalTables, ...) specific to the flagging module
     533             : // </etymology>
     534             : //
     535             : // <synopsis>
     536             : //
     537             : // This is a top-level class defining the data handling interface for the flagging module.
     538             : // There are various methods (virtual) that must be re-implemented by the specific derived
     539             : // classes (e.g. FlagMSHandler, FlagCalTableHandler). These methods essentially cover:
     540             : //
     541             : // - casacore::Table access (i.e. open/close/iteration/rw)
     542             : //
     543             : // - casacore::Table selection (i.e. expression parsing, sub-table selection)
     544             : //
     545             : // Additionally there are public non-virtual methods to:
     546             : //
     547             : // - Set configuration parameters (pre-sort columns, data selection, time interval, async I/O)
     548             : //
     549             : // - Enable and access different kinds of mapping (baselines, correlation products, antenna pointing)
     550             : //
     551             : // Also at this top level there are public members which are used by the FlagAgent classes,
     552             : // so that there is no dependency with the specific implementation classes (e.g. FlagMsHandler,
     553             : // FlagCalTableHandler), and thus no re-implementation is required at the FlagAgent level.
     554             : //
     555             : // - VisBuffer (for accessing the data and meta data columns)
     556             : //
     557             : // - Chunk and casacore::Table flag counters (for statistics)
     558             : //
     559             : // </synopsis>
     560             : //
     561             : // <motivation>
     562             : // The motivation for the FlagDataHandler class is having all the data operations encapsulated
     563             : // in one single class, with a common interface for all types of tables (MSs, CalTables, SingleDish),
     564             : // so that no specific specific table type implementation has to be done at the FlagAgent level.
     565             : // </motivation>
     566             : //
     567             : // <example>
     568             : // <srcblock>
     569             : //
     570             : // // The following code sets up a FlagDataHandler with either CalTable or casacore::MS implementation and
     571             : // // iterates through the table applying a clip agent, flushing the flags, and extracting summaries.
     572             : //
     573             : // // IMPORTANT NOTE:
     574             : // // The order of FlagDataHandler and FlagAgent initialization is critical to have everything right,
     575             : // // in particular data selection must happen before initializing FlagAgents, and iterator generation
     576             : // // must be done after initializing FlagAgents, so that each agent can communicate to the FlagDataHandler
     577             : // // which columns have to be pre-fetched (async i/o or parallel mode), and what mapping options are necessary.
     578             : //
     579             : // // NOTE ON ASYNC I/O:
     580             : // // Asyncnronous I/O is only enabled for casacore::MS-type tables, but not for CalTables, and it is necessary to switch
     581             : // // it on before generating the iterators. Something else to take into account, is that there are 2 global
     582             : // // switches at .casarc level which invalidate the application code selection:
     583             : // //
     584             : // // VisibilityIterator.async.enabled rules over
     585             : // // |-> FlagDataHandler.asyncio, and in turns rules over
     586             : // //     |-> FlagDataHandler.enableAsyncIO(true)
     587             : //
     588             : // // Identify table type
     589             : // casacore::Table table(msname_p,casacore::TableLock(TableLock::AutoNoReadLocking));
     590             : // casacore::TableInfo& info = table.tableInfo();
     591             : // casacore::String type=info.type();
     592             : //
     593             : // // Create derived FlagDataHandler object with corresponding implementation
     594             : // FlagDataHandler *fdh_p = NULL;
     595             : // if (type == "Measurement Set")
     596             : // {
     597             : //    fdh_p = new FlagMSHandler(msname_p, FlagDataHandler::COMPLETE_SCAN_UNMAPPED, timeInterval_p);
     598             : // }
     599             : // else
     600             : // {
     601             : //    fdh_p = new FlagCalTableHandler(msname_p, FlagDataHandler::COMPLETE_SCAN_UNMAPPED, timeInterval_p);
     602             : // }
     603             : //
     604             : // // NOTE: It is also possible to independently set the iteration approach via the setIterationApproach
     605             : // //       method which accepts the following modes, defined in the FlagDataHandler iteration enumeration
     606             : // //
     607             : // //       COMPLETE_SCAN_MAPPED:
     608             : // //       - casacore::Sort by OBSERVATION_ID, ARRAY_ID, SCAN_NUMBER, FIELD_ID, DATA_DESC_ID and TIME
     609             : // //       - Group all time steps together, so that there is no sub-chunk iteration
     610             : // //       - Generate baseline maps (to iterate trough rows with the same antenna1, antenna2)
     611             : // //       - Generate sub-integration maps (to iterate trough rows with the same timestamp)
     612             : // //       COMPLETE_SCAN_MAP_SUB_INTEGRATIONS_ONLY:
     613             : // //       - casacore::Sort by OBSERVATION_ID, ARRAY_ID, SCAN_NUMBER, FIELD_ID, DATA_DESC_ID and TIME
     614             : // //       - Group all time steps together, so that there is no sub-chunk iteration
     615             : // //       * Don't generate baseline maps
     616             : // //       - Generate sub-integration maps (to iterate trough rows with the same timestamp)
     617             : // //       COMPLETE_SCAN_MAP_ANTENNA_PAIRS_ONLY:
     618             : // //       - casacore::Sort by OBSERVATION_ID, ARRAY_ID, SCAN_NUMBER, FIELD_ID, DATA_DESC_ID and TIME
     619             : // //       - Group all time steps together, so that there is no sub-chunk iteration
     620             : // //       - Generate baseline maps (to iterate trough rows with the same antenna1, antenna2)
     621             : // //       * Don't generate sub-integration maps
     622             : // //       COMPLETE_SCAN_UNMAPPED:
     623             : // //       - casacore::Sort by OBSERVATION_ID, ARRAY_ID, SCAN_NUMBER, FIELD_ID, DATA_DESC_ID and TIME
     624             : // //       - Group all time steps together, so that there is no sub-chunk iteration
     625             : // //       * Don't generate baseline maps
     626             : // //       * Don't generate sub-integration maps
     627             : // //       COMBINE_SCANS_MAPPED:
     628             : // //       - casacore::Sort by OBSERVATION_ID, ARRAY_ID, FIELD_ID, DATA_DESC_ID and TIME
     629             : // //       - Group all time steps together, so that there is no sub-chunk iteration
     630             : // //       - Generate baseline maps (to iterate trough rows with the same antenna1, antenna2)
     631             : // //       - Generate sub-integration maps (to iterate trough rows with the same timestamp)
     632             : // //       COMBINE_SCANS_MAP_SUB_INTEGRATIONS_ONLY:
     633             : // //       - casacore::Sort by OBSERVATION_ID, ARRAY_ID, FIELD_ID, DATA_DESC_ID and TIME
     634             : // //       - Group all time steps together, so that there is no sub-chunk iteration
     635             : // //       * Don't generate baseline maps
     636             : // //       - Generate sub-integration maps (to iterate trough rows with the same timestamp)
     637             : // //       COMBINE_SCANS_MAP_ANTENNA_PAIRS_ONLY:
     638             : // //       - casacore::Sort by OBSERVATION_ID, ARRAY_ID, FIELD_ID, DATA_DESC_ID and TIME
     639             : // //       - Group all time steps together, so that there is no sub-chunk iteration
     640             : // //       - Generate baseline maps (to iterate trough rows with the same antenna1, antenna2)
     641             : // //       * Don't generate sub-integration maps
     642             : // //       COMBINE_SCANS_UNMAPPED:
     643             : // //       - casacore::Sort by OBSERVATION_ID, ARRAY_ID, FIELD_ID, DATA_DESC_ID and TIME
     644             : // //       - Group all time steps together, so that there is no sub-chunk iteration
     645             : // //       * Don't generate baseline maps
     646             : // //       * Don't generate sub-integration maps
     647             : // //       ANTENNA_PAIR:
     648             : // //       - casacore::Sort by OBSERVATION_ID, ARRAY_ID, FIELD_ID, ANTENNA1, ANTENNA2, DATA_DESC_ID and TIME
     649             : // //       - Group all time steps together, so that there is no sub-chunk iteration
     650             : // //       * Don't generate baseline maps (they are not necessary because the chunks have constant ANTENNA1,ANTENNA2)
     651             : // //       * Don't generate sub-integration maps
     652             : // //       SUB_INTEGRATION:
     653             : // //       - casacore::Sort by OBSERVATION_ID, ARRAY_ID, SCAN_NUMBER, FIELD_ID, DATA_DESC_ID and TIME
     654             : // //       - Don't group all time steps together, so it is necessary to add an inner sub-chunk iteration loop
     655             : // //       * Don't generate baseline maps (it is not possible because not all the rows corresponding to a given baseline are available)
     656             : // //       * Don't generate sub-integration maps (they are not necessary because the sub-chunks have constant TIME)
     657             : // //       ARRAY_FIELD:
     658             : // //       - casacore::Sort by OBSERVATION_ID, ARRAY_ID, FIELD_ID, DATA_DESC_ID and TIME
     659             : // //       - Don't group all time steps together, so it is necessary to add an inner sub-chunk iteration loop
     660             : // //       * Don't generate baseline maps (it is not possible because not all the rows corresponding to a given baseline are available)
     661             : // //       * Don't generate sub-integration maps (they are not necessary because the sub-chunks have constant TIME)
     662             : // //       * NOTE: This is the iteration approach used by the old flagger framework
     663             : //
     664             : // // Open table
     665             : // fdh_p->open();
     666             : //
     667             : // // Parse data selection to Flag casacore::Data Handler
     668             : // fdh_p->setDataSelection(dataSelection);
     669             : //
     670             : // // Select data (thus creating selected table)
     671             : // fdh_p->selectData();
     672             : //
     673             : // // Create flagging agent and list
     674             : // casacore::Record agentConfig;
     675             : // agentConfig.define("mode","clip")
     676             : // FlagAgentBase *agent = FlagAgentBase::create(fdh_p,agentConfig);
     677             : // FlagAgentList agentList;
     678             : // agentList.push_back(agent);
     679             : //
     680             : // // Switch on/off async i/p
     681             : // fdh_p->enableAsyncIO(true);
     682             : //
     683             : // // Generate table iterator
     684             : // fdh_p->generateIterator();
     685             : //
     686             : // // Start Flag Agent
     687             : // agentList.start();
     688             : //
     689             : // // Iterates over chunks (constant column values)
     690             : // while (fdh_p->nextChunk())
     691             : // {
     692             : //    // Iterates over buffers (time steps)
     693             : //    while (fdh_p->nextBuffer())
     694             : //    {
     695             : //       // Apply flags
     696             : //       agentList.apply();
     697             : //       // Flush flag cube
     698             : //       fdh_p->flushFlags();
     699             : //    }
     700             : //
     701             : //    // Print end-of-chunk statistics
     702             : //    agentList.chunkSummary();
     703             : // }
     704             : //
     705             : // // Print total stats from each agent
     706             : // agentList.msSummary();
     707             : //
     708             : // // Stop Flag Agent
     709             : // agentList.terminate();
     710             : // agentList.join();
     711             : //
     712             : // // Close MS
     713             : // fdh_p->close();
     714             : //
     715             : // // Clear Flag Agent List
     716             : // agentList.clear();
     717             : //
     718             : // </srcblock>
     719             : // </example>
     720             : //
     721             : // <example>
     722             : // <srcblock>
     723             : //
     724             : // // The following code shows the FlagAgent-FlagDataHandler interaction works internally:
     725             : //
     726             : // // First of all, at construction time, each agent has to communicate to the FlagDataHandler
     727             : // // which columns have to be pre-fetched (for async i/o or parallel mode) and what mapping
     728             : // // options are necessary
     729             : 
     730             : // // ...for instance in the case of FlagAgentShadow we need Ant1,Ant2,UVW,TimeCentroid and PhaseCenter:
     731             : // flagDataHandler_p->preLoadColumn(vi::Antenna1);
     732             : // flagDataHandler_p->preLoadColumn(vi::Antenna2);
     733             : // flagDataHandler_p->preLoadColumn(vi::uvw);
     734             : // flagDataHandler_p->preLoadColumn(vi::TimeCentroid);
     735             : // flagDataHandler_p->preLoadColumn(vi::PhaseCenter);
     736             : //
     737             : // // ...and FlagAgentElevation needs to have the antenna pointing information globally available for each chunk:
     738             : // flagDataHandler_p->setMapAntennaPointing(true);
     739             : //
     740             : // // Then, at iteration time, the FlagAgentBase class has access to the VisBuffer held
     741             : // // in the FlagDataHandler, in order to retrieve the meta-data columns needed for the
     742             : // // data selection engine (agent-level row filtering).
     743             : // // NOTE: The VisBuffer is actually held within an auto-pointer wrapper,
     744             : // //       thus there is an additional get() involved when accessing it.
     745             : //
     746             : // if (spwList_p.size())
     747             : // {
     748             : //    if (!find(spwList_p,visibilityBuffer_p->get()->spectralWindow())) return false;
     749             : // }
     750             : //
     751             : // // The sorting columns used for the iteration are also accessible to optimize the selection engine:
     752             : // // (e.g.: If scan is constant check only 1st row)
     753             : // if ( (scanList_p.size()>0) and (find(flagDataHandler_p->sortOrder_p,casacore::MS::SCAN_NUMBER)==true) )
     754             : // {
     755             : //    if (!find(scanList_p,visibilityBuffer_p->get()->scan()[0])) return false;
     756             : // }
     757             : //
     758             : // // Once that chunk/rows are evaluated as eligible for the flagging process
     759             : // // by the data selection engine, the previously booked maps at construction
     760             : // // time can be access in order to iterate trough the data as desired:
     761             : // // e.g.: Baseline (antenna pairs) iteration
     762             : // for (myAntennaPairMapIterator=flagDataHandler_p->getAntennaPairMap()->begin();
     763             : //      myAntennaPairMapIterator != flagDataHandler_p->getAntennaPairMap()->end();
     764             : //      ++myAntennaPairMapIterator)
     765             : // {
     766             : //    // NOTE: The following code is also encapsulated in the FlagAgentBase::processAntennaPair(casacore::Int antenna1,casacore::Int antenna2) code
     767             : //
     768             : //    // From the antenna map we can retrieve the rows corresponding to the baseline defined by the antenna pair
     769             : //    std::vector<casacore::uInt> baselineRows = (*flagDataHandler_p->getAntennaPairMap())[std::make_pair(antennaPair.first,antennaPair.second)];
     770             : //
     771             : //    // This rows can be now inserted in the mapper classes (VisMapper and FlagMapper using the CubeView<T> template class)
     772             : //    VisMapper visibilitiesMap = VisMapper(expression_p,flagDataHandler_p->getPolarizationMap());
     773             : //    FlagMapper flagsMap = FlagMapper(flag_p,visibilitiesMap.getSelectedCorrelations());
     774             : //    setVisibilitiesMap(antennaRows,&visibilitiesMap);
     775             : //    setFlagsMap(antennaRows,&flagsMap);
     776             : // }
     777             : //
     778             : // // Finally, after flagging time, the FlagAgent can communicate to the FlagDataHandler
     779             : // // that the modified FlagCube has to be flushed to disk, this is a small but very important
     780             : // // step in order to avoid unnecessary I/O activity when a chunk is not eligible for flagging
     781             : // // or the auto-flagging algorithms don't produce any flags.
     782             : //
     783             : // // If any row was flagged, then we have to flush the flagRow
     784             : // if (flagRow_p) flagDataHandler_p->flushFlagRow_p = true;
     785             : // // If any flag was raised, then we have to flush the flagCube
     786             : // if (visBufferFlags_p>0) flagDataHandler_p->flushFlags_p = true;
     787             : //
     788             : // </srcblock>
     789             : // </example>
     790             : 
     791             : class FlagDataHandler
     792             : {
     793             : 
     794             : public:
     795             : 
     796             :         enum iteration {
     797             : 
     798             :                 COMPLETE_SCAN_MAPPED=0,
     799             :                 COMPLETE_SCAN_MAP_SUB_INTEGRATIONS_ONLY,
     800             :                 COMPLETE_SCAN_MAP_ANTENNA_PAIRS_ONLY,
     801             :                 COMPLETE_SCAN_UNMAPPED,
     802             :                 COMBINE_SCANS_MAPPED,
     803             :                 COMBINE_SCANS_MAP_SUB_INTEGRATIONS_ONLY,
     804             :                 COMBINE_SCANS_MAP_ANTENNA_PAIRS_ONLY,
     805             :                 COMBINE_SCANS_UNMAPPED,
     806             :                 ANTENNA_PAIR,
     807             :                 SUB_INTEGRATION,
     808             :                 ARRAY_FIELD
     809             :         };
     810             : 
     811             :         enum tableType {
     812             : 
     813             :                 MEASUREMENT_SET=0,
     814             :                 CALIBRATION_TABLE
     815             :         };
     816             : 
     817             :         // Default constructor
     818             :         // NOTE: casacore::Time interval 0 groups all time steps together in one chunk.
     819             :         FlagDataHandler(string msname, casacore::uShort iterationApproach = SUB_INTEGRATION, casacore::Double timeInterval = 0);
     820             : 
     821             :         // Default destructor
     822             :         virtual ~FlagDataHandler();
     823             : 
     824             :         // Common casacore::MS/CalTables public interface
     825             :         virtual bool open() = 0;
     826             :         virtual bool close() = 0;
     827             :         virtual bool selectData() = 0;
     828             :         virtual bool generateIterator() = 0;
     829             :         virtual bool nextChunk() = 0;
     830             :         virtual bool nextBuffer() = 0;
     831             :         virtual bool flushFlags() = 0;
     832             :         virtual casacore::String getTableName() = 0;
     833             :         virtual bool parseExpression(casacore::MSSelection &/*parser*/) = 0;
     834             :         virtual bool checkIfColumnExists(casacore::String /*column*/) = 0;
     835           0 :         virtual bool checkIfSourceModelColumnExists() {return false;}
     836             :         virtual bool summarySignal() = 0;
     837             : 
     838             :         // Set the iteration approach
     839             :         void setIterationApproach(casacore::uShort iterationApproach);
     840             : 
     841             :         // Set casacore::Data Selection parameters
     842             :         bool setDataSelection(casacore::Record record);
     843             : 
     844             :         // Set time interval (also known as ntime)
     845             :         void setTimeInterval(casacore::Double timeInterval);
     846             : 
     847             :         // Methods to switch on/off async i/o
     848             :         void enableAsyncIO(casacore::Bool enable);
     849             : 
     850             :         // Pre-Load columns (in order to avoid parallelism problems when not using
     851             :         // async i/o, and also to know what columns to pre-fetch in async i/o mode)
     852             :         void preLoadColumn(VisBufferComponent2 column);
     853             :         void preFetchColumns();
     854             : 
     855             :         // Stop iterating
     856           0 :         void stopIteration() {stopIteration_p = true;};
     857             : 
     858             :         // As requested by Urvashi R.V. provide access to the original and modified flag cubes
     859      795219 :         casacore::Cube<casacore::Bool> * getModifiedFlagCube() {return &modifiedFlagCube_p;}
     860      795219 :         casacore::Cube<casacore::Bool> * getOriginalFlagCube() {return &originalFlagCube_p;}
     861      795219 :         casacore::Vector<casacore::Bool> * getModifiedFlagRow() {return &modifiedFlagRow_p;}
     862      795219 :         casacore::Vector<casacore::Bool> * getOriginalFlagRow() {return &originalFlagRow_p;}
     863             : 
     864             :         // Functions to switch on/off mapping functions
     865             :         void setMapAntennaPairs(bool activated);
     866             :         void setMapSubIntegrations(bool activated);
     867             :         void setMapPolarizations(bool activated);
     868             :         void setMapAntennaPointing(bool activated);
     869             :         void setScanStartStopMap(bool activated);
     870             :         void setScanStartStopFlaggedMap(bool activated);
     871             :     void setTimeAverageIter(bool activated);
     872             :     void setChanAverageIter(casacore::Vector<casacore::Int> chanbin);
     873             : 
     874             :         // Accessors for the mapping functions
     875       70452 :         antennaPairMap * getAntennaPairMap() {return antennaPairMap_p;}
     876             :         subIntegrationMap * getSubIntegrationMap() {return subIntegrationMap_p;}
     877       62055 :         polarizationMap * getPolarizationMap() {return polarizationMap_p;}
     878     4661962 :         polarizationIndexMap * getPolarizationIndexMap() {return polarizationIndexMap_p;}
     879             :         antennaPointingMap * getMapAntennaPointing() {return antennaPointingMap_p;}
     880     1140576 :         scanStartStopMap * getMapScanStartStop() {return scanStartStopMap_p;}
     881       17184 :         lambdaMap * getLambdaMap() {return lambdaMap_p;}
     882             : 
     883             :         void setProfiling(casacore::Bool value) {profiling_p=value;}
     884             : 
     885             :         // Get a casacore::Float visCube and return a casacore::Complex one
     886             :         casacore::Cube<casacore::Complex>& weightVisCube();
     887             :         casacore::Cube<casacore::Complex> weight_spectrum_p;
     888             : 
     889             :         // Make the logger public to that we can use it from FlagAgentBase::create
     890             :         casacore::LogIO *logger_p;
     891             : 
     892             :         // Measurement set section
     893             :         casacore::String tablename_p;
     894             :         casacore::MSSelection *measurementSetSelection_p;
     895             :         casacore::Vector<casacore::String> *antennaNames_p;
     896             :         std::map< string, std::pair<casacore::Int,casacore::Int> > baselineToAnt1Ant2_p;
     897             :         std::map< std::pair<casacore::Int,casacore::Int>, string > Ant1Ant2ToBaseline_p;
     898             :         casacore::ScalarMeasColumn<casacore::MPosition> *antennaPositions_p;
     899             :         casacore::Vector<casacore::Double> *antennaDiameters_p;
     900             :         casacore::Vector<casacore::String> *fieldNames_p;
     901             :         std::vector<casacore::String> *corrProducts_p;
     902             : 
     903             :         // RO Visibility Iterator
     904             :         VisBufferComponents2 *prefetchColumns_p;
     905             :         // Iteration counters
     906             :         size_t processedRows_p;
     907             :         size_t chunkNo_p;
     908             :         size_t bufferNo_p;
     909             : 
     910             :         // FlagDataHanler-FlagAgents interaction
     911             :         bool flushFlags_p;
     912             :         bool flushFlagRow_p;
     913             :         // per-chunk flag count
     914             :         casacore::uInt64 chunkCounts_p;
     915             :         // cummulative counter throughout chunks (flagged so far)
     916             :         casacore::uInt64 progressCounts_p;
     917             :         casacore::uInt64 msCounts_p;
     918             :         bool printChunkSummary_p;
     919             : 
     920             :         // control report/logging frequency for the per-agent partial (ongoing) summaries
     921             :         casacore::uInt summaryThreshold_p;
     922             :         const casacore::uInt summaryThresholdInc_p = 10;
     923             :         // control report/logging frequency for the per-chunk progress report lines
     924             :         casacore::uInt chunkLineThreshold_p;
     925             :         const casacore::uInt chunkLineThresholdInc_p = 10;
     926             : 
     927             :         casacore::uShort tableTye_p;
     928             :         casacore::Bool loadProcessorTable_p;
     929             : 
     930             :         // PROCESSOR sub-table section
     931             :         casacore::Vector<bool> isCorrelatorType_p;
     932             :         bool processorTableExist_p;
     933             : 
     934             : 
     935             :         // Visibility Buffer
     936             :         // WARNING: The attach mechanism only works with pointers or
     937             :         // referenced variables. Otherwise the VisBuffer is created
     938             :         // and attached, but when it is assigned to the member it is
     939             :         // detached because of the dynamically called destructor
     940             :         vi::VisBuffer2 *visibilityBuffer_p;
     941             : 
     942             :         // Vis buffer characteristics (constant values)
     943             :         bool groupTimeSteps_p;
     944             :         casacore::Block<int> sortOrder_p;
     945             : 
     946             :     // casacore::Time average iterator parameters
     947             :     casacore::Bool enableTimeAvg_p;
     948             :     casacore::Bool enableChanAvg_p;
     949             :     casacore::Double timeAverageBin_p;
     950             :     casacore::Vector <casacore::Int> chanAverageBin_p;
     951             :     casacore::String dataColumnType_p;
     952             :     vi::AveragingOptions timeAvgOptions_p;
     953             :     casacore::Record chanAvgOptions_p;
     954             : 
     955             : protected:
     956             : 
     957             :         // Common casacore::MS/CalTables private interface
     958             :         virtual void generateAntennaPairMap();
     959             :         virtual void generateSubIntegrationMap();
     960             :         virtual void generatePolarizationsMap();
     961             :         virtual void generateAntennaPointingMap();
     962             :         virtual void generateScanStartStopMap();
     963             : 
     964             :         // casacore::Data Selection ranges
     965             :         bool anySelection_p;
     966             :         bool inrowSelection_p;
     967             :         casacore::String arraySelection_p;
     968             :         casacore::String fieldSelection_p;
     969             :         casacore::String scanSelection_p;
     970             :         casacore::String timeSelection_p;
     971             :         casacore::String spwSelection_p;
     972             :         casacore::String baselineSelection_p;
     973             :         casacore::String uvwSelection_p;
     974             :         casacore::String polarizationSelection_p;
     975             :         casacore::String scanIntentSelection_p;
     976             :         casacore::String observationSelection_p;
     977             : 
     978             :         // Async I/O stuff
     979             :         bool asyncio_enabled_p;
     980             :         // Pre-Load columns (in order to avoid parallelism problems when not using
     981             :         // async i/o, and also to know what columns to pre-fetch in async i/o mode)
     982             :     std::vector<VisBufferComponent2> preLoadColumns_p;
     983             : 
     984             :         // Iteration parameters
     985             :         casacore::uShort iterationApproach_p;
     986             :         casacore::Double timeInterval_p;
     987             :         // Slurp flag
     988             :         bool slurp_p;
     989             :         // Iteration initialization parameters
     990             :         bool chunksInitialized_p;
     991             :         bool buffersInitialized_p;
     992             :         bool iteratorGenerated_p;
     993             :         bool stopIteration_p;
     994             : 
     995             :         // Flag Cubes
     996             :         casacore::Cube<casacore::Bool> originalFlagCube_p;
     997             :         casacore::Cube<casacore::Bool> modifiedFlagCube_p;
     998             : 
     999             :         // FlagRows
    1000             :         casacore::Vector<casacore::Bool> originalFlagRow_p;
    1001             :         casacore::Vector<casacore::Bool> modifiedFlagRow_p;
    1002             : 
    1003             :         // Mapping members
    1004             :         antennaPairMap *antennaPairMap_p;
    1005             :         subIntegrationMap *subIntegrationMap_p;
    1006             :         polarizationMap *polarizationMap_p;
    1007             :         polarizationIndexMap *polarizationIndexMap_p;
    1008             :         antennaPointingMap *antennaPointingMap_p;
    1009             :         scanStartStopMap *scanStartStopMap_p;
    1010             :         lambdaMap *lambdaMap_p;
    1011             :         bool mapAntennaPairs_p;
    1012             :         bool mapSubIntegrations_p;
    1013             :         bool mapPolarizations_p;
    1014             :         bool mapAntennaPointing_p;
    1015             :         bool mapScanStartStop_p;
    1016             :         bool mapScanStartStopFlagged_p;
    1017             : 
    1018             :         // Stats members
    1019             :         bool stats_p;
    1020             :         casacore::uLong cubeAccessCounter_p;
    1021             :         double cubeAccessTime_p;
    1022             :         casacore::uLong cubeAccessCounterTotal_p;
    1023             :         double cubeAccessTimeTotal_p;
    1024             : 
    1025             :         // Profiling
    1026             :         bool profiling_p;
    1027             : };
    1028             : 
    1029             : } //# NAMESPACE CASA - END
    1030             : 
    1031             : #endif /* FLAGDATAHANDLER_H_ */

Generated by: LCOV version 1.16