LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - FringeJones.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 23 29 79.3 %
Date: 2025-08-21 08:01:32 Functions: 22 28 78.6 %

          Line data    Source code
       1             : //# FringeJones.h: Declaration of fringe-fitting VisCal
       2             : //# Copyright (C) 1996,1997,2000,2001,2002,2003,2011,2016
       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             : 
      28             : #ifndef SYNTHESIS_FRINGEJONES_H
      29             : #define SYNTHESIS_FRINGEJONES_H
      30             : 
      31             : #include <casacore/casa/aips.h>
      32             : #include <synthesis/MeasurementComponents/StandardVisCal.h>
      33             : #include <synthesis/MeasurementComponents/DelayRateFFT.h>
      34             : #include <synthesis/CalTables/CTTimeInterp1.h>
      35             : #include <synthesis/CalTables/NewCalTable.h>
      36             : 
      37             : 
      38             : namespace casa { //# NAMESPACE CASA - BEGIN
      39             : 
      40             : // Rate-aware time interpolation engine
      41             : class CTRateAwareTimeInterp1 : public CTTimeInterp1 {
      42             : 
      43             : public:
      44             : 
      45             :   // From NewCalTable
      46             :   CTRateAwareTimeInterp1(NewCalTable& ct,
      47             :                          const casacore::String& timetype,
      48             :                          casacore::Array<casacore::Float>& result,
      49             :                          casacore::Array<casacore::Bool>& rflag);
      50             : 
      51             :   // Destructor
      52             :   virtual ~CTRateAwareTimeInterp1();
      53             : 
      54             :   // Interpolate, given timestamp; returns T if new result
      55             :   virtual casacore::Bool interpolate(casacore::Double time);
      56             : 
      57             :   // static factory method to make CTRateAwareTimeInterp1
      58             :   // NB: returns pointer to a _generic_ CTTimeInterp1
      59         276 :   static CTTimeInterp1* factory(NewCalTable& ct,
      60             :                                 const casacore::String& timetype,
      61             :                                 casacore::Array<casacore::Float>& result,
      62             :                                 casacore::Array<casacore::Bool>& rflag) {
      63         276 :     return new casa::CTRateAwareTimeInterp1(ct,timetype,result,rflag); }
      64             : 
      65             : private:
      66             : 
      67             :   // Refine time-dep phase with rate info
      68             :   void applyPhaseRate(casacore::Bool single);
      69             : 
      70             :   // Default ctor is unusable
      71             :   //  CTRateAwareTimeInterp1(); 
      72             : 
      73             : };
      74             : 
      75             : 
      76             : // Fringe-fitting (parametrized phase) VisCal
      77             : class FringeJones : public GJones {
      78             : public:
      79             :   // Constructor
      80             :   //  TBD:  MSMetaInfoForCal-aware version; deprecate older ones
      81             :   FringeJones(VisSet& vs);
      82             :   FringeJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
      83             :   FringeJones(const MSMetaInfoForCal& msmc);
      84             :   FringeJones(casacore::Int nAnt);
      85             : 
      86             :   virtual ~FringeJones();
      87             : 
      88             :   // We have casacore::Float parameters
      89        6616 :   virtual VisCalEnum::VCParType parType() { return VisCalEnum::REAL; };
      90             : 
      91             :   // Return the type enum
      92      556543 :   virtual Type type() { return VisCal::K; };
      93             : 
      94             :   // Return type name as string
      95         251 :   virtual casacore::String typeName()     { return "Fringe Jones"; };
      96          64 :   virtual casacore::String longTypeName() { return "Fringe Jones (parametrized phase)"; };
      97             : 
      98             :   // Type of Jones matrix according to nPar()
      99       41591 :   virtual Jones::JonesType jonesType() { return Jones::Diagonal; };
     100             : 
     101        4680 :   virtual bool timeDepMat() { return true; };
     102             : 
     103             :   // Freq dependence (delays)
     104       38289 :   virtual casacore::Bool freqDepPar() { return false; };
     105             :   // If the following is false frequency spectrum is squashed to one point.
     106     1000479 :   virtual casacore::Bool freqDepMat() { return true; };
     107             : 
     108             :   // Local setApply to enforce calWt=F for delays
     109             :   virtual void setApply(const casacore::Record& apply);
     110             :   virtual void setApply();
     111             :   using GJones::setApply;
     112             :   virtual void setCallib(const casacore::Record& callib,
     113             :                          const casacore::MeasurementSet& selms);
     114             : 
     115             :   // Local setSolve (traps lack of refant)
     116             :   virtual void setSolve(const casacore::Record& solve);
     117             :   using GJones::setSolve;
     118             : 
     119             :   // Default parameter value
     120           0 :   virtual casacore::Complex defaultPar() { return casacore::Complex(0.0); };
     121             :   
     122             :   // FIXME: was omitted
     123             :   virtual void specify(const casacore::Record& specify);
     124             :   
     125             :   // This type is not yet accumulatable
     126           0 :   virtual casacore::Bool accumulatable() { return false; };
     127             : 
     128             :   // This type is smoothable
     129           0 :   virtual casacore::Bool smoothable() { return true; };
     130             : 
     131             :   // Delay to phase calculator
     132             :   virtual void calcAllJones();
     133             : 
     134             :   // Hazard a guess at parameters (unneeded here)
     135             :   //  TBD?  Needed?
     136           0 :   virtual void guessPar(VisBuffer& ) {};
     137             : 
     138             :   // FringeJones uses generic gather, but solves for itself per solution
     139          32 :   virtual casacore::Bool useGenericGatherForSolve() { return true; };
     140         225 :   virtual casacore::Bool useGenericSolveOne() { return false; }
     141             : 
     142             :   // Post solve tinkering
     143             :   virtual void globalPostSolveTinker();
     144             : 
     145             :   // Local implementation of selfSolveOne (generalized signature)
     146             :   // virtual void selfSolveOne(VisBuffGroupAcc& vbga);
     147             :   virtual void selfSolveOne(SDBList&);
     148             : 
     149             :   virtual void solveOneVB(const VisBuffer&);
     150             : 
     151             :   // SolveDataBuffer is being phased out; we no longer support it.
     152             :   // virtual void solveOneSDB(const SolveDataBuffer&);
     153             : 
     154        2520 :   virtual casacore::Bool& zeroRates() { return zeroRates_; }
     155         257 :   virtual casacore::Bool& globalSolve() { return globalSolve_; } 
     156         257 :   virtual casacore::Int& maxits() { return maxits_; }
     157         257 :   virtual casacore::Array<casacore::Double>& delayWindow() { return delayWindow_; }
     158         257 :   virtual casacore::Array<casacore::Double>& rateWindow() { return rateWindow_; }
     159         257 :   virtual casacore::Array<casacore::Bool>& paramActive() { return paramActive_; }
     160         257 :   virtual casacore::Bool& concatSPWs() { return concatspws_; }
     161             :   
     162             :   virtual void smooth(casacore::Vector<casacore::Int>& fields,
     163             :                       const casacore::String& smtype,
     164             :                       const casacore::Double& smtime,
     165             :                       const bool ratesmooth);
     166             :   
     167             :   // Apply reference antenna
     168             :   virtual void applyRefAnt();
     169             : 
     170        8470 :   virtual casacore::Int& refant() { return refant_; }
     171             :   
     172             : protected:
     173             : 
     174             :   // phase, delay, rate
     175             :   //  TBD:  Need to cater for parameter opt-out  (e.g., no rate solve, etc.)
     176     9145793 :   virtual casacore::Int nPar() { return 8; };
     177             : 
     178             :   // Jones matrix elements are NOT trivial
     179        4680 :   virtual casacore::Bool trivialJonesElem() { return false; };
     180             : 
     181             :   // dJ/dp are trivial
     182             :   //  TBD: make this default in SVC?
     183           0 :   virtual casacore::Bool trivialDJ() { return false; };
     184             : 
     185             :   // Initialize trivial dJs
     186             :   //  TBD: make this default in SVC?
     187           0 :   virtual void initTrivDJ() {};
     188             : 
     189             :   // Reference frequencies
     190             :   casacore::Vector<casacore::Double> KrefFreqs_;
     191             : 
     192             :   
     193             :   
     194             : private:
     195             : 
     196             :   // Pointer to CTRateAwareTimeInterp1 factory method
     197             :   // This ensures the rates are incorporated into the time-dep interpolation
     198           7 :   virtual CTTIFactoryPtr cttifactoryptr() { return &CTRateAwareTimeInterp1::factory; };
     199             :   void calculateSNR(casacore::Int, casa::DelayRateFFT&);
     200             : 
     201             :   casacore::Int refant_; // Override
     202             :   casacore::Bool zeroRates_;
     203             :   casacore::Bool globalSolve_;
     204             :   casacore::Array<casacore::Double> delayWindow_;
     205             :   casacore::Array<casacore::Double> rateWindow_;
     206             :   casacore::Array<casacore::Bool> paramActive_;
     207             :   casacore::Int maxits_;
     208             :   casacore::Bool concatspws_;
     209             : };
     210             : 
     211             : void smoothCTFringe(NewCalTable ct,
     212             :                     const casacore::String& smtype,
     213             :                     const casacore::Double& smtime,
     214             :                     casacore::Vector<casacore::Int> selfields);
     215             : 
     216             : } //# NAMESPACE CASA - END
     217             : 
     218             : #endif

Generated by: LCOV version 1.16