LCOV - code coverage report
Current view: top level - msvis/MSVis - AveragingTvi2.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 2 3 66.7 %
Date: 2024-11-06 17:42:47 Functions: 1 2 50.0 %

          Line data    Source code
       1             : #if ! defined (Msvis_AveragingTvi2_H_121211_1236)
       2             : #define Msvis_AveragingTvi2_H_121211_1236
       3             : 
       4             : #include <casacore/casa/aips.h>
       5             : #include <msvis/MSVis/TransformingVi2.h>
       6             : #include <msvis/MSVis/VisibilityIterator2.h>
       7             : #include <msvis/MSVis/AveragingVi2Factory.h>
       8             : 
       9             : namespace casa {
      10             : 
      11             : namespace ms {
      12             : 
      13             : class MsRow;
      14             : 
      15             : };
      16             : 
      17             : namespace vi {
      18             : 
      19             : class AveragingOptions;
      20             : 
      21             : namespace avg {
      22             : 
      23             : class MsRowAvg;
      24             : class VbAvg;
      25             : 
      26             : }
      27             : 
      28             : class AveragingTvi2 : public TransformingVi2 {
      29             : 
      30             : public:
      31             : 
      32             :     AveragingTvi2 (ViImplementation2 * inputVii,
      33             :                    const AveragingParameters & averagingParameters);
      34             :     ~AveragingTvi2 ();
      35             : 
      36             :     // Report the the ViImplementation type
      37           0 :     virtual casacore::String ViiType() const { return casacore::String("TimeAve( ")+getVii()->ViiType()+" )"; };
      38             : 
      39             :     /////////////////////////////////////////////////////////////////////////
      40             :     //
      41             :     // Chunk/Subchunk structure in the AveragingTvi2
      42             :     //
      43             :     // The averaging interval, in seconds, is specified at construction time.
      44             :     // The interval (i.e., the size of the chunk in time) is also specified
      45             :     // at creation time; the interval must be an integer multiple of the
      46             :     // averaging interval.
      47             :     //
      48             :     // The input VI's setting must be compatible with those of the
      49             :     // AveragingTvi2.  This means that the chunk size of the input VI must
      50             :     // have the same duration as the averaging VI.  Although the input VI
      51             :     // and the averaging VI have the same duration, the averaging VI will
      52             :     // have fewer subchunks since N input subchunks will be averaged down
      53             :     // to create a single output subchunk.
      54             :     //
      55             :     // The input VI will also define the averaging boundaries by its
      56             :     // definition of a chunk.  For example, if the input VI allows data with
      57             :     // different scans to be in the same chunk, then they will potentially
      58             :     // be averaged together.
      59             :     //
      60             :     // The input VI must use the data description ID as a sort column so that
      61             :     // a chunk will only contain data from a single DDID setting.
      62             : 
      63             :     void originChunks (casacore::Bool forceRewind = false);
      64             :     void nextChunk ();
      65             :     casacore::Bool moreChunks () const;
      66             : 
      67             :     void origin ();
      68             :     void next ();
      69             :     casacore::Bool more () const;
      70             : 
      71             :     void writeFlag (const casacore::Cube<casacore::Bool> & flag);
      72             :     void writeFlagRow (const casacore::Vector<casacore::Bool> & rowflags);
      73             : 
      74             :     virtual void visibilityCorrected(casacore::Cube<casacore::Complex>& vis) const;
      75             :     virtual void visibilityModel(casacore::Cube<casacore::Complex>& vis) const;
      76             :     virtual void visibilityObserved(casacore::Cube<casacore::Complex>& vis) const;
      77             :     virtual void floatData(casacore::Cube<casacore::Float>& fcube) const;
      78             :     virtual void flag(casacore::Cube<casacore::Bool>& flags) const;
      79             :     virtual void flagRow(casacore::Vector<casacore::Bool>& rowflags) const;
      80             :     virtual void weight(casacore::Matrix<casacore::Float>& wtmat) const;
      81             :     virtual void sigma(casacore::Matrix<casacore::Float>& sigmat) const;
      82             :     virtual void weightSpectrum (casacore::Cube<casacore::Float> & wtsp) const;
      83             :     virtual void sigmaSpectrum (casacore::Cube<casacore::Float> & sigsp) const;
      84             :     virtual casacore::Bool weightSpectrumExists () const;
      85             :     virtual casacore::Bool sigmaSpectrumExists () const;
      86             :     virtual void exposure (casacore::Vector<double> & expo) const;
      87             :     virtual void getRowIds (casacore::Vector<casacore::rownr_t> & rowids) const;
      88             :     virtual void time (casacore::Vector<double> & t) const;
      89             :     virtual void timeInterval (casacore::Vector<double> & ti) const;
      90             :     virtual void timeCentroid (casacore::Vector<double> & t) const;
      91             :     virtual void antenna1 (casacore::Vector<casacore::Int> & ant1) const;
      92             :     virtual void antenna2 (casacore::Vector<casacore::Int> & ant2) const;
      93             :     virtual void uvw (casacore::Matrix<double> & uvwmat) const;
      94             : 
      95             :     static casacore::Float weightToSigma (casacore::Float weight);
      96   811073677 :     static inline casacore::Float sigmaToWeight (casacore::Float sigma)
      97             :     {
      98   811073677 :         return sigma > FLT_MIN ? 1.0 / (sigma * sigma) : 0.0; // bad sample
      99             :     }
     100             : 
     101             : 
     102             :     static casacore::Vector<casacore::Float> average (const casacore::Matrix<casacore::Float> &data, const casacore::Matrix<casacore::Bool> &flags);
     103             :     static casacore::Matrix<casacore::Float> average (const casacore::Cube<casacore::Float> &data, const casacore::Cube<casacore::Bool> &flags);
     104             : 
     105             : protected:
     106             : 
     107             :     void advanceInputVii ();
     108             :     casacore::Int determineDdidToUse () const;
     109             :     casacore::Bool inputExceedsTimeDistance (ms::MsRow * rowInput, avg::MsRowAvg * rowAveraged);
     110             :     casacore::Bool inputExceedsUvwDistance (ms::MsRow * rowInput, avg::MsRowAvg * rowAveraged);
     111             :     void produceSubchunk ();
     112             :     void processInputSubchunk (const VisBuffer2 *);
     113             :     // casacore::Bool reachedAveragingBoundary();
     114             :     void captureIterationInfo (const VisBuffer2 * vb2);
     115             :     bool subchunksReady () const;
     116             :     void validateInputVi (ViImplementation2 *);
     117             : 
     118             : private:
     119             : 
     120             :     const casacore::Double averagingInterval_p; // averaging interval in seconds
     121             :     AveragingOptions averagingOptions_p;
     122             :     AveragingParameters averagingParameters_p;
     123             :     casacore::Int ddidLastUsed_p; // ddId last used to produce a subchunk.
     124             :     casacore::Bool inputViiAdvanced_p; // true if input VII was advanced but data not used
     125             :     casacore::Bool more_p;
     126             :     Subchunk subchunk_p;
     127             :     casacore::Bool subchunkExists_p;
     128             :     avg::VbAvg * vbAvg_p;
     129             :     WeightScaling * weightScaling_p;
     130             :     // Bookkeeping required by writeFlag() and writeFlagRow()
     131             :     casacore::Int startBuffer_p;
     132             :     casacore::Int endBuffer_p;
     133             : };
     134             : 
     135             : } // end namespace vi
     136             : 
     137             : } // end namespace casa
     138             : 
     139             : #endif // ! defined (Msvis_AveragingTvi2_H_121211_1236)

Generated by: LCOV version 1.16