LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - CalibratingVi2.h (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 2 7 28.6 %
Date: 2023-11-06 10:06:49 Functions: 3 9 33.3 %

          Line data    Source code
       1             : //# CalibratingVi2.h: Interface definition of the CalibratingVi2 class.
       2             : //#
       3             : //#  CASA - Common Astronomy Software Applications (http://casa.nrao.edu/)
       4             : //#  Copyright (C) Associated Universities, Inc. Washington DC, USA 2011, All rights reserved.
       5             : //#  Copyright (C) European Southern Observatory, 2011, All rights reserved.
       6             : //#
       7             : //#  This library is free software; you can redistribute it and/or
       8             : //#  modify it under the terms of the GNU Lesser General Public
       9             : //#  License as published by the Free software Foundation; either
      10             : //#  version 2.1 of the License, or (at your option) any later version.
      11             : //#
      12             : //#  This library is distributed in the hope that it will be useful,
      13             : //#  but WITHOUT ANY WARRANTY, without even the implied warranty of
      14             : //#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             : //#  Lesser General Public License for more details.
      16             : //#
      17             : //#  You should have received a copy of the GNU Lesser General Public
      18             : //#  License along with this library; if not, write to the Free Software
      19             : //#  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      20             : //#  MA 02111-1307  USA
      21             : //# $Id: $
      22             : 
      23             : #ifndef CalibratingVi2_H_
      24             : #define CalibratingVi2_H_
      25             : 
      26             : // Where TransformingVi2 interface is defined
      27             : #include <msvis/MSVis/TransformingVi2.h>
      28             : #include <synthesis/MeasurementComponents/Calibrater.h>
      29             : #include <synthesis/MeasurementEquations/VisEquation.h>
      30             : 
      31             : #include <casacore/casa/Containers/Record.h>
      32             : 
      33             : namespace casa { //# NAMESPACE CASA - BEGIN
      34             : namespace vi { //# NAMESPACE VI - BEGIN
      35             : 
      36             : class CalibratingParameters {
      37             : 
      38             : // TBD:  add solve-context parameters, like apply pivot (solved-for term), normalization
      39             : 
      40             : public:
      41             : 
      42             :   CalibratingParameters();
      43             : 
      44             :   CalibratingParameters(const casacore::Record& calLibRecord);
      45             :   CalibratingParameters(const casacore::String& callib);
      46             :   CalibratingParameters(casacore::Float corrFactor); // temporary, for initial testing
      47             : 
      48             :   CalibratingParameters(const CalibratingParameters& other);
      49             :   CalibratingParameters& operator=(const CalibratingParameters & other);
      50             : 
      51             :   casacore::Bool byCalLib() const;
      52             : 
      53             :   const casacore::Record& getCalLibRecord() const;
      54             :   casacore::Float getCorrFactor() const;  
      55             : 
      56             :   void setCalLibRecord(const casacore::Record& calLibRecord);
      57             :   void setCorrFactor(casacore::Float corrFactor);  
      58             : 
      59             : private:
      60             : 
      61             :   void validate() const;
      62             :   casacore::Bool byCalLib_p;
      63             :   casacore::Record calLibRecord_p;
      64             :   casacore::Float corrFactor_p;  // temporary, for initial testing
      65             : };
      66             : 
      67             : 
      68             : 
      69             : 
      70             : class CalibratingVi2 : public vi::TransformingVi2
      71             : {
      72             : 
      73             : public:
      74             : 
      75             :   CalibratingVi2( vi::ViImplementation2 * inputVii,
      76             :                   const CalibratingParameters& calpar);
      77             : 
      78             :   // From cal pars and an MS (used by OTF calibration outside synthesis)
      79             :   CalibratingVi2( vi::ViImplementation2 * inputVii,
      80             :                   const CalibratingParameters& calpar,
      81             :                   casacore::String msname);
      82             : 
      83             :   // From a VE pointer (used within synthesis, e.g., for solving)
      84             :   CalibratingVi2( vi::ViImplementation2 * inputVii,
      85             :                   VisEquation *ve);
      86             : 
      87             :   ~CalibratingVi2();
      88             :   
      89             :   // Report the the ViImplementation type
      90           0 :   virtual casacore::String ViiType() const { return casacore::String("Cal( ")+getVii()->ViiType()+" )"; };
      91             : 
      92             : 
      93             :   // Iterating management
      94             :   virtual void origin ();
      95             :   virtual void next ();
      96             : 
      97             :   // Smart corrected data/weights/flags accessors
      98             :   virtual void weight(casacore::Matrix<casacore::Float>& wt) const;
      99             :   virtual void weightSpectrum(casacore::Cube<casacore::Float>& wtsp) const;
     100             :   virtual void visibilityCorrected(casacore::Cube<casacore::Complex>& vis) const;
     101             :   virtual void flag(casacore::Cube<casacore::Bool>& flagC) const;
     102             :   //  virtual void flag(casacore::Matrix<casacore::Bool>& flagM) const;  // CORR-INDEP FLAGS DEPRECATED IN VI2/VB2?
     103             : 
     104             :   // Reports true in case of *Corrected columns
     105             :   //  (because this class provides it, even if it doesn't exist physically!)
     106             :   virtual casacore::Bool existsColumn (VisBufferComponent2 id) const;
     107             :   
     108             : protected:
     109             : 
     110             :   // Correct the current VB
     111             :   virtual void calibrateCurrentVB() const;
     112             : 
     113             :   // Initialize corrected data member to raw data
     114             :   //  (this method is sensitive to DATA vs. FLOAT_DATA
     115             :   virtual void initCorrected(casa::vi::VisBuffer2* vb) const;
     116             : 
     117             :   // Calibrater and VisEquation
     118             :   Calibrater *cb_p;
     119             :   VisEquation *ve_p;   
     120             : 
     121             :   // A simple factor for testing
     122             :   casacore::Float corrFactor_p;  
     123             : 
     124             :   // signals whether or not correctCurrentVB has been called
     125             :   mutable casacore::Bool visCalibrationOK_p;
     126             : 
     127             : };
     128             : 
     129             : class CalVi2LayerFactory : public ViiLayerFactory {
     130             : 
     131             :  public:
     132             : 
     133             :   CalVi2LayerFactory(const CalibratingParameters& calpars);
     134             : 
     135           0 :   virtual ~CalVi2LayerFactory () {}
     136             : 
     137             :  protected:
     138             : 
     139             :   // CalVi2-specific layer-creater
     140             :   //   
     141             :   virtual ViImplementation2 * createInstance (ViImplementation2* vii0) const;
     142             : 
     143             :   // Store a copy of the parameters
     144             :   const CalibratingParameters calpars_;
     145             : 
     146             : 
     147             : };
     148             : 
     149             : class CalSolvingVi2 : public vi::CalibratingVi2
     150             : {
     151             : 
     152             : public:
     153             : 
     154             :   CalSolvingVi2( vi::ViImplementation2 * inputVii,
     155             :                  const CalibratingParameters& calpar);
     156             : 
     157             :   CalSolvingVi2( vi::ViImplementation2 * inputVii,
     158             :                  const CalibratingParameters& calpar,
     159             :                  casacore::String msname);
     160             : 
     161             :   CalSolvingVi2( vi::ViImplementation2 * inputVii,
     162             :                  VisEquation *ve,
     163             :                  const casacore::Bool& corrDepFlags=false);
     164             : 
     165             :   ~CalSolvingVi2();
     166             : 
     167             : 
     168             :   // Iterating management
     169             :   virtual void originChunks(casacore::Bool forceRewind = false);
     170             :   virtual void origin ();
     171             :   virtual void next ();
     172             : 
     173             :   // Report the the ViImplementation type
     174           0 :   virtual casacore::String ViiType() const {
     175           0 :       return casacore::String("CalForSolve( ")+getVii()->ViiType()+" )";
     176             :   }
     177             : 
     178             :   // Weight spectrum exists _by_defn_ in the solving context
     179             :   //  (it is generated by verifyWeightSpectrum() below)
     180      794242 :   virtual casacore::Bool weightSpectrumExists () const { return true; };
     181             : 
     182             :   // Cal solving also involve modified model data
     183             :   virtual void visibilityModel(casacore::Cube<casacore::Complex>& vis) const;
     184             :   
     185             : private:
     186             : 
     187             :   // specialized cal application for solving
     188             :   virtual void calibrateCurrentVB() const;
     189             : 
     190             :   // Flag all corrs if any one is flagged (OLD style)
     191             :   virtual void corrIndepFlags(casa::vi::VisBuffer2* vb) const;
     192             : 
     193             :   // Ensure weightSpectrum is populated
     194             :   virtual void verifyWeightSpectrum(casa::vi::VisBuffer2* vb) const;
     195             : 
     196             :   // Sample counters
     197             :   mutable casacore::Int64 ntotal_,nflagged_,nskipped_;
     198             :   mutable casacore::Int64 nVB_,nVB0_;
     199             :   mutable casacore::Double Tio_,Tcalws_,Tcalfl_,Tcal2_;
     200             : 
     201             :   casacore::Bool corrDepFlags_;
     202             : 
     203             : };
     204             : 
     205             : 
     206             : class CalSolvingVi2LayerFactory : public CalVi2LayerFactory {
     207             : 
     208             :  public:
     209             : 
     210             :   CalSolvingVi2LayerFactory(const CalibratingParameters& calpars);
     211             : 
     212           0 :   virtual ~CalSolvingVi2LayerFactory () {}
     213             : 
     214             :  protected:
     215             : 
     216             :   // CalSolvingVi2-specific layer-creater
     217             :   virtual ViImplementation2 * createInstance (ViImplementation2* vii0) const;
     218             : 
     219             : };
     220             : 
     221             : class CalSolvingVi2LayerFactoryByVE : public ViiLayerFactory {
     222             : 
     223             :  public:
     224             : 
     225             :   CalSolvingVi2LayerFactoryByVE(VisEquation* ve,const casacore::Bool& corrDepFlags=false);  // From a VE pointer in calling scope
     226             : 
     227         334 :   virtual ~CalSolvingVi2LayerFactoryByVE () {}
     228             : 
     229             :  protected:
     230             : 
     231             :   // CalSolvingVi2-specific layer-creater
     232             :   virtual ViImplementation2 * createInstance (ViImplementation2* vii0) const;
     233             : 
     234             :  private:
     235             :   
     236             :   VisEquation *ve_p;
     237             : 
     238             :   casacore::Bool corrDepFlags_;
     239             : 
     240             : };
     241             : 
     242             : 
     243             : 
     244             : 
     245             : } //# NAMESPACE VI - END
     246             : } //# NAMESPACE CASA - END
     247             : 
     248             : 
     249             : #endif /* CalibratingVi2_H_ */
     250             : 

Generated by: LCOV version 1.16