LCOV - code coverage report
Current view: top level - msvis/MSVis - VisBuffAccumulator.h (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 6 10 60.0 %
Date: 2023-11-06 10:06:49 Functions: 6 7 85.7 %

          Line data    Source code
       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 <casacore/casa/aips.h>
      32             : #include <msvis/MSVis/VisBuffer.h>
      33             : #include <msvis/MSVis/CalVisBuffer.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             : 
      74             : class VisBuffAccumulator
      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
      83             :   ~VisBuffAccumulator();
      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         126 :   VisBuffer& aveVisBuff() { return avBuf_p; }
      98        4646 :   CalVisBuffer& aveCalVisBuff() { return avBuf_p; }
      99             : 
     100             :   // Global timestamp info
     101         124 :   casacore::Double& timeStamp() { return globalTime_p; };
     102         124 :   casacore::Double& timeStampWt() { return globalTimeWt_p; };
     103             : 
     104             :   // The number of VisBuffers that have been accumulated.
     105             :   casacore::uInt nBuf() {return nBuf_p;}
     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.
     113           0 :   const casacore::Vector<casacore::Int>& outToInRow(const casacore::Bool hurl=true){
     114           0 :     if(hurl && nBuf_p != 1)
     115           0 :       throw_err("outToInRow", "The output to input row map is unreliable");
     116           0 :     return outToInRow_p;
     117             :   }
     118             : 
     119         124 :   void setTVIDebug(bool debug) {tvi_debug = debug;}
     120             : 
     121             :   void reportData();
     122             : 
     123             : protected:
     124             :   // Averaging buffer
     125             :   CalVisBuffer avBuf_p;
     126             : 
     127             :   // Number of correlations and channels
     128             :   casacore::Int nCorr_p, nChan_p;
     129             : 
     130             : private:
     131             :   // Prohibit null constructor, copy constructor and assignment for now
     132             :   VisBuffAccumulator();
     133             :   VisBuffAccumulator& operator= (const VisBuffAccumulator&);
     134             :   VisBuffAccumulator (const VisBuffAccumulator&);
     135             : 
     136             :   // Diagnostic printing level
     137       13307 :   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
     153             :   casacore::Int nAnt_p;
     154             : 
     155             :   // Averaging interval
     156             :   casacore::Double interval_p;
     157             : 
     158             :   // Pre-normalization flag
     159             :   casacore::Bool prenorm_p;
     160             : 
     161             :   // Diagnostic print level
     162             :   casacore::Int prtlev_;
     163             : 
     164             :   // How many VisBuffers have been accumulated.
     165             :   casacore::uInt nBuf_p;
     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
     172             :   casacore::Double aveTime_p;
     173             :   casacore::Double aveTimeWt_p;
     174             : 
     175             :   // Global timestamp average
     176             :   casacore::Double globalTime_p;
     177             :   casacore::Double globalTimeWt_p;
     178             : 
     179             :   // Start time and row of current accumulation
     180             :   casacore::Double tStart_p;
     181             :   casacore::Int avrow_p;
     182             : 
     183             :   // Flag to mark the first accumulation interval
     184             :   casacore::Bool firstInterval_p;
     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.
     188             :   casacore::Vector<casacore::Int> outToInRow_p;
     189             : 
     190             :   bool tvi_debug;
     191             : };
     192             : 
     193             : 
     194             : } //# NAMESPACE CASA - END
     195             : 
     196             : #endif
     197             : 
     198             : 

Generated by: LCOV version 1.16