LCOV - code coverage report
Current view: top level - msvis/MSVis - StatWT.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 2 0.0 %
Date: 2024-10-10 19:51:30 Functions: 0 1 0.0 %

          Line data    Source code
       1             : //# StatWT.h: Sets WEIGHT and SIGMA for a VisBuffGroup according to the scatter
       2             : //#           of its visibilities.
       3             : //# Copyright (C) 2011
       4             : //# Associated Universities, Inc. Washington DC, USA.
       5             : //#
       6             : //# This library is free software; you can redistribute it and/or modify it
       7             : //# under the terms of the GNU Library General Public License as published by
       8             : //# the Free Software Foundation; either version 2 of the License, or (at your
       9             : //# option) any later version.
      10             : //#
      11             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      12             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      14             : //# License for more details.
      15             : //#
      16             : //# You should have received a copy of the GNU Library General Public License
      17             : //# along with this library; if not, write to the Free Software Foundation,
      18             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      19             : //#
      20             : //# Correspondence concerning AIPS++ should be addressed as follows:
      21             : //#        Internet email: casa-feedback@nrao.edu.
      22             : //#        Postal address: AIPS++ Project Office
      23             : //#                        National Radio Astronomy Observatory
      24             : //#                        520 Edgemont Road
      25             : //#                        Charlottesville, VA 22903-2475 USA
      26             : //#
      27             : 
      28             : #ifndef MSVIS_STATWT_H
      29             : #define MSVIS_STATWT_H
      30             : 
      31             : #include <casacore/casa/aips.h>
      32             : #include <casacore/ms/MeasurementSets/MeasurementSet.h>
      33             : #include <msvis/MSVis/GroupWorker.h>
      34             : #include <msvis/MSVis/VisibilityIterator.h>
      35             : #include <msvis/MSVis/VisBufferComponents.h>
      36             : #include <map>
      37             : #include <set>
      38             : 
      39             : namespace casa { //# NAMESPACE CASA - BEGIN
      40             : 
      41             : //# forward decl
      42             : class VisBuffGroup;
      43             : 
      44             : //<summary>StatWT sets WEIGHT and SIGMA statistically</summary>
      45             : //
      46             : // <use visibility=export>
      47             : //
      48             : // <reviewed reviewer="" date="" tests="" demos="">
      49             : 
      50             : // <prerequisite>
      51             : //   <li> <linkto class="VisBuffGroup">VisBuffGroup</linkto>
      52             : //   <li> <linkto class="VisibilityIterator">VisibilityIterator</linkto>
      53             : //   <li> <linkto class="GroupProcessor">GroupProcessor</linkto>
      54             : //   <li> <linkto class="GroupWorker">GroupWorker</linkto>
      55             : // </prerequisite>
      56             : //
      57             : // <etymology>
      58             : // StatWT sets WEIGHT and SIGMA statistically.
      59             : // </etymology>
      60             : //
      61             : //<synopsis>
      62             : // Set the weights and sigmas according to the scatter of the
      63             : // visibilities.
      64             : //</synopsis>
      65             : //
      66             : //<todo>
      67             : // <li> 
      68             : //</todo>
      69             : class StatWT : public GroupWorker
      70             : {
      71             : public:
      72             :   // Construct an object that will set the weights and sigmas of vi's
      73             :   // casacore::MeasurementSet, as selected by outspw, according to the scatter of the
      74             :   // visibilities selected by fitspw.  If dorms is true, assume that the true
      75             :   // mean is 0.  Otherwise, use the standard sample variance.
      76             :   //
      77             :   // For each baseline and correlation, if fitspw does not select at least
      78             :   // minsamp unflagged visibilities, it will be flagged and weight and sigma
      79             :   // will not be calculated.  minsamp is effectively at least 2.
      80             :   //
      81             :   StatWT(const ROVisibilityIterator& vi,
      82             :          const casacore::MS::PredefinedColumns datacol=casacore::MS::DATA,
      83             :          const casacore::String& fitspw="*",
      84             :          const casacore::String& outspw="*",
      85             :          const casacore::Bool dorms=false,
      86             :          const casacore::uInt minsamp=2,
      87             :          const std::vector<casacore::uInt> selcorrs=std::vector<casacore::uInt>());
      88             : 
      89             :   //// Copy construct
      90             :   //StatWT(const StatWT& other) {}
      91             : 
      92             :   // Destructor
      93             :   virtual ~StatWT();
      94             : 
      95             :   //// Assignment
      96             :   //virtual StatWT& operator=(const StatWT& gw) {}
      97             : 
      98             :   // // Returns which columns need to be prefetched for process to work.
      99             :   // virtual asyncio::PrefetchColumns *prefetchColumns() const;
     100             : 
     101             :   // This is where all the work gets done!
     102             :   virtual casacore::Bool process(VisBuffGroup& vbg);
     103             : 
     104             : private:
     105             :   // Disable null c'tor.
     106             :   StatWT();
     107             : 
     108             :   casacore::Bool update_variances(std::map<casacore::uInt, casacore::Vector<casacore::uInt> >& ns,
     109             :                         std::map<casacore::uInt, casacore::Vector<casacore::Complex> >& means,
     110             :                         std::map<casacore::uInt, casacore::Vector<casacore::Double> >& variances,
     111             :                         const VisBuffer& vb,
     112             :                         const casacore::Cube<casacore::Bool>& chanmaskedflags, const casacore::uInt maxAnt);
     113             : 
     114             :   // ns and variances are effectively const here, but declaring them that way
     115             :   // would take some gymnastics.
     116             :   casacore::Bool apply_variances(VisBuffer& vb,
     117             :                        std::map<casacore::uInt, casacore::Vector<casacore::uInt> >& ns,
     118             :                        std::map<casacore::uInt, casacore::Vector<casacore::Double> >& variances,
     119             :                        const casacore::uInt maxAnt);
     120             : 
     121             :   // Compute a baseline (row) index (ant1, ant2).
     122             :   // It ASSUMES that ant1 and ant2 are both <= maxAnt.
     123           0 :   casacore::uInt hashFunction(const casacore::Int ant1, const casacore::Int ant2, const casacore::Int maxAnt)
     124             :   {
     125           0 :     return (maxAnt + 1) * ant1 - (ant1 * (ant1 - 1)) / 2 + ant2 - ant1;
     126             :   }
     127             : 
     128             :   // Initialized by c'tor:
     129             : 
     130             :   // Which of DATA, MODEL_DATA, or CORRECTED_DATA to fit.
     131             :   // It will always _write_ to DATA if datacols_p.nelements() == 1, and write
     132             :   // to all 3 otherwise.  Thus datacols_p.nelements() should be either 1 or 3.
     133             :   // 4 and 2 are right out, and FLOAT_DATA isn't handled by this yet.
     134             :   casacore::MS::PredefinedColumns datacol_p;
     135             : 
     136             :   casacore::String fitspw_p;      // Line-free channels used for the fit.  Can include ;
     137             :   casacore::String outspw_p;      // Channels to write out.  Does not yet support ;.
     138             :   casacore::Bool   dorms_p;       // If true, assume that the true mean is 0.
     139             :   casacore::uInt   rowsdone_p;    // How many rows have been written so far.
     140             :   std::set<casacore::Int> outspws_p;  // Spws to reweight.
     141             :                                 // Otherwise, use the standard sample variance.
     142             :   casacore::uInt   minsamp_p;     // Minimum # of unflagged visibilities for calculating
     143             :                         // a variance.
     144             :   std::vector<casacore::uInt> selcorrs_p;
     145             :   // Not initialized by c'tor:
     146             :   //std::set<casacore::Int> appliedSpWs_p;
     147             :   std::map<casacore::Int, casacore::Vector<casacore::Bool>*> fitmask_p;      // spw -> a list of flags by chan
     148             : };
     149             : 
     150             : } //# NAMESPACE CASA - END
     151             : 
     152             : #endif
     153             : 

Generated by: LCOV version 1.16