casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFChunkStats.h
Go to the documentation of this file.
1 //# RFChunkStats.h: this defines RFChunkStats
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_RFCHUNKSTATS_H
28 #define FLAGGING_RFCHUNKSTATS_H
29 
31 #include <casa/Arrays/Vector.h>
32 #include <casa/Arrays/Matrix.h>
33 #include <casa/Arrays/Cube.h>
34 #include <casa/Containers/Block.h>
37 
38 namespace casacore{
39 
40 class MeasurementSet;
41 }
42 
43 namespace casa { //# NAMESPACE CASA - BEGIN
44 
45 class Flagger;
46 class VisibilityIterator;
47 class VisBuffer;
48 
49 class RFABase;
50 typedef RFABase RFA;
51 
52 // <summary>
53 // RFChunkStats: vital information and flagging stats for a visibility chunk
54 // </summary>
55 
56 // <use visibility=local>
57 
58 // <reviewed reviewer="" date="" tests="" demos="">
59 // </reviewed>
60 
61 // <prerequisite>
62 // <li> VisibilityIterator
63 // <li> VisBuffer
64 // <li> MeasurementSet
65 // <li> Flagger
66 // </prerequisite>
67 //
68 // <etymology>
69 // </etymology>
70 //
71 // <synopsis>
72 // RFChunkStats maintains various stats, derived values, and flagging
73 // counts for a single visibility chunk. Also serves as an interface to
74 // VisIter and VisBuffer.
75 // </synopsis>
76 //
77 // <motivation>
78 // Vital information about an casacore::MS or a visibility chunk is spread all over
79 // three classes (casacore::MS, VisIter, VisBuffer). RFChunkStats provides a central
80 // point for flagging agents to look this info up.
81 // </motivation>
82 //
83 // <todo asof="2001/04/16">
84 // <li> add this feature
85 // <li> fix this bug
86 // <li> start discussion of this possible extension
87 // </todo>
88 
89 class RFChunkStats : public FlaggerEnums
90 {
91 protected:
95 
109 
110 // casacore::Matrix<casacore::uInt> nf_corr_ifr, nf_chan_corr, nf_chan_time, nf_corr_time;
111 
112  std::vector<double> scan_start; /* first time stamp in scan */
113  std::vector<double> scan_start_flag; /* first time stamp with any
114  unflagged data in scan*/
115  std::vector<double> scan_end, scan_end_flag; /* as above */
116 
117 
118 
119 public:
120 // constructor
122 
123 // accessors to VisIter
124  const VisibilityIterator & visIter () const { return visiter; }
126 // accessor to VisBuffer
127  VisBuffer &visBuf () { return visbuf; }
128 // accessor to MS
129  const casacore::MeasurementSet & measSet () const;
130 // accessor to MS
131  const casacore::String msName () const;
132 // returns antenna names
134 
135  // scan start/end times
136  double get_scan_start(unsigned scan) const
137  { return scan_start[scan]; }
138 
139  double get_scan_end(unsigned scan) const
140  { return scan_end[scan]; }
141 
142  // scan start/end times for unflagged data
143  //
144  // returns: time stamps of first/last unflagged
145  // data in the given scan, or a negative number
146  // if there's no unflagged data in the scan.
147  double get_scan_start_unflagged(unsigned scan) const
148  { return scan_start_flag[scan]; }
149 
150  double get_scan_end_unflagged(unsigned scan) const
151  { return scan_end_flag[scan]; }
152 
153 // loads data for new chunk, resets all flag stat counters
154  void newChunk (bool init_quack);
155 // loads data for new pass
157 // loads data for new iteration
158  void newTime ();
159 
160 // returns current chunk number
161  casacore::uInt nchunk() const { return chunk_no; };
162 // returns current pass number
163  casacore::uInt npass() const { return pass_no; };
164 // returns current time slot
165  casacore::Int iTime() const { return itime; };
166 
167 // returns a data dimension (POL, CHAN, IFR, etc.)
168  casacore::uInt num ( StatEnums which ) const { return counts[which]; }
169 // returns vector of frequencies (one per channel)
171 
172 // returns time of currently iterated time slot
174  { return current_time; }
175 // return first time slot in chunk
177  { return start_time; }
178 // return last time slot in chunk
180  { return end_time; }
181 
182 // returns corr mask corresponding to specified casacore::Stokes types
183 // (templated, but only casacore::String and casacore::Int will actually work)
184  template<class T> RFlagWord getCorrMask ( const casacore::Vector<T> &corrspec );
185 
186 // returns mask with all correlations
187  RFlagWord fullCorrMask () { return (1<<num(CORR))-1; };
188 // returns string of correlations
190 
191 // returns IFR index corresponding to current VisBuffer rows
193 // returns IFR index corresponding to current VisBuffer rows
195 
196 // returns FEED index corresponding to current VisBuffer rows
198 // returns FEED index corresponding to current VisBuffer rows
200 
201 // converts antenna indices into IFR index
203 // converts IFR index back to antenna numbers
204  void ifrToAnt ( casacore::uInt &ant1,casacore::uInt &ant2,casacore::uInt ifr );
205 // converts IFR index to standard ID string
207 
208 // data availability stats, per IFR
211 
212 // accessors to various flagging stats
214  { return nf_ifr_time(ifr,itime); }
216  { return nf_ifr_time; }
217  casacore::uInt & nfChanIfr ( casacore::uInt ich,casacore::uInt ifr ) // flags per channel and ifr
218  { return nf_chan_ifr(ich,ifr); }
220  { return nf_chan_ifr; }
222  { return nf_chan_ifr; }
224  { return nrf_ifr(i); }
226  { return nrf_time(i); }
228  { return nrf_ifr; };
230  { return nrf_time; };
231 
232  //casacore::Matrix<casacore::uInt> nf_corr_ifr, nf_chan_corr, nf_chan_time, nf_corr_time;
233  //casacore::uInt & nfCorrIfr( casacore::uInt icorr, casacore::uInt ifr ) { return nf_corr_ifr(icorr,ifr); }
234  //const casacore::Matrix<casacore::uInt> & nfCorrIfr () const { return nf_corr_ifr; }
235  //casacore::uInt & nfChanCorr( casacore::uInt ich, casacore::uInt icorr ) { return nf_chan_corr(ich,icorr); }
236  //const casacore::Matrix<casacore::uInt> & nfChanCorr () const { return nf_chan_corr; }
237  //casacore::uInt & nfChanTime( casacore::uInt ich, casacore::uInt itime ) { return nf_chan_time(ich,itime); }
238  //const casacore::Matrix<casacore::uInt> & nfChanTime () const { return nf_chan_time; }
239  //casacore::uInt & nfCorrTime( casacore::uInt icorr, casacore::uInt itime ) { return nf_corr_time(icorr,itime); }
240  //const casacore::Matrix<casacore::uInt> & nfCorrTime () const { return nf_corr_time; }
241 
242 // prints stats to stderr
243  void printStats ();
244 };
245 
246 // enums for which stats are actually collected
249 
250 // global function for finding polarization by index
252 
253 
254 } //# NAMESPACE CASA - END
255 
256 #ifndef AIPS_NO_TEMPLATE_SRC
257 #include <flagging/Flagging/RFChunkStats.tcc>
258 #endif //# AIPS_NO_TEMPLATE_SRC
259 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
const casacore::Vector< casacore::uInt > & nrowPerIfr() const
Definition: RFChunkStats.h:210
VisibilityIterator & visiter
Definition: RFChunkStats.h:92
int Int
Definition: aipstype.h:50
VisBuffer & visbuf
Definition: RFChunkStats.h:93
casacore::uInt RFlagWord
RFAs use bitwise flags.
Definition: RFCommon.h:41
const casacore::Matrix< casacore::uInt > & nfChanIfr() const
Definition: RFChunkStats.h:219
VisBuffer & visBuf()
accessor to VisBuffer
Definition: RFChunkStats.h:127
double get_scan_end(unsigned scan) const
Definition: RFChunkStats.h:139
std::vector< double > scan_start_flag
Definition: RFChunkStats.h:113
casacore::Int iTime() const
returns current time slot
Definition: RFChunkStats.h:165
virtual Type type()
Return the type enum.
casacore::Vector< casacore::uInt > nrf_ifr
Definition: RFChunkStats.h:100
std::vector< double > scan_start
casacore::Matrix&lt;casacore::uInt&gt; nf_corr_ifr, nf_chan_corr, nf_chan_time, nf_corr_time; ...
Definition: RFChunkStats.h:112
casacore::Double start_time
Definition: RFChunkStats.h:106
casacore::Double end_time
Definition: RFChunkStats.h:106
const casacore::MeasurementSet & measSet() const
accessor to MS
casacore::String corr_string
Definition: RFChunkStats.h:105
casacore::IPosition visshape
Definition: RFChunkStats.h:96
casacore::Matrix< casacore::uInt > & nfChanIfr()
Definition: RFChunkStats.h:221
casacore::uInt num(StatEnums which) const
returns a data dimension (POL, CHAN, IFR, etc.)
Definition: RFChunkStats.h:168
StokesTypes
The Stokes types are defined by this enum.
Definition: Stokes.h:66
const casacore::uInt num_active_stats
Definition: RFChunkStats.h:248
casacore::Int itime
Definition: RFChunkStats.h:108
casacore::uInt nchunk() const
returns current chunk number
Definition: RFChunkStats.h:161
void ifrToAnt(casacore::uInt &ant1, casacore::uInt &ant2, casacore::uInt ifr)
converts IFR index back to antenna numbers
const casacore::Vector< casacore::Int > & feedNums()
returns FEED index corresponding to current VisBuffer rows
Definition: RFChunkStats.h:199
const casacore::Vector< casacore::Int > & ifrNums()
returns IFR index corresponding to current VisBuffer rows
Definition: RFChunkStats.h:194
std::vector< double > scan_end
Definition: RFChunkStats.h:115
void newChunk(bool init_quack)
loads data for new chunk, resets all flag stat counters
casacore::Vector< casacore::Double > freq
Definition: RFChunkStats.h:104
casacore::Int findCorrType(casacore::Stokes::StokesTypes type, const casacore::Vector< casacore::Int > &corr)
global function for finding polarization by index
double get_scan_start(unsigned scan) const
scan start/end times
Definition: RFChunkStats.h:136
casacore::Vector< casacore::uInt > rows_per_ifr
Definition: RFChunkStats.h:99
casacore::Matrix< casacore::uInt > nf_chan_ifr
Definition: RFChunkStats.h:98
casacore::Vector< casacore::Int > feed_nums
Definition: RFChunkStats.h:102
double Double
Definition: aipstype.h:55
casacore::Vector< casacore::uInt > nrf_time
Definition: RFChunkStats.h:100
const casacore::String & getCorrString()
returns string of correlations
Definition: RFChunkStats.h:189
casacore::uInt npass() const
returns current pass number
Definition: RFChunkStats.h:163
casacore::Double endMJD() const
return last time slot in chunk
Definition: RFChunkStats.h:179
casacore::uInt & nrfTime(casacore::uInt i)
Definition: RFChunkStats.h:225
casacore::uInt nrowPerIfr(casacore::uInt ifr)
data availability stats, per IFR
Definition: RFChunkStats.h:209
Flagger: high-performance automated flagging.
Definition: Flagger.h:100
casacore::uInt & nrfIfr(casacore::uInt i)
Definition: RFChunkStats.h:223
const casacore::Matrix< casacore::uInt > & nfIfrTime() const
Definition: RFChunkStats.h:215
const casacore::Vector< casacore::String > & antNames() const
returns antenna names
casacore::Vector< casacore::Int > corrtypes
Definition: RFChunkStats.h:103
const casacore::Vector< casacore::Double > & frequency()
returns vector of frequencies (one per channel)
RFChunkStats(VisibilityIterator &vi, VisBuffer &vb, Flagger &rf)
constructor
casacore::Vector< casacore::Int > ifr_nums
Definition: RFChunkStats.h:101
double get_scan_start_unflagged(unsigned scan) const
scan start/end times for unflagged data
Definition: RFChunkStats.h:147
const VisibilityIterator & visIter() const
accessors to VisIter
Definition: RFChunkStats.h:124
std::vector< double > scan_end_flag
Definition: RFChunkStats.h:115
casacore::uInt antToIfr(casacore::uInt ant1, casacore::uInt ant2)
converts antenna indices into IFR index
casacore::Double currentMJD() const
returns time of currently iterated time slot
Definition: RFChunkStats.h:173
A Table intended to hold astronomical data (a set of Measurements).
VisibilityIterator & visIter()
Definition: RFChunkStats.h:125
FlaggerEnums: collection of enums for various flagger classes.
Definition: RFCommon.h:126
Abstract RedFlagger Agent base class.
Definition: RFABase.h:59
RFABase RFA
Definition: RFChunkStats.h:49
casacore::uInt pass_no
Definition: RFChunkStats.h:107
casacore::uInt ifrNum(casacore::uInt nr)
returns IFR index corresponding to current VisBuffer rows
Definition: RFChunkStats.h:192
casacore::uInt & nfIfrTime(casacore::uInt ifr, casacore::uInt itime)
accessors to various flagging stats
Definition: RFChunkStats.h:213
const casacore::String msName() const
accessor to MS
double get_scan_end_unflagged(unsigned scan) const
Definition: RFChunkStats.h:150
casacore::Double startMJD() const
return first time slot in chunk
Definition: RFChunkStats.h:176
casacore::Matrix< casacore::uInt > nf_ifr_time
Definition: RFChunkStats.h:98
const casacore::Vector< casacore::uInt > & nrfTime() const
Definition: RFChunkStats.h:229
void newTime()
loads data for new iteration
casacore::uInt chunk_no
Definition: RFChunkStats.h:107
void newPass(casacore::uInt npass)
loads data for new pass
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::uInt & nfChanIfr(casacore::uInt ich, casacore::uInt ifr)
Definition: RFChunkStats.h:217
casacore::uInt feedNum(casacore::uInt nr)
returns FEED index corresponding to current VisBuffer rows
Definition: RFChunkStats.h:197
void printStats()
casacore::Matrix&lt;casacore::uInt&gt; nf_corr_ifr, nf_chan_corr, nf_chan_time, nf_corr_time; casacore::uIn...
RFChunkStats: vital information and flagging stats for a visibility chunk.
Definition: RFChunkStats.h:89
casacore::Double current_time
Definition: RFChunkStats.h:106
VisBuffers encapsulate one chunk of visibility data for processing.
Definition: VisBuffer.h:153
VisibilityIterator iterates through one or more writable MeasurementSets.
casacore::uInt counts[Num_StatEnums]
Definition: RFChunkStats.h:97
casacore::String ifrString(casacore::uInt ifr)
converts IFR index to standard ID string
RFlagWord fullCorrMask()
returns mask with all correlations
Definition: RFChunkStats.h:187
const RFChunkStats::StatEnums active_stats[]
enums for which stats are actually collected
Definition: RFChunkStats.h:247
const casacore::Vector< casacore::uInt > & nrfIfr() const
Definition: RFChunkStats.h:227
RFlagWord getCorrMask(const casacore::Vector< T > &corrspec)
returns corr mask corresponding to specified casacore::Stokes types (templated, but only casacore::St...
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42