casa
$Rev:20696$
|
00001 //# VisBuffGroupAcc.h: class to group separately averaged VisBuffers 00002 //# Copyright (C) 2008 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: VisBuffAccumulator.h,v 19.6 2004/11/30 17:50:38 ddebonis Exp $ 00027 00028 #ifndef MSVIS_VISBUFFGROUPACC_H 00029 #define MSVIS_VISBUFFGROUPACC_H 00030 00031 #include <casa/aips.h> 00032 #include <synthesis/MSVis/VisBuffAccumulator.h> 00033 #include <map> 00034 00035 namespace casa { //# NAMESPACE CASA - BEGIN 00036 00037 // <summary> 00038 // A class to group separately averaged VisBuffers 00039 // </summary> 00040 // 00041 // <use visibility=export> 00042 // 00043 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00044 // </reviewed> 00045 00046 // <prerequisite> 00047 // <li> VisBufferAccumulator 00048 // </prerequisite> 00049 // 00050 // <etymology> 00051 // 00052 // </etymology> 00053 // 00054 // <synopsis> 00055 // This class groups separately averaged VisBuffers 00056 // </synopsis> 00057 // 00058 // <example> 00059 // </example> 00060 // 00061 // <motivation> 00062 // To encapsulate in a single object multiple (averaged) VisBuffers 00063 // for the solver. 00064 // 00065 // Used by calibration to generate multiple accumulations, e.g., per spw, when 00066 // using combine='spw' and the data cannot be averaged over spw. 00067 // </motivation> 00068 // 00069 // <thrown> 00070 // <li> 00071 // <li> 00072 // </thrown> 00073 // 00074 // <todo asof="2008/08/04"> 00075 // <li> ?? 00076 // </todo> 00077 00078 class VisBuffGroupAcc 00079 { 00080 public: 00081 // Construct from the number of antennas, spws, fields, the averaging interval and the pre-normalization flag 00082 VisBuffGroupAcc (const Int& nAnt, 00083 const Int& nSpw, 00084 const Int& nFld, 00085 const Double& subinterval, 00086 const Bool fillModel=True); 00087 00088 // Null destructor 00089 ~VisBuffGroupAcc(); 00090 00091 // Accumulate a VisBuffer 00092 void accumulate (const VisBuffer& vb); 00093 00094 // Finalize averaging, and return the result 00095 void finalizeAverage(); 00096 00097 // Make data amp- or phase-only 00098 void enforceAPonData(const String& apmode); 00099 00100 // Optionally set cross-hands weights to zero, so they are 00101 // not used (e.g., for solving) subsequently, but remain 00102 // present in case a general calibration (like P for linears) 00103 // is applied that will mix them with the parallel hands 00104 void enforceSolveCorrWeights(const Bool phandonly=False); 00105 00106 // How many separate VisBuffers are contained herein? 00107 Int nBuf() const {return nBuf_p;} 00108 00109 Int nAnt() const {return nAnt_p;} 00110 Int nSpw() const {return nSpw_p;} 00111 Int nFld() const {return nFld_p;} 00112 00113 // The global timestamp 00114 Double& globalTimeStamp() { return globalTimeStamp_p; }; 00115 00116 // Return reference to the indexed VisBuffer 00117 CalVisBuffer& operator()(const Int& buf); 00118 CalVisBuffer& operator()(const Int& spw, const Int& fld); 00119 00120 // Return a map from row numbers in the VisBuffer returned by the above 00121 // operator()s to row numbers in the corresponding input VisBuffer. Only 00122 // useful if there is exactly one corresponding input VisBuffer or you are 00123 // sure that the last corresponding input VisBuffer will meet your 00124 // needs (i.e. all the corresponding input VisBuffers had same set of 00125 // antennas and the metadata you want also matches). hurl controls whether 00126 // an exception will be thrown if the number of VisBuffers that went into the 00127 // output of operator() != 1. Unfilled rows point to -1. 00128 const Vector<Int>& outToInRow(const Int buf, const Bool hurl=true) const; 00129 const Vector<Int>& outToInRow(const Int spw, const Int fld, 00130 const Bool hurl=true) const; 00131 00132 // Setup chanmask from a spw:chan selection string and an MS. 00133 // static so a chanmask can be made once and provided to multiple VBGAs. 00134 static Bool fillChanMask(std::map<Int, Vector<Bool>*>& chanmask, 00135 const String& spwstr, 00136 const MeasurementSet& ms); 00137 00138 // Select channels in the accumulated buffers by flagging with the chanmask. 00139 // Returns the number of VisBuffers that the chanmask operated on. 00140 uInt applyChanMask(std::map<Int, Vector<Bool>*>& chanmask); 00141 00142 // Empties chanmask (which may have some newed elements). 00143 static void clearChanMask(std::map<Int, Vector<Bool>*>& chanmask); 00144 00145 private: 00146 00147 // Prohibit in-public null constructor, copy constructor and assignment 00148 VisBuffGroupAcc(); 00149 VisBuffGroupAcc& operator= (const VisBuffGroupAcc&); 00150 VisBuffGroupAcc (const VisBuffGroupAcc&); 00151 00152 // Number of antennas, spw, fld, buffers 00153 Int nAnt_p, nSpw_p, nFld_p, nBuf_p; 00154 00155 // Averaging interval 00156 Double subinterval_p; 00157 00158 Bool fillModel_p; // Whether or not to accumulate MODEL_DATA 00159 00160 // Pre-normalization flag 00161 Bool prenorm_p; 00162 00163 // Per-interval timestamp averaging 00164 Double globalTimeStamp_p; 00165 00166 // Averaging buffer (length = nSpw_p x nFld_p) 00167 PtrBlock<VisBuffAccumulator*> VBA_p; 00168 00169 // Map spw,fld to the buffer id 00170 Matrix<Int> spwfldids_p; 00171 }; 00172 00173 00174 } //# NAMESPACE CASA - END 00175 00176 #endif 00177 00178