LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - KJones.h (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 0 36 0.0 %
Date: 2023-11-02 14:27:30 Functions: 0 36 0.0 %

          Line data    Source code
       1             : //# KJones.h: Declaration of delay-like (geometry) calibration types
       2             : //# Copyright (C) 1996,1997,2000,2001,2002,2003,2011
       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_KJONES_H
      29             : #define SYNTHESIS_KJONES_H
      30             : 
      31             : #include <casacore/casa/aips.h>
      32             : #include <synthesis/MeasurementComponents/StandardVisCal.h>
      33             : 
      34             : namespace casa { //# NAMESPACE CASA - BEGIN
      35             : 
      36             : class DelayFFT {
      37             : public:
      38             :   // Construct from freq info and data-like casacore::Cube<casacore::Complex>
      39             :   //  (for generic testing w/out casacore::MS data)
      40             :   DelayFFT(casacore::Double f0, casacore::Double df, casacore::Double padBW, 
      41             :            casacore::Cube<casacore::Complex> V, 
      42             :            casacore::Cube<casacore::Float> wt=casacore::Cube<casacore::Float>());
      43             : 
      44             :   // Construct from freq info and shape, w/ initialization
      45             :   //   (for accumulation)
      46             :   DelayFFT(casacore::Double f0, casacore::Double df, casacore::Double padBW, 
      47             :            casacore::Int nCorr, casacore::Int nElem, casacore::Int refant, 
      48             :            casacore::Complex v0, casacore::Float wt=1.0);
      49             : 
      50             :   // Construct from a VB
      51             :   DelayFFT(const VisBuffer& vb,casacore::Double padBW,casacore::Int refant);
      52             : 
      53             :   // Construct from a VB2
      54             :   DelayFFT(SolveDataBuffer& sdb,casacore::Double padBW,casacore::Int refant,casacore::Int nElem);
      55             : 
      56             :   // Perform FFT
      57             :   void FFT();
      58             : 
      59             :   // Apply shift theorem
      60             :   void shift(casacore::Double f);
      61             : 
      62             :   // Accumulate another DelayFFT
      63             :   void add(const DelayFFT& other);
      64             : 
      65             :   // Accumulate another DelayFFT, with duplication (if nec) and shift
      66             :   void addWithDupAndShift(const DelayFFT& other);
      67             : 
      68             :   // Find peaks
      69             :   void searchPeak();
      70             : 
      71             :   const casacore::Cube<casacore::Complex>& Vpad() const { return Vpad_; };
      72             : 
      73             :   // Access to results
      74           0 :   const casacore::Matrix<casacore::Float>& delay() const { return delay_; };
      75           0 :   const casacore::Matrix<casacore::Bool>& flag() const { return flag_; };
      76             : 
      77             :   // Report some stateinfo
      78             :   void state();
      79             : 
      80             : protected:
      81             :   casacore::Double f0_, df_, padBW_;
      82             :   casacore::Int nCorr_, nPadChan_, nElem_;
      83             :   casacore::Int refant_;
      84             :   casacore::Cube<casacore::Complex> Vpad_;
      85             :   casacore::Matrix<casacore::Float> delay_;
      86             :   casacore::Matrix<casacore::Bool> flag_;
      87             : 
      88             : };
      89             : 
      90             : 
      91             :  class CrossDelayFFT : public DelayFFT {
      92             : public:
      93             :   // Construct from freq info and data-like casacore::Cube<casacore::Complex>
      94             :   //  (for generic testing w/out casacore::MS data)
      95             :   CrossDelayFFT(casacore::Double f0, casacore::Double df, casacore::Double padBW, 
      96             :            casacore::Cube<casacore::Complex> V);
      97             : 
      98             :   // Construct from freq info and shape, w/ initialization
      99             :   //   (for accumulation)
     100             :   CrossDelayFFT(casacore::Double f0, casacore::Double df, casacore::Double padBW);
     101             : 
     102             :   // Construct from a SDB (VB2)
     103             :   CrossDelayFFT(SolveDataBuffer& sdb,casacore::Double padBW);
     104             : 
     105             :   // Report some stateinfo
     106             :   void state();
     107             : 
     108             : };
     109             : 
     110             : 
     111             : 
     112             : 
     113             : 
     114             : 
     115             : // Forward declarations
     116             : 
     117             : 
     118             : // K Jones provides support for SBD delays
     119             : class KJones : public GJones {
     120             : 
     121             : 
     122             : public:
     123             : 
     124             :   //  friend class KJonesTest;
     125             : 
     126             :   // Constructor
     127             :   KJones(VisSet& vs);
     128             :   KJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     129             :   KJones(const MSMetaInfoForCal& msmc);
     130             :   KJones(const casacore::Int& nAnt);
     131             : 
     132             :   virtual ~KJones();
     133             : 
     134             :   // Local setApply to enforce calWt=F for delays
     135             :   virtual void setApply(const casacore::Record& apply);
     136             :   virtual void setApply();
     137             :   using GJones::setApply;
     138             :   virtual void setCallib(const casacore::Record& callib,
     139             :                          const casacore::MeasurementSet& selms);
     140             : 
     141             :   // Local setSolve (traps lack of refant)
     142             :   virtual void setSolve(const casacore::Record& solve);
     143             :   using GJones::setSolve;
     144             : 
     145             :   // We have casacore::Float parameters
     146           0 :   virtual VisCalEnum::VCParType parType() { return VisCalEnum::REAL; };
     147             : 
     148             :   // Return the type enum
     149           0 :   virtual Type type() { return VisCal::K; };
     150             : 
     151             :   // Return type name as string
     152           0 :   virtual casacore::String typeName()     { return "K Jones"; };
     153           0 :   virtual casacore::String longTypeName() { return "K Jones (delay)"; };
     154             : 
     155             :   // Type of Jones matrix according to nPar()
     156           0 :   virtual Jones::JonesType jonesType() { return Jones::Diagonal; };
     157             : 
     158             :   // Freq dependence (delays)
     159           0 :   virtual casacore::Bool freqDepPar() { return false; };
     160           0 :   virtual casacore::Bool freqDepMat() { return true; };
     161             : 
     162             :   // Default parameter value
     163           0 :   virtual casacore::Complex defaultPar() { return casacore::Complex(0.0); };
     164             : 
     165             :   // Type-specific specify
     166             :   virtual void specify(const casacore::Record& specify);
     167             : 
     168             :   // This type is not yet accumulatable
     169           0 :   virtual casacore::Bool accumulatable() { return false; };
     170             : 
     171             :   // This type is smoothable
     172           0 :   virtual casacore::Bool smoothable() { return true; };
     173             : 
     174             :   // Calculate phase(chan) from delay
     175             :   virtual void calcAllJones();
     176             : 
     177             :   // Delay to phase calculator
     178             :   //  virtual void calcOneJones(casacore::Vector<casacore::Complex>& mat, casacore::Vector<casacore::Bool>& mOk, 
     179             :   //                            const casacore::Vector<casacore::Complex>& par, const casacore::Vector<casacore::Bool>& pOk );
     180             : 
     181             : 
     182             :   // Hazard a guess at parameters (unneeded here)
     183           0 :   virtual void guessPar(VisBuffer& ) {};
     184             : 
     185             :   // K now uses generic gather, but solves for itself per solution
     186           0 :   virtual casacore::Bool useGenericGatherForSolve() { return true; };
     187           0 :   virtual casacore::Bool useGenericSolveOne() { return false; }
     188             : 
     189             :   // Override G here; nothing to do for K, for now
     190           0 :   virtual void globalPostSolveTinker() {};
     191             : 
     192             :   // Local implementation of selfSolveOne (generalized signature)
     193             :   virtual void selfSolveOne(VisBuffGroupAcc& vbga);
     194             :   virtual void selfSolveOne(SDBList& sdbs);
     195             : 
     196             : protected:
     197             : 
     198             :   // K has two "real" parameters
     199           0 :   virtual casacore::Int nPar() { return 2; };
     200             : 
     201             :   // Jones matrix elements are trivial
     202           0 :   virtual casacore::Bool trivialJonesElem() { return false; };
     203             : 
     204             :   // dG/dp are trivial
     205           0 :   virtual casacore::Bool trivialDJ() { return false; };
     206             : 
     207             :   // Initialize trivial dJs
     208           0 :   virtual void initTrivDJ() {};
     209             : 
     210             :   // FFT solver for one VB
     211             :   virtual void solveOneVB(const VisBuffer& vb);
     212             :   virtual void solveOneSDB(SolveDataBuffer& sdb);
     213             : 
     214             :   // FFT solver for multi-VB (MBD)
     215             :   virtual void solveOneVBmbd(VisBuffGroupAcc& vbga);
     216             :   virtual void solveOneSDBmbd(SDBList& sdbs);
     217             : 
     218             :   // Reference frequencies
     219             :   casacore::Vector<casacore::Double> KrefFreqs_;
     220             : 
     221             : private:
     222             : 
     223             :   
     224             : };
     225             : 
     226             : // (sbd) K for cross-hand solve
     227             : class KcrossJones : public KJones {
     228             : public:
     229             : 
     230             :   // Constructor
     231             :   KcrossJones(VisSet& vs);
     232             :   KcrossJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     233             :   KcrossJones(const MSMetaInfoForCal& msmc);
     234             :   KcrossJones(const casacore::Int& nAnt);
     235             : 
     236             : 
     237             :   virtual ~KcrossJones();
     238             : 
     239             :   // Return type name as string
     240           0 :   virtual casacore::String typeName()     { return "Kcross Jones"; };
     241           0 :   virtual casacore::String longTypeName() { return "Kcross Jones (cross-hand delay)"; };
     242             : 
     243             :   // By definition, we consider cross-hands
     244           0 :   virtual casacore::Bool phandonly() { return false; };
     245             : 
     246             :   // Local implementation of selfSolveOne 
     247             :   //   This traps combine='spw', which isn't supported yet
     248             :   virtual void selfSolveOne(VisBuffGroupAcc& vbga);
     249             :   virtual void selfSolveOne(SDBList& sdbs);
     250             : 
     251             : 
     252             : 
     253             : protected:
     254             : 
     255             : 
     256             :   // FFT solver for on VB, that collapses baselines and cross-hands first
     257             :   virtual void solveOneVB(const VisBuffer& vb);
     258             :   virtual void solveOneSDB(SolveDataBuffer& sdb);
     259             : 
     260             :   // MBD support
     261             :   void solveOneSDBmbd(SDBList& sdbs);
     262             : 
     263             : };
     264             : 
     265             : 
     266             : // KMBD Jones provides support for multi-band delays
     267             : class KMBDJones : public KJones {
     268             : public:
     269             : 
     270             :   // Constructor
     271             :   KMBDJones(VisSet& vs);
     272             :   KMBDJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     273             :   KMBDJones(const MSMetaInfoForCal& msmc);
     274             :   KMBDJones(const casacore::Int& nAnt);
     275             : 
     276             :   virtual ~KMBDJones();
     277             : 
     278             :   // Return the type enum
     279           0 :   virtual Type type() { return VisCal::K; };
     280             : 
     281             :   // Return type name as string
     282           0 :   virtual casacore::String typeName()     { return "KMBD Jones"; };
     283           0 :   virtual casacore::String longTypeName() { return "KMBD Jones (multi-band delay)"; };
     284             : 
     285             :   // Local setApply (to enforce KrefFreq_=0.0)
     286             :   virtual void setApply(const casacore::Record& apply);
     287             :   using KJones::setApply;
     288             : 
     289             :  
     290             : };
     291             : 
     292             : 
     293             : 
     294             : class KAntPosJones : public KJones {
     295             : public:
     296             : 
     297             :   // Constructor
     298             :   KAntPosJones(VisSet& vs);
     299             :   KAntPosJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     300             :   KAntPosJones(const MSMetaInfoForCal& msmc);
     301             :   KAntPosJones(const casacore::Int& nAnt);
     302             : 
     303             : 
     304             :   virtual ~KAntPosJones();
     305             : 
     306             :   // Return the type enum
     307           0 :   virtual Type type() { return VisCal::KAntPos; };
     308             : 
     309             :   // Return type name as string
     310           0 :   virtual casacore::String typeName()     { return "KAntPos Jones"; };
     311           0 :   virtual casacore::String longTypeName() { return "KAntPos Jones (antenna position errors)"; };
     312             : 
     313             :   // This is a scalar Jones matrix
     314           0 :   virtual Jones::JonesType jonesType() { return Jones::Scalar; };
     315             : 
     316           0 :   virtual casacore::Bool timeDepMat() { return true; };
     317             : 
     318             :   // This type is not smoothable
     319           0 :   virtual casacore::Bool smoothable() { return false; };
     320             : 
     321             :   // Local setApply to enforce spwmap=0 for all spw
     322             :   virtual void setApply(const casacore::Record& apply);
     323             :   using KJones::setApply;
     324             :   virtual void setCallib(const casacore::Record& callib,const casacore::MeasurementSet& selms);
     325             : 
     326             :   // Type-specific specify
     327             :   virtual void specify(const casacore::Record& specify);
     328             : 
     329             :   // Calculate phase(chan) from delay
     330             :   virtual void calcAllJones();
     331             : 
     332             : protected:
     333             : 
     334             :   // Detect phase direction and antpos for the current VB
     335             :   virtual void syncMeta(const VisBuffer& vb);
     336             :   virtual void syncMeta2(const vi::VisBuffer2& vb);
     337             : 
     338             :   // AntPos has three "real" parameters (dBx, dBy, dBz)
     339           0 :   virtual casacore::Int nPar() { return 3; };
     340             : 
     341             :   // Jones matrix elements are not trivial
     342           0 :   virtual casacore::Bool trivialJonesElem() { return false; };
     343             : 
     344             :   // dG/dp are not trivial
     345           0 :   virtual casacore::Bool trivialDJ() { return false; };
     346             : 
     347             :   // Initialize trivial dJs
     348           0 :   virtual void initTrivDJ() {};
     349             : 
     350             : private:
     351             :   
     352             :   // casacore::Geometry info for internal calculations (updated per VB)
     353             :   casacore::String epochref_p;
     354             :   casacore::MDirection phasedir_p;
     355             :   casacore::MPosition antpos0_p;
     356             : 
     357             :   // utility methods/variables for Trop Delay Error correction
     358             :   bool vlaTrDelCorrApplicable(bool checkCalTable=false);
     359             :   void markCalTableForTrDelCorr();
     360             :   void initTrDelCorr();                        // init (at set apply)
     361             :   double calcTrDelError(int iant);              // calc (per ant,timestamp)
     362             :   bool doTrDelCorr_;                            // on or off
     363             :   double userEterm_;
     364             :   casacore::Vector<double> MJDlim_;             // applicable date ranges
     365             :   #define MJD0 String("2016/08/09/00:00:00.0")
     366             :   #define MJD1 String("2016/11/15/00:00:00.0") 
     367             :   double eterm_;                                // scale
     368             :   casacore::Vector<double> losDist_, armAz_;    // geo info
     369             :   casacore::Vector<casacore::MDirection> azel_;
     370             : 
     371             : };
     372             : 
     373             : 
     374             : } //# NAMESPACE CASA - END
     375             : 
     376             : #endif

Generated by: LCOV version 1.16