LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - UVMod.h (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 24 24 100.0 %
Date: 2023-11-06 10:06:49 Functions: 24 24 100.0 %

          Line data    Source code
       1             : //# UVMod.h: Definitions of interface for UV-modelling in calibrater
       2             : //# Copyright (C) 1996,1997,2000,2001,2002,2003
       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 adressed 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             : //#
      27             : 
      28             : #ifndef SYNTHESIS_UVMOD_H
      29             : #define SYNTHESIS_UVMOD_H
      30             : 
      31             : #include <casacore/casa/aips.h>
      32             : #include <casacore/casa/Containers/Record.h>
      33             : #include <casacore/casa/BasicSL/Complex.h>
      34             : #include <casacore/casa/BasicSL/Constants.h>
      35             : #include <synthesis/MeasurementEquations/Iterate.h>
      36             : #include <msvis/MSVis/VisSet.h>
      37             : #include <casacore/measures/Measures/MDirection.h>
      38             : #include <casacore/measures/Measures/MPosition.h>
      39             : #include <casacore/casa/Arrays/Array.h>
      40             : #include <casacore/casa/Arrays/Vector.h>
      41             : #include <casacore/casa/Arrays/Matrix.h>
      42             : #include <components/ComponentModels/ComponentType.h>
      43             : #include <components/ComponentModels/ComponentList.h>
      44             : #include <components/ComponentModels/SkyComponent.h>
      45             : 
      46             : 
      47             : namespace casa { //# NAMESPACE CASA - BEGIN
      48             : 
      49             : // <summary> 
      50             : // VisCal: Model multiplicative errors for the <linkto class="VisEquation">VisEquation</linkto>
      51             : // </summary>
      52             : 
      53             : // <use visibility=export>
      54             : 
      55             : // <reviewed reviewer="" date="" tests="" demos="">
      56             : 
      57             : // <prerequisite>
      58             : //   <li> <linkto class="MeasurementComponents">MeasurementComponents</linkto> module
      59             : //   <li> <linkto class="VisSet">VisSet</linkto> module
      60             : //   <li> <linkto class="VisEquation">VisEquation</linkto> module
      61             : // </prerequisite>
      62             : //
      63             : // <etymology>
      64             : // VisCal describes an interface for multiplicative errors to be used in
      65             : // the <linkto class="VisEquation">VisEquation</linkto>. It is an Abstract Base Class: most methods
      66             : // must be defined in derived classes.
      67             : // </etymology>
      68             : //
      69             : // <synopsis> 
      70             : //
      71             : // See <linkto class="VisEquation">VisEquation</linkto> for definition of the
      72             : // Visibility Measurement Equation.
      73             : //
      74             : // The following examples illustrate how an VisCal can be
      75             : // used:
      76             : // <ul>
      77             : // <li> Simulation: random multiplicative gains of a certain scaling
      78             : // can be applied: <linkto class="SimVisCal">SimVisCal</linkto>
      79             : // <li> casacore::Time variable multiplicative errors: <linkto class="TimeVarVisCal">TimeVarVisCal</linkto>
      80             : // <li> Solvable time variable multiplicatiove errors: <linkto class="SolvableVisCal">SolvableVisCal</linkto>
      81             : // </ul>
      82             : // </synopsis> 
      83             : //
      84             : // <example>
      85             : // <srcblock>
      86             : //      // Read the VisSet from disk
      87             : //      VisSet vs("3c84.MS");
      88             : //
      89             : //      VisEquation ve(vs);
      90             : //
      91             : //      // Make an VisCal
      92             : //      PhaseScreenVisCal coac(vs);
      93             : //
      94             : //      // Correct the visset
      95             : //      ve.correct();
      96             : // </srcblock>
      97             : // </example>
      98             : //
      99             : // <motivation>
     100             : // The properties of an multiplicative component must be described
     101             : // for the <linkto class="VisEquation">VisEquation</linkto>.
     102             : // </motivation>
     103             : //
     104             : // <todo asof="97/10/01">
     105             : // </todo>
     106             : 
     107             : // **********************************************************
     108             : //  VisCal
     109             : //
     110             : 
     111             : class UVMod {
     112             : public:
     113             : 
     114             :   UVMod(VisSet& vs);
     115             :   
     116             :   virtual ~UVMod();
     117             : 
     118    39711498 :   inline casacore::Int& nPar() { return nPar_; };
     119             : 
     120             :   void setModel(const ComponentType::Shape type, 
     121             :                 const casacore::Vector<casacore::Double> inpar,
     122             :                 const casacore::Vector<casacore::Bool> invary);
     123             :   
     124             :   casacore::Bool modelfit(const casacore::Int& maxiter, const casacore::String file);
     125             : 
     126        2957 :   inline casacore::Vector<casacore::Double>& par()  { return par_; };
     127             : 
     128             : protected:
     129             : 
     130             :   // Initial solving data
     131             :   void initSolve();
     132             : 
     133             :   // Calculate residuals (incl. diff'd) and chi2 
     134             :   virtual void residual();
     135             :   void chiSquare();
     136             : 
     137             :   // Internal solving methods
     138             :   void accGradHess();
     139             :   void solveGradHess(const casacore::Bool& doCovar=false);
     140             :   casacore::Bool updPar();
     141             :   casacore::Bool setCompPar();
     142             :   void printPar(const casacore::Int& iter);
     143             : 
     144             :   // Access to VisSet
     145          24 :   inline VisSet& vs() { return *vs_; };
     146             : 
     147             :   // Access to ComponentList
     148          47 :   inline ComponentList& cl() { return *cl_; };
     149             : 
     150             :   // Access to SkyComponents by id
     151     2268341 :   inline SkyComponent& skycomp(const casacore::uInt id) { return cl_->component(id); };
     152             : 
     153             :   // Access to current VisBuffer
     154    12488148 :   inline VisBuffer& svb() { return *svb_; };
     155             : 
     156             :   // Access to fieldId we are fitting for
     157          48 :   inline casacore::Int& fitfld() { return fitfld_; };
     158          48 :   inline casacore::MDirection& pc() { return pc_; };
     159             : 
     160             :   // Accessors to current svb's (differentiated) Residuals
     161     6394980 :   inline casacore::Cube<casacore::DComplex>&    R()  { return R_; };
     162     5129049 :   inline casacore::Array<casacore::DComplex>&   dR() { return dR_; };
     163             : 
     164             :   // Access to chi2
     165     2996249 :   inline casacore::Double& chiSq()     { return chiSq_; };
     166         684 :   inline casacore::Double& lastChiSq() { return lastChiSq_; };
     167     2995785 :   inline casacore::Double& sumWt()     { return sumWt_; };
     168     2995613 :   inline casacore::Int&    nWt()       { return nWt_; };
     169     8990514 :   inline casacore::Vector<casacore::Bool>& polWt()  { return polWt_; };
     170             : 
     171             :   // Access to parameters, & grad,hess,dp
     172         756 :   inline casacore::Double&         lamb() { return lamb_; };
     173         192 :   inline casacore::Vector<casacore::Double>& lastPar()  { return lastPar_; };
     174     9648039 :   inline casacore::Vector<casacore::Double>& grad() { return grad_; };
     175         216 :   inline casacore::Vector<casacore::Double>& lastGrad() { return lastGrad_; };
     176    21648217 :   inline casacore::Matrix<casacore::Double>& hess() { return hess_; };
     177         216 :   inline casacore::Matrix<casacore::Double>& lastHess() { return lastHess_; };
     178         453 :   inline casacore::Vector<casacore::Double>& dpar() { return dpar_; };
     179    21940238 :   inline casacore::Vector<casacore::Bool>&   vary() { return vary_; };
     180         238 :   inline casacore::Int&            nVary() { return nVary_; };
     181             : 
     182             : 
     183             : private:
     184             :   
     185             :   // Associated VisSet (LOCAL)
     186             :   VisSet* vs_;
     187             : 
     188             :   // ComponentList  (LOCAL)
     189             :   ComponentList* cl_;
     190             : 
     191             :   // VisBuffer (from outside)
     192             :   VisBuffer* svb_;
     193             : 
     194             :   // FieldId in fit
     195             :   casacore::Int fitfld_;
     196             : 
     197             :   // Phase center w.r.t. which modelfitting is done
     198             :   casacore::MDirection pc_;
     199             : 
     200             :   // Total Number of parameters
     201             :   casacore::Int nPar_;
     202             : 
     203             :   // Residual/Differentiation caches
     204             :   casacore::Cube<casacore::DComplex>  R_;
     205             :   casacore::Array<casacore::DComplex> dR_;
     206             : 
     207             :   // Chi2, sum wts
     208             :   casacore::Double chiSq_;
     209             :   casacore::Double lastChiSq_;
     210             :   casacore::Double sumWt_;
     211             :   casacore::Int    nWt_;
     212             : 
     213             :   casacore::Vector<casacore::Bool> polWt_;
     214             : 
     215             :   // Parameter storage
     216             :   casacore::Vector<casacore::Double> par_;
     217             :   casacore::Vector<casacore::Double> lastPar_;
     218             : 
     219             :   // Gradient, Hessian, par update
     220             :   casacore::Double         lamb_;
     221             :   casacore::Vector<casacore::Double> grad_;
     222             :   casacore::Vector<casacore::Double> lastGrad_;
     223             :   casacore::Matrix<casacore::Double> hess_;
     224             :   casacore::Matrix<casacore::Double> lastHess_;
     225             :   casacore::Vector<casacore::Double> dpar_;
     226             :   casacore::Vector<casacore::Bool>   vary_;
     227             :   casacore::Int            nVary_;
     228             : 
     229             : };
     230             : 
     231             : }
     232             : #endif

Generated by: LCOV version 1.16