LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - GSpline.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 3 6 50.0 %
Date: 2024-12-11 20:54:31 Functions: 3 6 50.0 %

          Line data    Source code
       1             : //# GJonesPoly.h: Electronic gain Jones matrix as polynomials over time
       2             : //# Copyright (C) 1996,1997,1998,1999,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: 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             : //#
      27             : //# $Id: GJonesPoly.h,v 19.7 2004/11/30 17:50:48 ddebonis Exp $
      28             : 
      29             : #ifndef SYNTHESIS_GSPLINE_H
      30             : #define SYNTHESIS_GSPLINE_H
      31             : 
      32             : #include <synthesis/MeasurementComponents/SolvableVisCal.h>
      33             : #include <synthesis/MeasurementComponents/StandardVisCal.h>
      34             : #include <synthesis/CalTables/GJonesMBuf.h>
      35             : 
      36             : namespace casa { //# NAMESPACE CASA - BEGIN
      37             : 
      38             : // <summary> Electronic gain Jones matrix as spline polynomial over time
      39             : // </summary>
      40             : 
      41             : // <use visibility=export>
      42             : 
      43             : // <reviewed reviewer="" date="" tests="" demos="">
      44             : 
      45             : // <prerequisite>
      46             : //   <li> <linkto module="GJones">GJones</linkto> module
      47             : //   <li> <linkto module="GJonesPoly">GJonesPoly</linkto> module
      48             : // </prerequisite>
      49             : //
      50             : // <etymology>
      51             : // GJonesSpline describes the electronic gain visibility Jones matrix 
      52             : // parametrized as a spline polynomial over time.
      53             : // </etymology>
      54             : //
      55             : // <synopsis> 
      56             : //
      57             : // See <linkto class="VisEquation">VisEquation</linkto> for definition of the
      58             : // Visibility Measurement Equation.
      59             : //
      60             : // The elements of GJonesSpline are only non-zero on the diagonal.
      61             : //
      62             : // </synopsis> 
      63             : //
      64             : // <motivation>
      65             : // Support electronic gain calibration using splines polynomials over time.
      66             : // </motivation>
      67             : //
      68             : // <todo asof="02/02/01">
      69             : // i) Support solution and pre-averaging intervals
      70             : // </todo>
      71             : 
      72             : class VisEquation;
      73             : 
      74             : class GJonesSpline : public GJones {
      75             : public:
      76             : 
      77             :   // Construct from a visibility data set
      78             :   GJonesSpline (VisSet& vs);
      79             : 
      80             :   // Construct from a MSMetaInfoForCal
      81             :   GJonesSpline (const MSMetaInfoForCal& msmc);
      82             : 
      83             :   // Destructor
      84             :   virtual ~GJonesSpline();
      85             : 
      86             :   // Return the type enum
      87           0 :   virtual Type type() { return VisCal::G; };
      88             : 
      89             :   // Return type name as a string
      90           3 :   virtual casacore::String typeName()     { return "GSPLINE"; };
      91           0 :   virtual casacore::String longTypeName() { return "G Jones SPLINE (elec. gain)"; };
      92             : 
      93             : 
      94             :   // GSpline gathers/solves for itself
      95           1 :   virtual casacore::Bool useGenericGatherForSolve() { return false; };
      96             : 
      97             :   // Type of Jones matrix according to nPar()
      98             :   // TBD:
      99        3829 :   virtual Jones::JonesType jonesType() { return Jones::Diagonal; };
     100             : 
     101             :   // Set the solver parameters
     102             :   using GJones::setSolve;
     103             :   virtual void setSolve(const casacore::Record& solvepar);
     104             : 
     105             :   // Set the interpolation parameters
     106             :   using GJones::setApply;
     107             :   virtual void setApply(const casacore::Record& applypar);
     108             : 
     109             :   // Solve
     110             :   virtual void selfGatherAndSolve (VisSet& vs, VisEquation& ve);
     111             : 
     112             : /*
     113             :   // Set raw phase transfer from another spw
     114             :   void setRawPhaseVisSet(VisSet& rawvs_p);
     115             : 
     116             :   // Set parameters for phase wrapping resolution
     117             :   void setPhaseWrapHelp(const casacore::Int& numpoi, const casacore::Double& phaseWrap);
     118             : */
     119             :   // Expose calculating pars for plotting
     120             :   inline void doCalcPar() { calcPar(); }
     121             : 
     122             :  protected:
     123             : 
     124             :   // GSPLINE has one trivial casacore::Complex parameter (single pol, for now)
     125             :   // TBD:
     126           0 :   virtual casacore::Int nPar() { return 2; };
     127             : 
     128             :   // Calc G pars from spline info
     129             :   virtual void calcPar();
     130             : 
     131             :  private:
     132             : 
     133             :   // The underlying VisSet
     134             :   VisSet* vs_p;
     135             : 
     136             :   // Private variables containing the solver parameters
     137             :   casacore::Bool solveAmp_p, solvePhase_p;
     138             :   casacore::Double splinetime_p;
     139             : 
     140             :   // casacore::Time for which the current calibration cache is valid
     141             :   //casacore::Double cacheTimeValid_p;
     142             : 
     143             :   // Ptr to a calibration buffer associated with the calibration
     144             :   // solutions which are to be interpolated and applied to the data
     145             :   GJonesSplineMBuf* calBuffer_p;
     146             : 
     147             : 
     148             :   // Parameters for raw phase removal from another spw
     149             :   //VisSet* rawvs_p;
     150             :   //casacore::Bool rawPhaseRemoval_p;
     151             :   std::map<casacore::String, casacore::Int> timeValueMap_p;
     152             :   casacore::Matrix<casacore::Double> rawPhase_p;
     153             : 
     154             :   // Solution timestamp
     155             :   casacore::Double solTimeStamp_p;
     156             : 
     157             : 
     158             :   // Create and fill an empty output calibration buffer
     159             :   void newCalBuffer (const casacore::Vector<casacore::Int>& fieldIdKeys, 
     160             :                      const casacore::Vector<casacore::Int>& antennaId);
     161             : 
     162             :   // Compute the number of spline knots required and their location
     163             :   casacore::Int getKnots (const casacore::Vector<casacore::Double>& times, casacore::Vector<casacore::Double>& knots);
     164             : 
     165             :   // Update the output calibration table
     166             :   virtual void updateCalTable (const casacore::Vector<casacore::Int>& fieldIdKeys,
     167             :                                const casacore::Vector<casacore::Int>& antennaId,
     168             :                                const casacore::Vector<casacore::String>& freqGrpName,
     169             :                                const casacore::Vector<casacore::String>& polyType,
     170             :                                const casacore::Vector<casacore::String>& polyMode,
     171             :                                const casacore::Vector<casacore::Complex>& scaleFactor,
     172             :                                const casacore::Matrix<casacore::Double>& polyCoeffAmp,
     173             :                                const casacore::Matrix<casacore::Double>& polyCoeffPhase,
     174             :                                const casacore::Vector<casacore::String>& phaseUnits,
     175             :                                const casacore::Vector<casacore::Double>& splineKnotsAmp,
     176             :                                const casacore::Vector<casacore::Double>& splineKnotsPhase,
     177             :                                const casacore::Vector<casacore::MFrequency>& refFreq,
     178             :                                const casacore::Vector<casacore::Int>& refAnt);
     179             :   
     180             :   // Compute a spline polynomial value
     181             :   casacore::Double getSplineVal (casacore::Double x, casacore::Vector<casacore::Double>& knots,
     182             :                        casacore::Vector<casacore::Double>& coeff);
     183             : 
     184             : 
     185             : /*
     186             :   // fill the raw phase buffer for usage
     187             :   void fillRawPhaseBuff();
     188             : 
     189             :   // return the rawphase of 
     190             :   casacore::Double getRawPhase(casacore::Int ant1, casacore::Int ant2, casacore::Double time);
     191             : 
     192             : */
     193             : 
     194             :   //Plot solutions as compare with data
     195             :   void plotsolve(const casacore::Vector<casacore::Double>& x, 
     196             :                  const casacore::Matrix<casacore::Double>& yall, 
     197             :                  const casacore::Matrix<casacore::Double>& weightall, 
     198             :                  const casacore::Vector<casacore::Double>& errall, 
     199             :                  casacore::Matrix<casacore::Double>& coeff, casacore::Bool phasesoln);
     200             : 
     201             :   // Return all field id.'s in the underlying MS
     202             :   casacore::Vector<casacore::Int> fieldIdRange();
     203             : 
     204             :   //Logging solution and rms
     205             :   void writeAsciiLog(const casacore::String& filename, const casacore::Matrix<casacore::Double>& coeff, const casacore::Vector<casacore::Double>& rmsFit, casacore::Bool phasesoln);
     206             : 
     207             :   casacore::Int numpoint_p;
     208             :   casacore::Double phaseWrap_p;
     209             : 
     210             : 
     211             : };
     212             : 
     213             : 
     214             : } //# NAMESPACE CASA - END
     215             : 
     216             : #endif
     217             : 
     218             : 

Generated by: LCOV version 1.16