casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFABase.h
Go to the documentation of this file.
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 <casa/Arrays/Cube.h>
32 #include <casa/Logging/LogIO.h>
33 #include <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.
75 // Destructor
76  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  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.
99  { return active=false; };
100 // Called once finished with a chunk
101  virtual void endChunk () {}
102 
103 // Called before starting a data pass on a chunk.
104  virtual void startData (bool /* verbose */) {};
105 
106 // Called before starting a dry pass on a chunk.
107  virtual void startDry (bool /* verbose */) {};
108 
109 // Called before starting the fetch-flags pass.
110  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  virtual IterMode endData () { return STOP; };
116 
117 // Called after a dry pass is complete
118  virtual IterMode endDry () { return STOP; };
119 
120 // Called after a flag pass is complete
121  virtual void endFlag () {};
122 
123 // Called at end of time chunk
124 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  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  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  virtual IterMode iterDry ( casacore::uInt /* itime */ ) { return CONT; };
141 
142 // Iteration method for a flag pass. Called once per each VisBuffer.
143  virtual void iterFlag ( casacore::uInt /* itime */ ) {}
144 
145 // called to obtain a short description of this RFA
146  virtual casacore::String getDesc () { return ""; }
147 // called (before endChunk()) to obtain a statistics report
148  virtual casacore::String getStats () { return ""; }
149 
150  virtual void printFlaggingReport ( ) {};
151 
152  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
158 // accessor to a casacore::LogIO for this agent
160 
161 // static method for setting the indexing base for agent arguments
162  static void setIndexingBase ( casacore::uInt base );
163 
164  virtual casacore::Record getResult( ) { return casacore::Record(); };
165 
166  virtual void finalize() {};
167  // Initialize chunk
168  virtual void initialize() {};
169  virtual void initializeIter(casacore::uInt /* iter */) {};
170  virtual void finalizeIter(casacore::uInt /* iter */) {};
171 
172  virtual void setNAgent(casacore::uInt n) { nAgent = n; };
173  virtual void setOnlySelector(bool only_sel) { only_selector = only_sel; };
174 
175 protected:
180  bool only_selector; //Do only RFASelector agents exist?
181 
182  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
189 
190 // flag: agent is active for this chunk (set in newChunk)
192 
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 
202 };
203 
205 {
206  return indexing_base;
207 }
208 
210 {
211  indexing_base = base;
212 }
213 
215 {
216  return os;
217 }
219 {
220  return myname;
221 }
222 
223 
224 } //# NAMESPACE CASA - END
225 
226 #endif
static casacore::uInt indexing_base
Definition: RFABase.h:201
int Int
Definition: aipstype.h:50
RFlagWord corrMask()
Definition: RFABase.h:188
virtual IterMode iterRow(casacore::uInt)
iterRow() is called once per each row in the VisBuffer.
Definition: RFABase.h:135
casacore::uInt RFlagWord
RFAs use bitwise flags.
Definition: RFCommon.h:41
virtual void startDry(bool)
Called before starting a dry pass on a chunk.
Definition: RFABase.h:107
virtual casacore::String getDesc()
called to obtain a short description of this RFA
Definition: RFABase.h:146
virtual casacore::Bool newChunk(casacore::Int &)
Called before iterating over a chunk.
Definition: RFABase.h:98
virtual ~RFABase()
Destructor.
Definition: RFABase.h:76
virtual void startFlag(bool)
Called before starting the fetch-flags pass.
Definition: RFABase.h:110
virtual IterMode endData()
Called after a pass is completed successfully (i.e., not stopped by start or iter methods)...
Definition: RFABase.h:115
virtual void endRows(casacore::uInt)
Called at end of time chunk.
Definition: RFABase.h:124
casacore::LogIO & logSink()
accessor to a casacore::LogIO for this agent
Definition: RFABase.h:214
virtual void endFlag()
Called after a flag pass is complete.
Definition: RFABase.h:121
virtual IterMode endDry()
Called after a dry pass is complete.
Definition: RFABase.h:118
static casacore::uInt indexingBase()
global flag indicates that Glish (1-based) indexing is in use for agent arguments ...
Definition: RFABase.h:204
ostream-like interface to creating log messages.
Definition: LogIO.h:167
casacore::Bool isActive()
returns the active status
Definition: RFABase.h:157
casacore::uInt num(StatEnums which) const
returns a data dimension (POL, CHAN, IFR, etc.)
Definition: RFChunkStats.h:168
virtual casacore::uInt estimateMemoryUse()
This method is called before iterating over a chunk, to inquire the expected memory use...
Definition: RFABase.h:85
bool only_selector
Definition: RFABase.h:180
IterMode
iteration modes
Definition: RFABase.h:63
static void setIndexingBase(casacore::uInt base)
static method for setting the indexing base for agent arguments
Definition: RFABase.h:209
virtual casacore::Record getResult()
Definition: RFABase.h:164
virtual void initializeIter(casacore::uInt)
Definition: RFABase.h:169
RFlagWord corrmask
Bit mask of correlations which are used &amp; flagged by this RFA.
Definition: RFABase.h:182
virtual casacore::String getID()
Definition: RFABase.h:152
RFChunkStats & chunk
Definition: RFABase.h:177
virtual void endChunk()
Called once finished with a chunk.
Definition: RFABase.h:101
casacore::LogIO os
Definition: RFABase.h:193
virtual void finalizeIter(casacore::uInt)
Definition: RFABase.h:170
virtual IterMode iterTime(casacore::uInt)
Iteration methods for a data pass.
Definition: RFABase.h:130
virtual casacore::String getStats()
called (before endChunk()) to obtain a statistics report
Definition: RFABase.h:148
virtual void printFlaggingReport()
Definition: RFABase.h:150
casacore::uInt nAgent
Definition: RFABase.h:173
virtual void finalize()
Definition: RFABase.h:166
virtual IterMode iterDry(casacore::uInt)
Iteration method for a dry pass.
Definition: RFABase.h:140
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Bool active
flag: agent is active for this chunk (set in newChunk)
Definition: RFABase.h:191
FlaggerEnums: collection of enums for various flagger classes.
Definition: RFCommon.h:126
Abstract RedFlagger Agent base class.
Definition: RFABase.h:59
virtual void initialize()
Initialize chunk.
Definition: RFABase.h:168
casacore::Record params
Definition: RFABase.h:178
virtual void setOnlySelector(bool only_sel)
Definition: RFABase.h:173
String: the storage and methods of handling collections of characters.
Definition: String.h:223
RFChunkStats: vital information and flagging stats for a visibility chunk.
Definition: RFChunkStats.h:89
virtual void init()
This method is called after constructing the agent.
RFABase(RFChunkStats &ch, const casacore::RecordInterface &parm)
An agent is always constructed from a chunk stats accessor, and a record of parameters.
Abstract base class for Record classes.
virtual void setNAgent(casacore::uInt n)
Definition: RFABase.h:172
casacore::String myname
Definition: RFABase.h:179
casacore::uInt num(StatEnums which)
Definition: RFABase.h:182
const casacore::String & name()
returns the name of this RFA (set in myname)
Definition: RFABase.h:218
virtual void iterFlag(casacore::uInt)
Iteration method for a flag pass.
Definition: RFABase.h:143
virtual void startData(bool)
Called before starting a data pass on a chunk.
Definition: RFABase.h:104
unsigned int uInt
Definition: aipstype.h:51