LCOV - code coverage report
Current view: top level - flagging/Flagging - RFChunkStats.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 33 0.0 %
Date: 2024-10-04 18:58:15 Functions: 0 22 0.0 %

          Line data    Source code
       1             : //# RFChunkStats.h: this defines RFChunkStats
       2             : //# Copyright (C) 2000,2001
       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: casa-feedback@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$
      27             : #ifndef FLAGGING_RFCHUNKSTATS_H
      28             : #define FLAGGING_RFCHUNKSTATS_H
      29             : 
      30             : #include <casacore/measures/Measures/Stokes.h> 
      31             : #include <casacore/casa/Arrays/Vector.h> 
      32             : #include <casacore/casa/Arrays/Matrix.h> 
      33             : #include <casacore/casa/Arrays/Cube.h> 
      34             : #include <casacore/casa/Containers/Block.h> 
      35             : #include <casacore/lattices/Lattices/LatticeIterator.h> 
      36             : #include <flagging/Flagging/RFCommon.h>
      37             : 
      38             : namespace casacore{
      39             : 
      40             : class MeasurementSet;
      41             : }
      42             : 
      43             : namespace casa { //# NAMESPACE CASA - BEGIN
      44             : 
      45             : class Flagger;
      46             : class VisibilityIterator;
      47             : class VisBuffer;
      48             : 
      49             : class RFABase;
      50             : typedef RFABase RFA;
      51             : 
      52             : // <summary>
      53             : // RFChunkStats: vital information and flagging stats for a visibility chunk
      54             : // </summary>
      55             : 
      56             : // <use visibility=local>
      57             : 
      58             : // <reviewed reviewer="" date="" tests="" demos="">
      59             : // </reviewed>
      60             : 
      61             : // <prerequisite>
      62             : //   <li> VisibilityIterator
      63             : //   <li> VisBuffer
      64             : //   <li> MeasurementSet
      65             : //   <li> Flagger
      66             : // </prerequisite>
      67             : //
      68             : // <etymology>
      69             : // </etymology>
      70             : //
      71             : // <synopsis>
      72             : // RFChunkStats maintains various stats, derived values, and flagging
      73             : // counts for a single visibility chunk. Also serves as an interface to
      74             : // VisIter and VisBuffer.
      75             : // </synopsis>
      76             : //
      77             : // <motivation>
      78             : // Vital information about an casacore::MS or a visibility chunk is spread all over 
      79             : // three classes (casacore::MS, VisIter, VisBuffer). RFChunkStats provides a central
      80             : // point for flagging agents to look this info up. 
      81             : // </motivation>
      82             : //
      83             : // <todo asof="2001/04/16">
      84             : //   <li> add this feature
      85             : //   <li> fix this bug
      86             : //   <li> start discussion of this possible extension
      87             : // </todo>
      88             : 
      89             : class RFChunkStats : public FlaggerEnums
      90             : {
      91             : protected:
      92             :   VisibilityIterator &visiter;
      93             :   VisBuffer          &visbuf;
      94             :   Flagger            &flagger;
      95             :   
      96             :   casacore::IPosition visshape;  
      97             :   casacore::uInt counts[Num_StatEnums];
      98             :   casacore::Matrix<casacore::uInt> nf_ifr_time,nf_chan_ifr;
      99             :   casacore::Vector<casacore::uInt> rows_per_ifr;
     100             :   casacore::Vector<casacore::uInt> nrf_ifr,nrf_time;
     101             :   casacore::Vector<casacore::Int>  ifr_nums;
     102             :   casacore::Vector<casacore::Int>  feed_nums;
     103             :   casacore::Vector<casacore::Int>  corrtypes;
     104             :   casacore::Vector<casacore::Double> freq;
     105             :   casacore::String       corr_string;
     106             :   casacore::Double       start_time,end_time,current_time;
     107             :   casacore::uInt chunk_no,pass_no;
     108             :   casacore::Int itime;
     109             : 
     110             : //  casacore::Matrix<casacore::uInt> nf_corr_ifr, nf_chan_corr, nf_chan_time, nf_corr_time;
     111             :   
     112             :   std::vector<double> scan_start;      /* first time stamp in scan */
     113             :   std::vector<double> scan_start_flag; /* first time stamp with any 
     114             :                                           unflagged data in scan*/
     115             :   std::vector<double> scan_end, scan_end_flag; /* as above */
     116             :   
     117             : 
     118             : 
     119             : public:
     120             : // constructor
     121             :   RFChunkStats( VisibilityIterator &vi,VisBuffer &vb,Flagger &rf );
     122             : 
     123             : // accessors to VisIter
     124             :   const VisibilityIterator & visIter () const { return visiter; }
     125           0 :   VisibilityIterator & visIter () { return visiter; }
     126             : // accessor to VisBuffer
     127           0 :   VisBuffer &visBuf () { return visbuf; }
     128             : // accessor to MS
     129             :   const casacore::MeasurementSet & measSet () const;
     130             : // accessor to MS
     131             :   const casacore::String msName () const;
     132             : // returns antenna names
     133             :   const casacore::Vector<casacore::String>  & antNames () const;
     134             : 
     135             :   // scan start/end times
     136           0 :   double get_scan_start(unsigned scan) const
     137           0 :     { return scan_start[scan]; }
     138             : 
     139           0 :   double get_scan_end(unsigned scan) const
     140           0 :     { return scan_end[scan]; }
     141             : 
     142             :   // scan start/end times for unflagged data
     143             :   //
     144             :   // returns: time stamps of first/last unflagged
     145             :   // data in the given scan, or a negative number 
     146             :   // if there's no unflagged data in the scan.
     147           0 :   double get_scan_start_unflagged(unsigned scan) const
     148           0 :     { return scan_start_flag[scan]; }
     149             : 
     150           0 :   double get_scan_end_unflagged(unsigned scan) const
     151           0 :     { return scan_end_flag[scan]; }
     152             : 
     153             : // loads data for new chunk, resets all flag stat counters
     154             :   void newChunk (bool init_quack);
     155             : // loads data for new pass
     156             :   void newPass (casacore::uInt npass);
     157             : // loads data for new iteration
     158             :   void newTime ();
     159             : 
     160             : // returns current chunk number
     161           0 :   casacore::uInt nchunk() const { return chunk_no; };
     162             : // returns current pass number
     163           0 :   casacore::uInt npass()  const { return pass_no; };
     164             : // returns current time slot
     165           0 :   casacore::Int  iTime()  const { return itime; };
     166             : 
     167             : // returns a data dimension (POL, CHAN, IFR, etc.)
     168           0 :   casacore::uInt num ( StatEnums which ) const { return counts[which]; }
     169             : // returns vector of frequencies (one per channel)
     170             :   const casacore::Vector<casacore::Double> & frequency ();
     171             :   
     172             : // returns time of currently iterated time slot
     173             :   casacore::Double currentMJD () const     
     174             :     { return current_time; }
     175             : // return first time slot in chunk
     176             :   casacore::Double startMJD () const     
     177             :     { return start_time; }
     178             : // return last time slot in chunk
     179             :   casacore::Double endMJD () const       
     180             :     { return end_time; }
     181             : 
     182             : // returns corr mask corresponding to specified casacore::Stokes types
     183             : // (templated, but only casacore::String and casacore::Int will actually work)
     184             :   template<class T> RFlagWord getCorrMask ( const casacore::Vector<T> &corrspec );
     185             :   
     186             : // returns mask with all correlations
     187           0 :   RFlagWord fullCorrMask () { return (1<<num(CORR))-1; };
     188             : // returns string of correlations
     189           0 :   const casacore::String & getCorrString () { return corr_string; }
     190             : 
     191             : // returns IFR index corresponding to current VisBuffer rows
     192           0 :   casacore::uInt ifrNum( casacore::uInt nr )  { return ifr_nums(nr); };
     193             : // returns IFR index corresponding to current VisBuffer rows
     194           0 :   const casacore::Vector<casacore::Int> & ifrNums ()  { return ifr_nums; };
     195             : 
     196             : // returns FEED index corresponding to current VisBuffer rows
     197             :   casacore::uInt feedNum( casacore::uInt nr )  { return feed_nums(nr); };
     198             : // returns FEED index corresponding to current VisBuffer rows
     199           0 :   const casacore::Vector<casacore::Int> & feedNums ()  { return feed_nums; };
     200             : 
     201             : // converts antenna indices into IFR index
     202             :   casacore::uInt antToIfr ( casacore::uInt ant1,casacore::uInt ant2 );
     203             : // converts IFR index back to antenna numbers
     204             :   void ifrToAnt ( casacore::uInt &ant1,casacore::uInt &ant2,casacore::uInt ifr );
     205             : // converts IFR index to standard ID string 
     206             :   casacore::String ifrString ( casacore::uInt ifr ); 
     207             :   
     208             : // data availability stats, per IFR
     209             :   casacore::uInt nrowPerIfr ( casacore::uInt ifr )            { return rows_per_ifr(ifr); }
     210             :   const casacore::Vector<casacore::uInt> & nrowPerIfr () const { return rows_per_ifr; }
     211             : 
     212             : // accessors to various flagging stats
     213           0 :   casacore::uInt & nfIfrTime ( casacore::uInt ifr,casacore::uInt itime )  
     214           0 :                                           { return nf_ifr_time(ifr,itime); }
     215           0 :   const casacore::Matrix<casacore::uInt> & nfIfrTime () const    
     216           0 :                                           { return nf_ifr_time; }
     217           0 :   casacore::uInt & nfChanIfr ( casacore::uInt ich,casacore::uInt ifr   )  // flags per channel and ifr
     218           0 :                                           { return nf_chan_ifr(ich,ifr); }
     219             :   const casacore::Matrix<casacore::uInt> & nfChanIfr () const   
     220             :                                           { return nf_chan_ifr; }        
     221           0 :   casacore::Matrix<casacore::uInt> & nfChanIfr ()
     222           0 :                                           { return nf_chan_ifr; }        
     223           0 :   casacore::uInt & nrfIfr  (casacore::uInt i)                  
     224           0 :                                           { return nrf_ifr(i); }
     225           0 :   casacore::uInt & nrfTime (casacore::uInt i)                  
     226           0 :                                           { return nrf_time(i); }
     227           0 :   const casacore::Vector<casacore::uInt> & nrfIfr  () const     
     228           0 :                                           { return nrf_ifr; };
     229             :   const casacore::Vector<casacore::uInt> & nrfTime () const     
     230             :                                           { return nrf_time; };
     231             : 
     232             :   //casacore::Matrix<casacore::uInt> nf_corr_ifr, nf_chan_corr, nf_chan_time, nf_corr_time;
     233             :   //casacore::uInt & nfCorrIfr( casacore::uInt icorr, casacore::uInt ifr ) { return nf_corr_ifr(icorr,ifr); }
     234             :   //const casacore::Matrix<casacore::uInt> & nfCorrIfr () const { return nf_corr_ifr; }
     235             :   //casacore::uInt & nfChanCorr( casacore::uInt ich, casacore::uInt icorr ) { return nf_chan_corr(ich,icorr); }
     236             :   //const casacore::Matrix<casacore::uInt> & nfChanCorr () const { return nf_chan_corr; }
     237             :   //casacore::uInt & nfChanTime( casacore::uInt ich, casacore::uInt itime ) { return nf_chan_time(ich,itime); }
     238             :   //const casacore::Matrix<casacore::uInt> & nfChanTime () const { return nf_chan_time; }
     239             :   //casacore::uInt & nfCorrTime( casacore::uInt icorr, casacore::uInt itime ) { return nf_corr_time(icorr,itime); }
     240             :   //const casacore::Matrix<casacore::uInt> & nfCorrTime () const { return nf_corr_time; }
     241             :   
     242             : // prints stats to stderr
     243             :   void printStats ();
     244             : };
     245             : 
     246             : // enums for which stats are actually collected
     247             : const RFChunkStats::StatEnums active_stats[] = { RFChunkStats::CHAN,RFChunkStats::IFR,RFChunkStats::TIME };
     248             : const casacore::uInt num_active_stats = 3;
     249             : 
     250             : // global function for finding polarization by index
     251             : casacore::Int findCorrType( casacore::Stokes::StokesTypes type,const casacore::Vector<casacore::Int> &corr );
     252             : 
     253             : 
     254             : } //# NAMESPACE CASA - END
     255             : 
     256             : #ifndef AIPS_NO_TEMPLATE_SRC
     257             : #include <flagging/Flagging/RFChunkStats.tcc>
     258             : #endif //# AIPS_NO_TEMPLATE_SRC
     259             : #endif

Generated by: LCOV version 1.16