casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VisBuffGroupAcc.h
Go to the documentation of this file.
1 //# VisBuffGroupAcc.h: class to group separately averaged VisBuffers
2 //# Copyright (C) 2008
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_VISBUFFGROUPACC_H
29 #define MSVIS_VISBUFFGROUPACC_H
30 
31 #include <casa/aips.h>
33 #include <map>
34 
35 namespace casa { //# NAMESPACE CASA - BEGIN
36 
37 // <summary>
38 // A class to group separately averaged VisBuffers
39 // </summary>
40 //
41 // <use visibility=export>
42 //
43 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
44 // </reviewed>
45 
46 // <prerequisite>
47 // <li> VisBufferAccumulator
48 // </prerequisite>
49 //
50 // <etymology>
51 //
52 // </etymology>
53 //
54 // <synopsis>
55 // This class groups separately averaged VisBuffers
56 // </synopsis>
57 //
58 // <example>
59 // </example>
60 //
61 // <motivation>
62 // To encapsulate in a single object multiple (averaged) VisBuffers
63 // for the solver.
64 //
65 // Used by calibration to generate multiple accumulations, e.g., per spw, when
66 // using combine='spw' and the data cannot be averaged over spw.
67 // </motivation>
68 //
69 // <thrown>
70 // <li>
71 // <li>
72 // </thrown>
73 //
74 // <todo asof="2008/08/04">
75 // <li> ??
76 // </todo>
77 
79 {
80 public:
81  // Construct from the number of antennas, spws, fields, the averaging interval and the pre-normalization flag
83  const casacore::Int& nSpw,
84  const casacore::Int& nFld,
85  const casacore::Double& subinterval,
86  const casacore::Bool fillModel=true);
87 
88  // Null destructor
90 
91  // Accumulate a VisBuffer
92  void accumulate (const VisBuffer& vb);
93 
94  // Finalize averaging, and return the result
95  void finalizeAverage();
96 
97  // Make data amp- or phase-only
98  void enforceAPonData(const casacore::String& apmode);
99 
100  // Optionally set cross-hands weights to zero, so they are
101  // not used (e.g., for solving) subsequently, but remain
102  // present in case a general calibration (like P for linears)
103  // is applied that will mix them with the parallel hands
104  void enforceSolveCorrWeights(const casacore::Bool phandonly=false);
105 
106  // How many separate VisBuffers are contained herein?
107  casacore::Int nBuf() const {return nBuf_p;}
108 
109  casacore::Int nAnt() const {return nAnt_p;}
110  casacore::Int nSpw() const {return nSpw_p;}
111  casacore::Int nFld() const {return nFld_p;}
112 
113  // The global timestamp
115 
116  // Return reference to the indexed VisBuffer
118  CalVisBuffer& operator()(const casacore::Int& spw, const casacore::Int& fld);
119 
120  // Return a map from row numbers in the VisBuffer returned by the above
121  // operator()s to row numbers in the corresponding input VisBuffer. Only
122  // useful if there is exactly one corresponding input VisBuffer or you are
123  // sure that the last corresponding input VisBuffer will meet your
124  // needs (i.e. all the corresponding input VisBuffers had same set of
125  // antennas and the metadata you want also matches). hurl controls whether
126  // an exception will be thrown if the number of VisBuffers that went into the
127  // output of operator() != 1. Unfilled rows point to -1.
128  const casacore::Vector<casacore::Int>& outToInRow(const casacore::Int buf, const casacore::Bool hurl=true) const;
130  const casacore::Bool hurl=true) const;
131 
132  // Setup chanmask from a spw:chan selection string and an MS.
133  // static so a chanmask can be made once and provided to multiple VBGAs.
135  const casacore::String& spwstr,
136  const casacore::MeasurementSet& ms);
137 
138  // Select channels in the accumulated buffers by flagging with the chanmask.
139  // Returns the number of VisBuffers that the chanmask operated on.
141 
142  // Empties chanmask (which may have some newed elements).
143  static void clearChanMask(std::map<casacore::Int, casacore::Vector<casacore::Bool>*>& chanmask);
144 
146 
147  void reportData();
148 
149 private:
150 
151  // Prohibit in-public null constructor, copy constructor and assignment
152  VisBuffGroupAcc();
155 
156  // Number of antennas, spw, fld, buffers
158 
159  // Averaging interval
161 
162  casacore::Bool fillModel_p; // Whether or not to accumulate MODEL_DATA
163 
164  // Pre-normalization flag
166 
167  // Per-interval timestamp averaging
169 
170  // Averaging buffer (length = nSpw_p x nFld_p)
172 
173  // casacore::Map spw,fld to the buffer id
175 
176  bool tvi_debug;
177 };
178 
179 
180 } //# NAMESPACE CASA - END
181 
182 #endif
183 
184 
casacore::Bool prenorm_p
Pre-normalization flag.
void setTVIDebug(bool debug)
VisBuffGroupAcc & operator=(const VisBuffGroupAcc &)
void accumulate(const VisBuffer &vb)
Accumulate a VisBuffer.
int Int
Definition: aipstype.h:50
casacore::Bool fillModel_p
void enforceAPonData(const casacore::String &apmode)
Make data amp- or phase-only.
casacore::uInt applyChanMask(std::map< casacore::Int, casacore::Vector< casacore::Bool > * > &chanmask)
Select channels in the accumulated buffers by flagging with the chanmask.
casacore::Int nAnt_p
Number of antennas, spw, fld, buffers.
casacore::Int nSpw() const
CalVisBuffer & operator()(const casacore::Int &buf)
Return reference to the indexed VisBuffer.
const casacore::Vector< casacore::Int > & outToInRow(const casacore::Int buf, const casacore::Bool hurl=true) const
Return a map from row numbers in the VisBuffer returned by the above operator()s to row numbers in th...
casacore::Int nFld() const
CalVisBuffer extends VisBuffer to support storage and recall of associated residual and differentiate...
Definition: CalVisBuffer.h:65
void enforceSolveCorrWeights(const casacore::Bool phandonly=false)
Optionally set cross-hands weights to zero, so they are not used (e.g., for solving) subsequently...
~VisBuffGroupAcc()
Null destructor.
casacore::Double subinterval_p
Averaging interval.
casacore::Double & globalTimeStamp()
The global timestamp.
VisBuffGroupAcc()
Prohibit in-public null constructor, copy constructor and assignment.
static casacore::Bool fillChanMask(std::map< casacore::Int, casacore::Vector< casacore::Bool > * > &chanmask, const casacore::String &spwstr, const casacore::MeasurementSet &ms)
Setup chanmask from a spw:chan selection string and an MS.
casacore::Int nAnt() const
void finalizeAverage()
Finalize averaging, and return the result.
double Double
Definition: aipstype.h:55
static void clearChanMask(std::map< casacore::Int, casacore::Vector< casacore::Bool > * > &chanmask)
Empties chanmask (which may have some newed elements).
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
A class to group separately averaged VisBuffers.
A drop-in replacement for Block&lt;T*&gt;.
Definition: WProjectFT.h:54
A Table intended to hold astronomical data (a set of Measurements).
bool debug
casacore::Int nBuf() const
How many separate VisBuffers are contained herein?
casacore::Matrix< casacore::Int > spwfldids_p
casacore::Map spw,fld to the buffer id
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
casacore::PtrBlock< VisBuffAccumulator * > VBA_p
Averaging buffer (length = nSpw_p x nFld_p)
casacore::Double globalTimeStamp_p
Per-interval timestamp averaging.
unsigned int uInt
Definition: aipstype.h:51