00001 //# RFABase.h: this defines RFABase 00002 //# Copyright (C) 2000,2001 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id$ 00027 #ifndef FLAGGING_RFABASE_H 00028 #define FLAGGING_RFABASE_H 00029 00030 #include <casa/Arrays/Cube.h> 00031 #include <lattices/Lattices/TempLattice.h> 00032 #include <lattices/Lattices/LatticeIterator.h> 00033 #include <flagging/Flagging/RFChunkStats.h> 00034 #include <casa/Logging/LogIO.h> 00035 #include <casa/Containers/Record.h> 00036 00037 namespace casa { //# NAMESPACE CASA - BEGIN 00038 00039 // <summary> 00040 // Abstract RedFlagger Agent base class 00041 // </summary> 00042 00043 // <use visibility=local> 00044 00045 // <reviewed reviewer="" date="" tests="" demos=""> 00046 // </reviewed> 00047 00048 // <synopsis> 00049 // RFABase defines the interface for a flagging agent 00050 // </synopsis> 00051 // 00052 // <motivation> 00053 // RedFlagger works with objetcs called flagging agents. This class 00054 // defines the complete interface between RedFlagger and agents. 00055 // </motivation> 00056 // 00057 // <todo asof="2001/04/16"> 00058 // <li> add this feature 00059 // </todo> 00060 00061 class RFABase : public FlaggerEnums 00062 { 00063 public: 00064 // iteration modes 00065 enum IterMode { 00066 STOP = 0, 00067 DRY = 1, 00068 DATA = 2, 00069 00070 CONT = 3 00071 }; 00072 00073 // An agent is always constructed from a chunk stats accessor, and a 00074 // record of parameters. No other constructors are defined, and no others 00075 // may be used. 00076 RFABase ( RFChunkStats &ch,const RecordInterface &parm ); 00077 // Destructor 00078 virtual ~RFABase () {}; 00079 00080 // This method is called after constructing the agent. 00081 virtual void init (); 00082 00083 // This method is called before iterating over a chunk, to inquire the 00084 // expected memory use. Should return the max desired memory footprint, in MB. 00085 // Available physical memory is divided between agents in proportion to their 00086 // requests. 00087 virtual uInt estimateMemoryUse () { return 1; } 00088 00089 // Called before iterating over a chunk. Returns True if agent will 00090 // process this chunk, or False if this the agent is unable to process it. 00091 // (this can happen if, e.g., the requisite correlations are not present). 00092 // The Int & maxmem argument is the number of MB memory which is still 00093 // available in the memory pool. The agent class should plan its memory 00094 // use accordingly, and subtract its expected memory use from maxmem. In effect, 00095 // the agent "reserves" some amount of memory. This is used by RedFlagger to 00096 // contain the total memory footprint. Note that only a rough reckoning 00097 // is sufficient, so only bother estimating the biggest data structures. 00098 // See implementations in RFADiffBase and RFATimeMedian for good examples. 00099 virtual Bool newChunk (Int &) 00100 { return active=False; }; 00101 // Called once finished with a chunk 00102 virtual void endChunk () {} 00103 00104 // Called before starting a data pass on a chunk. 00105 virtual void startData () {}; 00106 // Called before starting a dry pass on a chunk. 00107 virtual void startDry () {}; 00108 // Called before starting the fetch-flags pass. 00109 virtual void startFlag () {}; 00110 // Called after a pass is completed successfully (i.e., not stopped 00111 // by start or iter methods). Return value: STOP to stop, DATA for 00112 // another data pass, DRY for another dry pass. 00113 virtual IterMode endData () { return STOP; }; 00114 // Called after a dry pass is complete 00115 virtual IterMode endDry () { return STOP; }; 00116 // Called after a flag pass is complete 00117 virtual void endFlag () {}; 00118 00119 // Iteration methods for a data pass. Either or both may be implemented. 00120 // iterTime() is called once for each new VisBuffer (= new time slot) 00121 // Return value: STOP to finish iterating, CONT/DATA to continue, or DRY 00122 // to cancel the data pass and request a dry pass. 00123 virtual IterMode iterTime ( uInt itime ) { return CONT; }; 00124 // iterRow() is called once per each row in the VisBuffer. 00125 // Iterating over rows is perhaps preferrable in terms of performance, 00126 // at least for data iterations. 00127 virtual IterMode iterRow ( uInt irow ) { return CONT; }; 00128 // Iteration method for a dry pass. Called once per each time slot. 00129 // Return value: STOP to finish iterating, CONT/DRY to continue, or DATA 00130 // to cancel the dry pass and request another data pass. 00131 virtual IterMode iterDry ( uInt itime ) { return CONT; }; 00132 // Iteration method for a flag pass. Called once per each VisBuffer. 00133 virtual void iterFlag ( uInt itime ) {} 00134 // called to obtain a short description of this RFA 00135 virtual String getDesc () { return ""; } 00136 // called (before endChunk()) to obtain a statistics report 00137 virtual String getStats () { return ""; } 00138 // called (before endChunk()) to plots a graphical flagging report 00139 virtual void plotFlaggingReport ( PGPlotterInterface & ) {}; 00140 virtual void printFlaggingReport ( ) {}; 00141 00142 virtual String getID() {return String("");}; 00143 00144 // returns the name of this RFA (set in myname) 00145 const String & name (); 00146 // returns the active status 00147 Bool isActive () { return active; } 00148 // accessor to a LogIO for this agent 00149 LogIO & logSink (); 00150 00151 // static method for setting the indexing base for agent arguments 00152 static void setIndexingBase ( uInt base ); 00153 00154 virtual Record getResult( ) { return Record(); }; 00155 00156 virtual void finalize() {}; 00157 virtual void initialize() {}; 00158 virtual void initializeIter(uInt iter) {}; 00159 virtual void finalizeIter(uInt iter) {}; 00160 00161 protected: 00162 RFChunkStats &chunk; 00163 Record params; 00164 String myname; 00165 00166 uInt num (StatEnums which) { return chunk.num(which); }; 00167 00168 // Bit mask of correlations which are used & flagged by this RFA. This mask is 00169 // used to (a) interpret the pre-flags of the FLAG column, and (b) apply the 00170 // resulting flags to the FLAG column 00171 RFlagWord corrmask; 00172 RFlagWord corrMask() { return corrmask; } 00173 00174 // flag: agent is active for this chunk (set in newChunk) 00175 Bool active; 00176 00177 LogIO os; 00178 00179 // global flag indicates that Glish (1-based) indexing is in use 00180 // for agent arguments 00181 static uInt indexingBase (); 00182 00183 private: 00184 00185 static uInt indexing_base; 00186 }; 00187 00188 inline uInt RFABase::indexingBase () 00189 { 00190 return indexing_base; 00191 } 00192 00193 inline void RFABase::setIndexingBase ( uInt base ) 00194 { 00195 indexing_base = base; 00196 } 00197 00198 inline LogIO & RFABase::logSink () 00199 { 00200 return os; 00201 } 00202 inline const String & RFABase::name () 00203 { 00204 return myname; 00205 } 00206 00207 00208 } //# NAMESPACE CASA - END 00209 00210 #endif
1.5.1