casa
$Rev:20696$
|
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 <flagging/Flagging/RFChunkStats.h> 00032 #include <casa/Logging/LogIO.h> 00033 #include <casa/Containers/Record.h> 00034 00035 namespace casa { //# NAMESPACE CASA - BEGIN 00036 00037 // <summary> 00038 // Abstract RedFlagger Agent base class 00039 // </summary> 00040 00041 // <use visibility=local> 00042 00043 // <reviewed reviewer="" date="" tests="" demos=""> 00044 // </reviewed> 00045 00046 // <synopsis> 00047 // RFABase defines the interface for a flagging agent 00048 // </synopsis> 00049 // 00050 // <motivation> 00051 // RedFlagger works with objetcs called flagging agents. This class 00052 // defines the complete interface between RedFlagger and agents. 00053 // </motivation> 00054 // 00055 // <todo asof="2001/04/16"> 00056 // <li> add this feature 00057 // </todo> 00058 00059 class RFABase : public FlaggerEnums 00060 { 00061 public: 00062 // iteration modes 00063 enum IterMode { 00064 STOP = 0, 00065 DRY = 1, 00066 DATA = 2, 00067 00068 CONT = 3 00069 }; 00070 00071 // An agent is always constructed from a chunk stats accessor, and a 00072 // record of parameters. No other constructors are defined, and no others 00073 // may be used. 00074 RFABase ( RFChunkStats &ch,const RecordInterface &parm ); 00075 // Destructor 00076 virtual ~RFABase () {}; 00077 00078 // This method is called after constructing the agent. 00079 virtual void init (); 00080 00081 // This method is called before iterating over a chunk, to inquire the 00082 // expected memory use. Should return the max desired memory footprint, in MB. 00083 // Available physical memory is divided between agents in proportion to their 00084 // requests. 00085 virtual uInt estimateMemoryUse () { return 1; } 00086 00087 // Called before iterating over a chunk. Returns True if agent will 00088 // process this chunk, or False if this the agent is unable to process it. 00089 // (this can happen if, e.g., the requisite correlations are not present). 00090 // The Int & maxmem argument is the number of MB memory which is still 00091 // available in the memory pool. The agent class should plan its memory 00092 // use accordingly, and subtract its expected memory use from maxmem. In effect, 00093 // the agent "reserves" some amount of memory. This is used by RedFlagger to 00094 // contain the total memory footprint. Note that only a rough reckoning 00095 // is sufficient, so only bother estimating the biggest data structures. 00096 // See implementations in RFADiffBase and RFATimeMedian for good examples. 00097 // nAgent is the total number of agents. 00098 virtual Bool newChunk (Int &) 00099 { return active=False; }; 00100 // Called once finished with a chunk 00101 virtual void endChunk () {} 00102 00103 // Called before starting a data pass on a chunk. 00104 virtual void startData (bool /* verbose */) {}; 00105 00106 // Called before starting a dry pass on a chunk. 00107 virtual void startDry (bool /* verbose */) {}; 00108 00109 // Called before starting the fetch-flags pass. 00110 virtual void startFlag (bool /* verbose */) {}; 00111 00112 // Called after a pass is completed successfully (i.e., not stopped 00113 // by start or iter methods). Return value: STOP to stop, DATA for 00114 // another data pass, DRY for another dry pass. 00115 virtual IterMode endData () { return STOP; }; 00116 00117 // Called after a dry pass is complete 00118 virtual IterMode endDry () { return STOP; }; 00119 00120 // Called after a flag pass is complete 00121 virtual void endFlag () {}; 00122 00123 // Called at end of time chunk 00124 virtual void endRows(uInt /* itime */) {}; 00125 00126 // Iteration methods for a data pass. Either or both may be implemented. 00127 // iterTime() is called once for each new VisBuffer (= new time slot) 00128 // Return value: STOP to finish iterating, CONT/DATA to continue, or DRY 00129 // to cancel the data pass and request a dry pass. 00130 virtual IterMode iterTime ( uInt /* itime */ ) { return CONT; }; 00131 00132 // iterRow() is called once per each row in the VisBuffer. 00133 // Iterating over rows is perhaps preferrable in terms of performance, 00134 // at least for data iterations. 00135 virtual IterMode iterRow ( uInt /* irow */ ) { return CONT; }; 00136 00137 // Iteration method for a dry pass. Called once per each time slot. 00138 // Return value: STOP to finish iterating, CONT/DRY to continue, or DATA 00139 // to cancel the dry pass and request another data pass. 00140 virtual IterMode iterDry ( uInt /* itime */ ) { return CONT; }; 00141 00142 // Iteration method for a flag pass. Called once per each VisBuffer. 00143 virtual void iterFlag ( uInt /* itime */ ) {} 00144 00145 // called to obtain a short description of this RFA 00146 virtual String getDesc () { return ""; } 00147 // called (before endChunk()) to obtain a statistics report 00148 virtual String getStats () { return ""; } 00149 00150 virtual void printFlaggingReport ( ) {}; 00151 00152 virtual String getID() {return String("");}; 00153 00154 // returns the name of this RFA (set in myname) 00155 const String & name (); 00156 // returns the active status 00157 Bool isActive () { return active; } 00158 // accessor to a LogIO for this agent 00159 LogIO & logSink (); 00160 00161 // static method for setting the indexing base for agent arguments 00162 static void setIndexingBase ( uInt base ); 00163 00164 virtual Record getResult( ) { return Record(); }; 00165 00166 virtual void finalize() {}; 00167 // Initialize chunk 00168 virtual void initialize() {}; 00169 virtual void initializeIter(uInt /* iter */) {}; 00170 virtual void finalizeIter(uInt /* iter */) {}; 00171 00172 virtual void setNAgent(uInt n) { nAgent = n; }; 00173 virtual void setOnlySelector(bool only_sel) { only_selector = only_sel; }; 00174 00175 protected: 00176 uInt nAgent; 00177 RFChunkStats &chunk; 00178 Record params; 00179 String myname; 00180 bool only_selector; //Do only RFASelector agents exist? 00181 00182 uInt num (StatEnums which) { return chunk.num(which); }; 00183 00184 // Bit mask of correlations which are used & flagged by this RFA. This mask is 00185 // used to (a) interpret the pre-flags of the FLAG column, and (b) apply the 00186 // resulting flags to the FLAG column 00187 RFlagWord corrmask; 00188 RFlagWord corrMask() { return corrmask; } 00189 00190 // flag: agent is active for this chunk (set in newChunk) 00191 Bool active; 00192 00193 LogIO os; 00194 00195 // global flag indicates that Glish (1-based) indexing is in use 00196 // for agent arguments 00197 static uInt indexingBase (); 00198 00199 private: 00200 00201 static uInt indexing_base; 00202 }; 00203 00204 inline uInt RFABase::indexingBase () 00205 { 00206 return indexing_base; 00207 } 00208 00209 inline void RFABase::setIndexingBase ( uInt base ) 00210 { 00211 indexing_base = base; 00212 } 00213 00214 inline LogIO & RFABase::logSink () 00215 { 00216 return os; 00217 } 00218 inline const String & RFABase::name () 00219 { 00220 return myname; 00221 } 00222 00223 00224 } //# NAMESPACE CASA - END 00225 00226 #endif