casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VisBuffAccumulator.h
Go to the documentation of this file.
1 //# VisBuffAccumulator.h: class to average VisBuffers in time
2 //# Copyright (C) 2000,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: VisBuffAccumulator.h,v 19.6 2004/11/30 17:50:38 ddebonis Exp $
27 
28 #ifndef MSVIS_VISBUFFACCUMULATOR_H
29 #define MSVIS_VISBUFFACCUMULATOR_H
30 
31 #include <casa/aips.h>
32 #include <msvis/MSVis/VisBuffer.h>
34 
35 namespace casa { //# NAMESPACE CASA - BEGIN
36 
37 // <summary>
38 // A class to average VisBuffers in time
39 // </summary>
40 //
41 // <use visibility=export>
42 //
43 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
44 // </reviewed>
45 
46 // <prerequisite>
47 // <li> VisBuffer
48 // </prerequisite>
49 //
50 // <etymology>
51 // From "visibility", "time" and "averaging".
52 // </etymology>
53 //
54 // <synopsis>
55 // This class averages VisBuffers in time.
56 // </synopsis>
57 //
58 // <example>
59 // </example>
60 //
61 // <motivation>
62 // Collect all time averaging capabilities for VisBuffer averaging.
63 // </motivation>
64 //
65 // <thrown>
66 // <li>
67 // <li>
68 // </thrown>
69 //
70 // <todo asof="2000/09/01">
71 // <li> averaging over other indices.
72 // </todo>
73 
75 {
76 public:
77  // Construct from the number of antennas, the averaging interval and
78  // the pre-normalization flag
79  VisBuffAccumulator (const casacore::Int& nAnt, const casacore::Double& interval,
80  const casacore::Bool& prenorm, const casacore::Bool fillModel=true);
81 
82  // Null destructor
84 
85  // Reset the averager
86  void reset();
87 
88  // Accumulate a VisBuffer
89  void accumulate (const VisBuffer& vb);
90 
91  // Finalize averaging, and return the result
92  void finalizeAverage();
93 
94  // Return a reference to the result
95  // TBD: is it ok to return a CVB as a VB reference? (do I need an
96  // explicit cast here?
97  VisBuffer& aveVisBuff() { return avBuf_p; }
99 
100  // Global timestamp info
103 
104  // The number of VisBuffers that have been accumulated.
106 
107  // Return a map from row numbers in the VisBuffer returned by aveVisBuff() or
108  // aveCalVisBuff() to row numbers in the input VisBuffer. Only useful if
109  // nBuf_p == 1 or you are sure that the last input VisBuffer will meet your
110  // needs (i.e. all the input VisBuffers had same set of antennas and the
111  // metadata you want also matches). hurl controls whether an exception will
112  // be thrown if nBuf() != 1. Unfilled rows point to -1.
114  if(hurl && nBuf_p != 1)
115  throw_err("outToInRow", "The output to input row map is unreliable");
116  return outToInRow_p;
117  }
118 
120 
121  void reportData();
122 
123 protected:
124  // Averaging buffer
126 
127  // Number of correlations and channels
129 
130 private:
131  // Prohibit null constructor, copy constructor and assignment for now
135 
136  // Diagnostic printing level
137  casacore::Int& prtlev() { return prtlev_; };
138 
139  // Initialize the next accumulation interval
140  void initialize(const casacore::Bool& copydata);
141 
142  // Normalize the current accumulation
143  void normalize();
144 
145  // Hash function to return the row offset for an interferometer (ant1, ant2)
146  casacore::Int hashFunction (const casacore::Int& ant1, const casacore::Int& ant2);
147 
148  // Shuffle error handling elsewhere in an attempt to let the calling function
149  // be efficient and inlinable.
150  void throw_err(const casacore::String& origin, const casacore::String &msg);
151 
152  // Number of antennas
154 
155  // Averaging interval
157 
158  // Pre-normalization flag
160 
161  // Diagnostic print level
163 
164  // How many VisBuffers have been accumulated.
166 
167  casacore::Bool fillModel_p; // Whether or not to accumulate MODEL_DATA
168 
169  // End of initialization list
170 
171  // Per-interval timestamp averaging
174 
175  // Global timestamp average
178 
179  // Start time and row of current accumulation
182 
183  // Flag to mark the first accumulation interval
185 
186  // A map from avBuf_p's row numbers to row numbers in the VisBuffer used to
187  // fill avBuf_p. Only useful if nBuf_p == 1. Unfilled rows point to -1.
189 
190  bool tvi_debug;
191 };
192 
193 
194 } //# NAMESPACE CASA - END
195 
196 #endif
197 
198 
void initialize(const casacore::Bool &copydata)
Initialize the next accumulation interval.
casacore::Bool firstInterval_p
Flag to mark the first accumulation interval.
int Int
Definition: aipstype.h:50
casacore::Vector< casacore::Int > outToInRow_p
A map from avBuf_p&#39;s row numbers to row numbers in the VisBuffer used to fill avBuf_p.
casacore::Bool prenorm_p
Pre-normalization flag.
casacore::Int nAnt_p
Number of antennas.
CalVisBuffer extends VisBuffer to support storage and recall of associated residual and differentiate...
Definition: CalVisBuffer.h:65
VisBuffer & aveVisBuff()
Return a reference to the result TBD: is it ok to return a CVB as a VB reference? (do I need an expli...
A class to average VisBuffers in time.
void throw_err(const casacore::String &origin, const casacore::String &msg)
Shuffle error handling elsewhere in an attempt to let the calling function be efficient and inlinable...
casacore::Int hashFunction(const casacore::Int &ant1, const casacore::Int &ant2)
Hash function to return the row offset for an interferometer (ant1, ant2)
casacore::Double & timeStampWt()
void reset()
Reset the averager.
VisBuffAccumulator()
Prohibit null constructor, copy constructor and assignment for now.
casacore::Double tStart_p
Start time and row of current accumulation.
double Double
Definition: aipstype.h:55
void normalize()
Normalize the current accumulation.
CalVisBuffer avBuf_p
Averaging buffer.
void accumulate(const VisBuffer &vb)
Accumulate a VisBuffer.
casacore::Int nCorr_p
Number of correlations and channels.
casacore::Int & prtlev()
Diagnostic printing level.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Int prtlev_
Diagnostic print level.
casacore::uInt nBuf_p
How many VisBuffers have been accumulated.
casacore::Double & timeStamp()
Global timestamp info.
casacore::uInt nBuf()
The number of VisBuffers that have been accumulated.
void finalizeAverage()
Finalize averaging, and return the result.
virtual Origin origin() const =0
ABSTRACT METHODS //.
casacore::Double aveTime_p
End of initialization list.
~VisBuffAccumulator()
Null destructor.
bool debug
casacore::Double globalTime_p
Global timestamp average.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
VisBuffers encapsulate one chunk of visibility data for processing.
Definition: VisBuffer.h:153
const casacore::Vector< casacore::Int > & outToInRow(const casacore::Bool hurl=true)
Return a map from row numbers in the VisBuffer returned by aveVisBuff() or aveCalVisBuff() to row num...
casacore::Double globalTimeWt_p
casacore::Double interval_p
Averaging interval.
VisBuffAccumulator & operator=(const VisBuffAccumulator &)
unsigned int uInt
Definition: aipstype.h:51
CalVisBuffer & aveCalVisBuff()