casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFADiffBase.h
Go to the documentation of this file.
1 //# RFADiffBase.h: this defines RFADiffBase and RFADiffMapbase
2 //# Copyright (C) 2000,2001,2002
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_RFADIFFBASE_H
28 #define FLAGGING_RFADIFFBASE_H
29 
35 #include <casa/Arrays/LogiVector.h>
37 
38 
39 namespace casa { //# NAMESPACE CASA - BEGIN
40 
41 // min number of deviations for which average is considered valid
42 const int RFA_MIN_NAD = 20;
43 // significant change in accumulated average
45 
46 // <summary>
47 // RFADiffBase: abstract class for deviation-based flagging
48 // </summary>
49 
50 // <use visibility=local>
51 
52 // <reviewed reviewer="" date="" tests="" demos="">
53 // </reviewed>
54 
55 // <prerequisite>
56 // <li> RFCubeLattice
57 // <li> RFRowClipper
58 // </prerequisite>
59 //
60 // <etymology>
61 // Diff = Deviation. Well, almost...
62 // </etymology>
63 //
64 // <synopsis>
65 // Several flagging algorithms flag by analyzing the deviation w/respect
66 // to something at each point. RFADiffBase provides common functions for
67 // these classes. It will maintain a lattice of deviations, compute the
68 // noise level estimates, and flag points. It will also flag rows with
69 // excessive noise level (using RFRowClipper). Derived classes are
70 // responsible for computing the deviation.
71 // </synopsis>
72 //
73 // <todo asof="2001/04/16">
74 // <li> add this feature
75 // <li> fix this bug
76 // <li> start discussion of this possible extension
77 // </todo>
78 
80 {
81 public:
83  virtual ~RFADiffBase ();
84 
86  virtual casacore::Bool newChunk ( casacore::Int &maxmem );
87  virtual void endChunk ();
88  virtual void startData (bool verbose);
89  virtual void startDry (bool verbose);
90  virtual IterMode iterTime (casacore::uInt it);
91  virtual IterMode iterDry (casacore::uInt it);
92  virtual IterMode endData ();
93  virtual IterMode endDry ();
94 
95  virtual casacore::String getDesc ();
96  static const casacore::RecordInterface & getDefaults ();
97 
98 protected:
100 
101 // prepares for a pass over one data row
102  void startDataRow (casacore::uInt ifr);
103 // updates the diff lattice with a value, and performs clipping
105 // ends pass over single data row
106  void endDataRow (casacore::uInt ifr);
107 
108 // updates noise estimates (sih0), returns the max change
110 
111 // computes a correlations mask. Called once for each chunk (since correlations
112 // can change from chunk to chunk)
113  virtual RFlagWord newCorrMask () =0;
114 
115  casacore::Double clip_level; // clipping level, in AADs
116  casacore::Double row_clip_level; // clipping level for rows (based on noise estimates), <0 for disable
117  casacore::Bool disable_row_clip; // flag: row clipping _disabled_ globally
118  casacore::Bool clipping_rows; // flag: row clipping active for this chunk
119 
120  RFFloatLattice diff; // (Nchan,Nifr,Nt) cube of deviations
121  FlagCubeIterator * pflagiter; // flag iterator used by setDiff()
123 
124  casacore::Vector<casacore::Float> diffrow; // one row of deviations, for noise computations
125  int idiffrow;
126 
127  casacore::Matrix<casacore::Float> sig; // current noise estimate for (it,ifr)
128  casacore::Matrix<casacore::Float> sig0; // reference estimate (boxcar average from previous pass)
129  casacore::LogicalVector sigupdated;
130 };
131 
132 // <summary>
133 // Abstract base class for deviation-based flagging with a data mapper.
134 // </summary>
135 
136 // <use visibility=local>
137 
138 // <reviewed reviewer="" date="" tests="" demos="">
139 // </reviewed>
140 
141 // <prerequisite>
142 // <li> RFDataMapper
143 // </prerequisite>
144 //
145 // <synopsis>
146 // This is another abstract class on top of DiffBase. It is also inherited from
147 // RFDataMapper, so it includes functions for mapping visibilities to a single
148 // casacore::Float value.
149 // </synopsis>
150 //
151 // <todo asof="2001/04/16">
152 // <li> add this feature
153 // <li> fix this bug
154 // <li> start discussion of this possible extension
155 // </todo>
156 
157 class RFADiffMapBase : public RFADiffBase, protected RFDataMapper
158 {
159 public:
161  virtual ~RFADiffMapBase ();
162 
163  virtual IterMode iterTime (casacore::uInt it);
164 
165  virtual casacore::String getDesc ();
166 
167 // returns a casacore::Record of all available parameters and their default values
168  static const casacore::RecordInterface & getDefaults ();
169 
170 protected:
171  virtual RFlagWord newCorrMask ()
172  { return RFDataMapper::corrMask(chunk.visIter()); }
173 
174  void setupMapper ()
176 };
177 
178 } //# NAMESPACE CASA - END
179 
180 #endif
casacore::Matrix< casacore::Float > sig0
Definition: RFADiffBase.h:128
casacore::Double row_clip_level
Definition: RFADiffBase.h:116
virtual RFlagWord newCorrMask()
computes a correlations mask.
Definition: RFADiffBase.h:171
Abstract RedFlagger Agent class with a flag cube.
int Int
Definition: aipstype.h:50
void startDataRow(casacore::uInt ifr)
prepares for a pass over one data row
casacore::uInt RFlagWord
RFAs use bitwise flags.
Definition: RFCommon.h:41
virtual IterMode iterTime(casacore::uInt it)
Iteration methods for a data pass.
casacore::LogicalVector sigupdated
Definition: RFADiffBase.h:129
VisBuffer & visBuf()
accessor to VisBuffer
Definition: RFChunkStats.h:127
void endDataRow(casacore::uInt ifr)
ends pass over single data row
RFFloatLattice diff
Definition: RFADiffBase.h:120
casacore::Bool clipping_rows
Definition: RFADiffBase.h:118
virtual void startData(bool verbose)
Called before starting a data pass on a chunk.
RFRowClipper: flags rows based on their noise level.
Definition: RFRowClipper.h:65
RFADiffBase(RFChunkStats &ch, const casacore::RecordInterface &parm)
virtual void startDry(bool verbose)
Called before starting a dry pass on a chunk.
void setVisBuffer(VisBuffer &vb)
point the datamapper at a visbuffer - called for every new buffer
virtual ~RFADiffMapBase()
casacore::Vector< casacore::Float > diffrow
Definition: RFADiffBase.h:124
RFADiffBase: abstract class for deviation-based flagging.
Definition: RFADiffBase.h:79
RFFloatLatice: a cubic lattice.
IterMode
iteration modes
Definition: RFABase.h:63
virtual RFlagWord newCorrMask()=0
computes a correlations mask.
RFlagWord corrMask(const VisibilityIterator &vi)
uses mapper to compute a correlations mask
casacore::Bool disable_row_clip
Definition: RFADiffBase.h:117
RFChunkStats & chunk
Definition: RFABase.h:177
static const casacore::RecordInterface & getDefaults()
returns a casacore::Record of all available parameters and their default values
casacore::Float setDiff(casacore::uInt ich, casacore::uInt ifr, casacore::Float d, casacore::Bool &flagged=dummy_Bool)
updates the diff lattice with a value, and performs clipping
RFADiffMapBase(RFChunkStats &ch, const casacore::RecordInterface &parm)
casacore::Double clip_level
Definition: RFADiffBase.h:115
double Double
Definition: aipstype.h:55
const int RFA_MIN_NAD
min number of deviations for which average is considered valid
Definition: RFADiffBase.h:42
virtual casacore::String getDesc()
called to obtain a short description of this RFA
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Float updateSigma()
updates noise estimates (sih0), returns the max change
static casacore::Bool dummy_Bool
Definition: RFADiffBase.h:99
virtual void endChunk()
Called once finished with a chunk.
float Float
Definition: aipstype.h:54
static const casacore::RecordInterface & getDefaults()
virtual ~RFADiffBase()
virtual casacore::Bool newChunk(casacore::Int &maxmem)
Called before iterating over a chunk.
const VisibilityIterator & visIter() const
accessors to VisIter
Definition: RFChunkStats.h:124
FlagCubeIterator * pflagiter
Definition: RFADiffBase.h:121
virtual casacore::uInt estimateMemoryUse()
This method is called before iterating over a chunk, to inquire the expected memory use...
virtual IterMode iterTime(casacore::uInt it)
Iteration methods for a data pass.
casacore::Matrix< casacore::Float > sig
Definition: RFADiffBase.h:127
virtual IterMode iterDry(casacore::uInt it)
Iteration method for a dry pass.
Abstract base class for deviation-based flagging with a data mapper.
Definition: RFADiffBase.h:157
virtual IterMode endData()
Called after a pass is completed successfully (i.e., not stopped by start or iter methods)...
virtual casacore::String getDesc()
called to obtain a short description of this RFA
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 IterMode endDry()
Called after a dry pass is complete.
RFRowClipper rowclipper
Definition: RFADiffBase.h:122
Abstract base class for Record classes.
const casacore::Float RFA_AAD_CHANGE
significant change in accumulated average
Definition: RFADiffBase.h:44
unsigned int uInt
Definition: aipstype.h:51
RFDataMapper: maps complex visibilities to a single real value.
Definition: RFDataMapper.h:73