PlotMSVBAverager.h

Go to the documentation of this file.
00001 //# PlotMSVBAverager.h: class to average VisBuffers for PlotMS
00002 //# Copyright (C) 2000,2002
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 PLOTMSVBAVERAGER_H
00029 #define PLOTMSVBAVERAGER_H
00030 
00031 #include <casa/aips.h>
00032 #include <msvis/MSVis/VisBuffer2.h>
00033 #include <casa/Arrays/Vector.h>
00034 #include <casa/Arrays/Matrix.h>
00035 #include <casa/Arrays/Cube.h>
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 // <summary>
00040 // A class to average VisBuffers for PlotMS
00041 // </summary>
00042 //
00043 // <use visibility=export>
00044 //
00045 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00046 // </reviewed>
00047 
00048 // <prerequisite>
00049 //   <li> VisBuffer2
00050 // </prerequisite>
00051 //
00052 // <etymology>
00053 // </etymology>
00054 //
00055 // <synopsis>
00056 // This class averages VisBuffers together for PlotMS
00057 // </synopsis>
00058 //
00059 // <example>
00060 // </example>
00061 //
00062 // <motivation>
00063 // </motivation>
00064 //
00065 // <thrown>
00066 //    <li>
00067 //    <li>
00068 // </thrown>
00069 //
00070 // <todo asof="2009/04/24">
00071 //   <li> averaging over other indices.
00072 // </todo>
00073 
00074 class PlotMSVBAverager
00075 {
00076 public:
00077   // Construct from the number of antennas, the averaging interval and
00078   // the pre-normalization flag
00079   PlotMSVBAverager(Int nAnt);
00080 
00081   // Null destructor
00082   ~PlotMSVBAverager();
00083 
00084   // Set up baseline averaging
00085   inline void setBlnAveraging(Bool doBln) { 
00086     blnAve_p = doBln; if (doBln) setAntAveraging(False); };
00087   // Set up antenna averaging
00088   inline void setAntAveraging(Bool doAnt) { 
00089     antAve_p = doAnt; if (doAnt) setBlnAveraging(False); };
00090   // Set scalar averaging flag 
00091   inline void setScalarAve(Bool doScalar) { 
00092     //    cout << "Using " << (doScalar ? "SCALAR" : "VECTOR") << " averaging." << endl;
00093     inCoh_p = doScalar; };
00094   
00095   // Control which data column to average
00096   inline void setNoData() {doVC_p = doMVC_p = doCVC_p = doFC_p = doWC_p = 
00097                                 doUVW_p = False;};
00098   inline void setDoVC()  {doVC_p  = doWC_p = True;};
00099   inline void setDoMVC() {doMVC_p = doWC_p = True;};
00100   inline void setDoCVC() {doCVC_p = doWC_p = True;};
00101   inline void setDoFC()  {doFC_p  = doWC_p = True;};
00102   inline void setDoUVW() {doUVW_p = True;};
00103 
00104   // Accumulate a VisBuffer
00105   inline void accumulate (vi::VisBuffer2& vb) { antAve_p ? antAccumulate(vb) : simpAccumulate(vb); };
00106 
00107   // Finalize averaging
00108   void finalizeAverage();
00109 
00110   // Return a reference to the result
00111   vi::VisBuffer2& aveVisBuff() { return *avBuf_p; }
00112 
00113 private:
00114   // Prohibit null constructor, copy constructor and assignment for now
00115   PlotMSVBAverager();
00116   PlotMSVBAverager& operator= (const PlotMSVBAverager&);
00117   PlotMSVBAverager (const PlotMSVBAverager&);
00118 
00119   // Diagnostic printing level
00120   Int& prtlev() { return prtlev_; };
00121 
00122   // Initialize the next accumulation interval
00123   void initialize(vi::VisBuffer2& vb);
00124 
00125   // Different accumulate versions
00126   void simpAccumulate (vi::VisBuffer2& vb);  // ordinary
00127   void antAccumulate (vi::VisBuffer2& vb);   // antenna-based averaging version
00128 
00129   // Verify zero or two crosshands present (if antAve_p)
00130   void verifyCrosshands(vi::VisBuffer2& vb);
00131 
00132   // Hash function to return the row offset for an interferometer (ant1, ant2)
00133   Int baseline(const Int& ant1, const Int& ant2);
00134 
00135   // Convert r/i to a/p
00136   void convertToAP(Cube<Complex>& d);
00137 
00138   // fill vector that is resized larger
00139   void fillIds(Int nrows);
00140 
00141   // Number of antennas, correlations, and channels
00142   Int nAnt_p, nCorr_p, nChan_p, nBlnMax_p;
00143 
00144   // Weights in input VBs are chan-independent
00145   Bool chanIndepWt_p;
00146 
00147   // Validation by baseline (if False, no attempt to accumulate this baseline)
00148   Vector<Bool> blnOK_p;
00149 
00150   // Are we averaging baselines together?
00151   Bool blnAve_p;
00152 
00153   // Are we averaging antennas together?
00154   Bool antAve_p;
00155 
00156   // Are we incoherently (scalar) averaging?
00157   Bool inCoh_p;
00158 
00159   // Accumulation helpers...
00160   Double timeRef_p;
00161   Double minTime_p;
00162   Double maxTime_p;
00163   Double aveTime_p;
00164   Double aveInterval_p;
00165   Vector<Double> blnWtSum_p;
00166   Double vbWtSum_p;
00167   Int aveScan_p;
00168 
00169   // Optional averaging triggers
00170   Bool doVC_p, doMVC_p, doCVC_p, doFC_p, doUVW_p, doWC_p;
00171 
00172   // Accumulation buffer
00173   vi::VisBuffer2* avBuf_p;
00174 
00175   // Keep track of initialization state
00176   Bool initialized_p;
00177 
00178   // Correlation list for cross-hand swapping
00179   Vector<Int> jcor_p;
00180   
00181   // Diagnostic print level
00182   Int prtlev_;
00183 
00184     // Mutable arrays, set in avBuf_p when finalized
00185     Cube<Complex> avgVisCube_;
00186     Cube<Complex> avgModelCube_;
00187     Cube<Complex> avgCorrectedCube_;
00188     Cube<Float> avgFloatCube_;
00189     Cube<Bool> avgFlagCube_;
00190     Vector<Bool> avgFlagRow_;
00191     Cube<Float> avgWeight_;
00192     Matrix<Double> avgUvw_;
00193     Vector<Int> avgAntenna1_;
00194     Vector<Int> avgAntenna2_;
00195     Vector<Double> avgTime_;
00196     Vector<Double> avgTimeInterval_;
00197     Vector<Int> avgScan_;
00198     // Need to resize these in final avBuf
00199     Vector<Int> fieldid_;
00200     Vector<Int> spw_;
00201     Vector<Int> obsid_;
00202     Vector<Int> stateid_;
00203 };
00204 
00205 
00206 } //# NAMESPACE CASA - END
00207 
00208 #endif
00209 
00210 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1