LCOV - code coverage report
Current view: top level - flagging/Flagging - RFABase.h (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 0 35 0.0 %
Date: 2023-11-06 10:06:49 Functions: 0 31 0.0 %

          Line data    Source code
       1             : //# RFABase.h: this defines RFABase
       2             : //# Copyright (C) 2000,2001
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This library is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU Library General Public License as published by
       7             : //# the Free Software Foundation; either version 2 of the License, or (at your
       8             : //# option) any later version.
       9             : //#
      10             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      11             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      13             : //# License for more details.
      14             : //#
      15             : //# You should have received a copy of the GNU Library General Public License
      16             : //# along with this library; if not, write to the Free Software Foundation,
      17             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed as follows:
      20             : //#        Internet email: aips2-request@nrao.edu.
      21             : //#        Postal address: AIPS++ Project Office
      22             : //#                        National Radio Astronomy Observatory
      23             : //#                        520 Edgemont Road
      24             : //#                        Charlottesville, VA 22903-2475 USA
      25             : //#
      26             : //# $Id$
      27             : #ifndef FLAGGING_RFABASE_H
      28             : #define FLAGGING_RFABASE_H
      29             : 
      30             : #include <casacore/casa/Arrays/Cube.h> 
      31             : #include <flagging/Flagging/RFChunkStats.h>
      32             : #include <casacore/casa/Logging/LogIO.h>
      33             : #include <casacore/casa/Containers/Record.h>
      34             : 
      35             : namespace casa { //# NAMESPACE CASA - BEGIN
      36             : 
      37             : // <summary>
      38             : // Abstract RedFlagger Agent base class
      39             : // </summary>
      40             : 
      41             : // <use visibility=local>
      42             : 
      43             : // <reviewed reviewer="" date="" tests="" demos="">
      44             : // </reviewed>
      45             : 
      46             : // <synopsis>
      47             : // RFABase defines the interface for a flagging agent
      48             : // </synopsis>
      49             : //
      50             : // <motivation>
      51             : // RedFlagger works with objetcs called flagging agents. This class
      52             : // defines the complete interface between RedFlagger and agents.
      53             : // </motivation>
      54             : //
      55             : // <todo asof="2001/04/16">
      56             : //   <li> add this feature
      57             : // </todo>
      58             : 
      59             : class RFABase : public FlaggerEnums
      60             : {
      61             : public:
      62             : // iteration modes
      63             :   enum IterMode { 
      64             :       STOP = 0,
      65             :       DRY  = 1,
      66             :       DATA = 2,
      67             :           
      68             :       CONT = 3
      69             :   };
      70             :   
      71             : // An agent is always constructed from a chunk stats accessor, and a 
      72             : // record of parameters. No other constructors are defined, and no others
      73             : // may be used.
      74             :   RFABase ( RFChunkStats &ch,const casacore::RecordInterface &parm );
      75             : // Destructor 
      76           0 :   virtual ~RFABase () {};
      77             : 
      78             : // This method is called after constructing the agent.
      79             :   virtual void init ();
      80             : 
      81             : // This method is called before iterating over a chunk, to inquire the 
      82             : // expected memory use. Should return the max desired memory footprint, in MB.
      83             : // Available physical memory is divided between agents in proportion to their 
      84             : // requests.
      85           0 :   virtual casacore::uInt estimateMemoryUse () { return 1; }  
      86             : 
      87             : // Called before iterating over a chunk. Returns true if agent will
      88             : // process this chunk, or false if this the agent is unable to process it.
      89             : // (this can happen if, e.g., the requisite correlations are not present).
      90             : // The casacore::Int & maxmem argument is the number of MB memory which is still 
      91             : // available in the memory pool. The agent class should plan its memory 
      92             : // use accordingly, and subtract its expected memory use from maxmem. In effect, 
      93             : // the agent "reserves" some amount of memory. This is used by RedFlagger to 
      94             : // contain the total memory footprint. Note that only a rough reckoning
      95             : // is sufficient, so only bother estimating the biggest data structures.
      96             : // See implementations in RFADiffBase and RFATimeMedian for good examples.
      97             : // nAgent is the total number of agents.
      98           0 :   virtual casacore::Bool newChunk (casacore::Int &) 
      99           0 :          { return active=false; };
     100             : // Called once finished with a chunk
     101           0 :   virtual void endChunk () {}
     102             :   
     103             : // Called before starting a data pass on a chunk. 
     104           0 :   virtual void startData (bool /* verbose */) {};
     105             : 
     106             : // Called before starting a dry pass on a chunk. 
     107           0 :   virtual void startDry  (bool /* verbose */) {};
     108             : 
     109             : // Called before starting the fetch-flags pass.
     110           0 :   virtual void startFlag (bool /* verbose */) {};
     111             : 
     112             : // Called after a pass is completed successfully (i.e., not stopped
     113             : // by start or iter methods). Return value: STOP to stop, DATA for 
     114             : // another data pass, DRY for another dry pass.
     115           0 :   virtual IterMode endData   () { return STOP; };
     116             : 
     117             : // Called after a dry pass is complete
     118           0 :   virtual IterMode endDry    () { return STOP; };
     119             : 
     120             : // Called after a flag pass is complete
     121           0 :   virtual void endFlag () {};
     122             : 
     123             : // Called at end of time chunk
     124           0 : virtual void endRows(casacore::uInt /* itime */) {};
     125             :   
     126             : // Iteration methods for a data pass. Either or both may be implemented.
     127             : // iterTime() is called once for each new VisBuffer (= new time slot)
     128             : // Return value: STOP to finish iterating, CONT/DATA to continue, or DRY
     129             : // to cancel the data pass and request a dry pass.
     130           0 :   virtual IterMode iterTime ( casacore::uInt /* itime */ ) { return CONT; };
     131             : 
     132             : // iterRow() is called once per each row in the VisBuffer.
     133             : // Iterating over rows is perhaps preferrable in terms of performance,
     134             : // at least for data iterations.
     135           0 :   virtual IterMode iterRow  ( casacore::uInt /* irow */ ) { return CONT; };
     136             : 
     137             : // Iteration method for a dry pass. Called once per each time slot.
     138             : // Return value: STOP to finish iterating, CONT/DRY to continue, or DATA
     139             : // to cancel the dry pass and request another data pass.
     140           0 :   virtual IterMode iterDry  ( casacore::uInt /* itime */ ) { return CONT; };
     141             : 
     142             : // Iteration method for a flag pass. Called once per each VisBuffer.
     143           0 :   virtual void iterFlag ( casacore::uInt /* itime */ ) {}
     144             : 
     145             : // called to obtain a short description of this RFA
     146           0 :   virtual casacore::String getDesc () { return ""; }
     147             : // called (before endChunk()) to obtain a statistics report 
     148           0 :   virtual casacore::String getStats () { return ""; }
     149             : 
     150           0 :   virtual void printFlaggingReport ( ) {};
     151             : 
     152           0 :   virtual casacore::String getID() {return casacore::String("");};
     153             :   
     154             : // returns the name of this RFA (set in myname)
     155             :   const casacore::String & name ();
     156             : // returns the active status
     157             :   casacore::Bool isActive ()   { return active; }
     158             : // accessor to a casacore::LogIO for this agent
     159             :   casacore::LogIO & logSink ();
     160             : 
     161             : // static method for setting the indexing base for agent arguments
     162             :   static void setIndexingBase ( casacore::uInt base );
     163             : 
     164           0 :   virtual casacore::Record getResult( ) { return casacore::Record(); };
     165             : 
     166           0 :   virtual void finalize() {};
     167             :   // Initialize chunk
     168           0 :   virtual void initialize() {};
     169           0 :   virtual void initializeIter(casacore::uInt /* iter */) {};
     170           0 :   virtual void finalizeIter(casacore::uInt /* iter */) {};
     171             : 
     172           0 :   virtual void setNAgent(casacore::uInt n) { nAgent = n; };
     173           0 :   virtual void setOnlySelector(bool only_sel) { only_selector = only_sel; };
     174             : 
     175             : protected:
     176             :   casacore::uInt nAgent;
     177             :   RFChunkStats &chunk;
     178             :   casacore::Record params;
     179             :   casacore::String myname;
     180             :   bool only_selector;  //Do only RFASelector agents exist?
     181             : 
     182           0 :   casacore::uInt num (StatEnums which) { return chunk.num(which); };
     183             : 
     184             : // Bit mask of correlations which are used & flagged by this RFA. This mask is
     185             : // used to (a) interpret the pre-flags of the FLAG column, and (b) apply the
     186             : // resulting flags to the FLAG column
     187             :   RFlagWord corrmask;
     188             :   RFlagWord corrMask()  { return corrmask; }
     189             : 
     190             : // flag: agent is active for this chunk (set in newChunk)  
     191             :   casacore::Bool active;
     192             : 
     193             :   casacore::LogIO os;
     194             :   
     195             : // global flag indicates that Glish (1-based) indexing is in use
     196             : // for agent arguments
     197             :   static casacore::uInt indexingBase (); 
     198             :   
     199             : private:
     200             :     
     201             :   static casacore::uInt indexing_base;
     202             : };
     203             : 
     204           0 : inline casacore::uInt RFABase::indexingBase () 
     205             : { 
     206           0 :   return indexing_base; 
     207             : }
     208             : 
     209           0 : inline void RFABase::setIndexingBase ( casacore::uInt base ) 
     210             : { 
     211           0 :   indexing_base = base; 
     212           0 : }
     213             :   
     214             : inline casacore::LogIO & RFABase::logSink ()
     215             : {
     216             :   return os;
     217             : }
     218           0 : inline const casacore::String & RFABase::name ()
     219             : {
     220           0 :   return myname;
     221             : }
     222             : 
     223             : 
     224             : } //# NAMESPACE CASA - END
     225             : 
     226             : #endif

Generated by: LCOV version 1.16