LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - DJones.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 28 0.0 %
Date: 2024-10-10 15:00:01 Functions: 0 28 0.0 %

          Line data    Source code
       1             : //# DJones.h: Declaration of standard Polarization 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: 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_DJONES_H
      29             : #define SYNTHESIS_DJONES_H
      30             : 
      31             : #include <casacore/casa/aips.h>
      32             : #include <casacore/casa/Containers/Record.h>
      33             : #include <casacore/casa/BasicSL/Complex.h>
      34             : #include <synthesis/MeasurementComponents/VisCal.h>
      35             : #include <synthesis/MeasurementComponents/SolvableVisCal.h>
      36             : #include <synthesis/MeasurementComponents/StandardVisCal.h>
      37             : #include <synthesis/MeasurementComponents/SolveDataBuffer.h>
      38             : #include <synthesis/MeasurementComponents/CalCorruptor.h>
      39             : 
      40             : namespace casa { //# NAMESPACE CASA - BEGIN
      41             : 
      42             : // Forward declarations
      43             : class VisEquation;
      44             : 
      45             : // **********************************************************
      46             : //  DJones
      47             : //
      48             : 
      49             : class DJones : public SolvableVisJones {
      50             : public:
      51             : 
      52             :   // Constructor
      53             :   DJones(VisSet& vs);
      54             :   DJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
      55             :   DJones(const MSMetaInfoForCal& msmc);
      56             :   DJones(const casacore::Int& nAnt);
      57             : 
      58             :   virtual ~DJones();
      59             : 
      60             :   // Local setapply
      61             :   using SolvableVisJones::setApply;
      62             :   virtual void setApply(const casacore::Record& apply);
      63             : 
      64             :   // D-specific solve setup
      65             :   using SolvableVisJones::setSolve;
      66             :   void setSolve(const casacore::Record& solvepar);
      67             : 
      68             :   // Return the type enum
      69           0 :   virtual Type type() { return VisCal::D; };
      70             : 
      71             :   // Return type name as string
      72           0 :   virtual casacore::String typeName()     { return "Dgen Jones"; };
      73           0 :   virtual casacore::String longTypeName() { return "Dgen Jones (instrumental polarization"; };
      74             : 
      75             :   // Type of Jones matrix according to nPar()
      76             :   //   Do GENERAL matrix algebra
      77           0 :   virtual Jones::JonesType jonesType() { return Jones::General; };
      78             : 
      79             :   // We can solve for polarization with D
      80           0 :   virtual casacore::Int solvePol() { return solvePol_; };
      81             : 
      82             :   // Specialization that conditions raw data & model for OTF pol solving
      83             :   virtual void setUpForPolSolve(vi::VisBuffer2& vb);
      84             : 
      85             :   // Hazard a guess at parameters
      86             :   virtual void guessPar(VisBuffer& vb);
      87             :   virtual void guessPar(SDBList& sdbs);
      88             :   virtual void guessPar(SDBList&,const casacore::Bool&);  // VI2
      89             : 
      90             :   // Update the parameters from solving
      91             :   //  (in linear approx, we always set the source update to zero, for now!)
      92             :   virtual void updatePar(const casacore::Vector<casacore::Complex> dCalPar,
      93             :                          const casacore::Vector<casacore::Complex> dSrcPar);
      94             : 
      95             :   // SNR is 1/err for D-terms (?)
      96             :   virtual void formSolveSNR();
      97             : 
      98             :   // D-specific post-solve stuff
      99             :   virtual void globalPostSolveTinker();
     100             : 
     101             :   // D-specific reReference
     102             :   // TBD: non-triv impl
     103           0 :   virtual void reReference() { cout << "reReference!" << endl;};
     104             : 
     105             :   virtual void applyRefAnt();
     106             : 
     107             :   // Method to list the D results
     108             :   virtual void logResults();
     109             : 
     110             :   virtual void createCorruptor(const VisIter& vi, 
     111             :                                const casacore::Record& simpar, 
     112             :                                const casacore::Int nSim);
     113             : protected:
     114             : 
     115             :   // D has two casacore::Complex parameters
     116           0 :   virtual casacore::Int nPar() { return 2; };
     117             : 
     118             :   // Jones matrix elements are trivial?
     119             :   //  true if GenLinear, false if General
     120           0 :   virtual casacore::Bool trivialJonesElem() { return (jonesType()==Jones::GenLinear); };  
     121             :   // dD/dp are trivial
     122           0 :   virtual casacore::Bool trivialDJ() { return true; };
     123             : 
     124             :   // Non-trivial Jones matrix calculation
     125             :   virtual void calcOneJones(casacore::Vector<casacore::Complex>& mat, casacore::Vector<casacore::Bool>& mOk,
     126             :                             const casacore::Vector<casacore::Complex>& par, const casacore::Vector<casacore::Bool>& pOk);
     127             : 
     128             :   // Initialize trivial dJs
     129             :   virtual void initTrivDJ();
     130             : 
     131             : private:
     132             : 
     133             :   casacore::Int solvePol_;
     134             :   DJonesCorruptor *dcorruptor_p;
     135             :   
     136             : 
     137             :   
     138             : };
     139             : 
     140             : // **********************************************************
     141             : //  DfJones (freq-dep D)  (general)
     142             : //
     143             : 
     144             : class DfJones : public DJones {
     145             : public:
     146             : 
     147             :   // Constructor
     148             :   DfJones(VisSet& vs);
     149             :   DfJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     150             :   DfJones(const MSMetaInfoForCal& msmc);
     151             :   DfJones(const casacore::Int& nAnt);
     152             : 
     153             :   virtual ~DfJones();
     154             : 
     155             :   // Return type name as string
     156           0 :   virtual casacore::String typeName()     { return "Dfgen Jones"; };
     157           0 :   virtual casacore::String longTypeName() { return "Dfgen Jones (frequency-dependent instrumental polarization"; };
     158             : 
     159             :   // This is the freq-dep version of D 
     160             :   //   (this is the ONLY fundamental difference from D)
     161           0 :   virtual casacore::Bool freqDepPar() { return true; };
     162             :   
     163             : };
     164             : 
     165             : 
     166             : 
     167             : // **********************************************************
     168             : //  DlinJones   (linearized DJones)
     169             : //
     170             : 
     171             : class DlinJones : public DJones {
     172             : public:
     173             : 
     174             :   // Constructor
     175             :   DlinJones(VisSet& vs);
     176             :   DlinJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     177             :   DlinJones(const MSMetaInfoForCal& msmc);
     178             :   DlinJones(const casacore::Int& nAnt);
     179             : 
     180             :   virtual ~DlinJones();
     181             : 
     182             :   // Return type name as string
     183           0 :   virtual casacore::String typeName()     { return "D Jones"; };
     184           0 :   virtual casacore::String longTypeName() { return "D Jones (instrumental polarization"; };
     185             : 
     186             :   // Type of Jones matrix according to nPar()
     187             :   //  Do linearized matrix algebra
     188           0 :   virtual Jones::JonesType jonesType() { return Jones::GenLinear; };
     189             : 
     190             : };
     191             : 
     192             : // **********************************************************
     193             : //  DflinJones (freq-dep, linearized DJones)
     194             : //
     195             : 
     196             : class DflinJones : public DlinJones {
     197             : public:
     198             : 
     199             :   // Constructor
     200             :   DflinJones(VisSet& vs);
     201             :   DflinJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     202             :   DflinJones(const MSMetaInfoForCal& msmc);
     203             :   DflinJones(const casacore::Int& nAnt);
     204             : 
     205             :   virtual ~DflinJones();
     206             : 
     207             :   // Return type name as string
     208           0 :   virtual casacore::String typeName()     { return "Df Jones"; };
     209           0 :   virtual casacore::String longTypeName() { return "Df Jones (frequency-dependent instrumental polarization"; };
     210             : 
     211             :   // This is the freq-dep version of D 
     212             :   //   (this is the ONLY fundamental difference from D)
     213           0 :   virtual casacore::Bool freqDepPar() { return true; };
     214             : 
     215             : };
     216             : 
     217             : // **********************************************************
     218             : //  DllsJones   (LLS DJones solve, General apply)
     219             : //
     220             : 
     221             : 
     222             : class DllsJones : public DJones {
     223             : public:
     224             : 
     225             :   // Constructor
     226             :   DllsJones(VisSet& vs);
     227             :   DllsJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     228             :   DllsJones(const MSMetaInfoForCal& msmc);
     229             :   DllsJones(const casacore::Int& nAnt);
     230             : 
     231             : 
     232             :   virtual ~DllsJones();
     233             : 
     234             :   // Return type name as string
     235           0 :   virtual casacore::String typeName()     { return "DLLS Jones"; };
     236           0 :   virtual casacore::String longTypeName() { return "DLLS Jones (instrumental polarization)"; };
     237             : 
     238             :   // Type of Jones matrix 
     239           0 :   virtual Jones::JonesType jonesType() { return Jones::General; };
     240             : 
     241             :   // Dlin now uses generic gather, but solves for itself per solution
     242           0 :   virtual casacore::Bool useGenericGatherForSolve() { return true; };
     243           0 :   virtual casacore::Bool useGenericSolveOne() { return false; }
     244             : 
     245             :   // Local implementation of selfSolveOne (generalized signature)
     246             :   //   call solveOneVB with the first (and only?) VB
     247           0 :   virtual void selfSolveOne(VisBuffGroupAcc& vbga) { this->solveOneVB(vbga(0)); };
     248           0 :   virtual void selfSolveOne(SDBList& sdbs) { this->solveOne(sdbs); };
     249             : 
     250             : 
     251             : protected:
     252             : 
     253             :   // LSQ Solver for 1 VB
     254             :   virtual void solveOneVB(const VisBuffer& vb);
     255             :   virtual void solveOneSDB(SolveDataBuffer& sdb);
     256             : 
     257             :   // LSQ Solver for an SDBList (which may contain multiple SDBs over time/spw)
     258             :   virtual void solveOne(SDBList& sdbs);
     259             : 
     260             : 
     261             : };
     262             : 
     263             : // **********************************************************
     264             : //  DfllsJones (freq-dep, LLS DJones solve, General apply)
     265             : //
     266             : 
     267             : class DfllsJones : public DllsJones {
     268             : public:
     269             : 
     270             :   // Constructor
     271             :   DfllsJones(VisSet& vs);
     272             :   DfllsJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     273             :   DfllsJones(const MSMetaInfoForCal& msmc);
     274             :   DfllsJones(const casacore::Int& nAnt);
     275             : 
     276             :   virtual ~DfllsJones();
     277             : 
     278             :   // Return type name as string
     279           0 :   virtual casacore::String typeName()     { return "DfLLS Jones"; };
     280           0 :   virtual casacore::String longTypeName() { return "DfLLS Jones (frequency-dependent instrumental polarization"; };
     281             : 
     282             :   // This is the freq-dep version of D 
     283             :   //   (this is the ONLY fundamental difference from D)
     284           0 :   virtual casacore::Bool freqDepPar() { return true; };
     285             : 
     286             : };
     287             : 
     288             : /*
     289             : 
     290             : // **********************************************************
     291             : //  X: position angle calibration (for circulars!)
     292             : //    (rendered as a Mueller for now)
     293             : 
     294             : class XMueller : public SolvableVisMueller {
     295             : public:
     296             : 
     297             :   // Constructor
     298             :   XMueller(VisSet& vs);
     299             :   XMueller(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     300             :   XMueller(const MSMetaInfoForCal& msmc);
     301             :   XMueller(const casacore::Int& nAnt);
     302             : 
     303             :   virtual ~XMueller();
     304             : 
     305             :   // Return the type enum
     306             :   virtual Type type() { return VisCal::X; };
     307             : 
     308             :   // Return type name as string
     309             :   virtual casacore::String typeName()     { return "X Mueller"; };
     310             :   virtual casacore::String longTypeName() { return "X Mueller (baseline-based)"; };
     311             : 
     312             :   // Type of Jones matrix according to nPar()
     313             :   virtual Mueller::MuellerType muellerType() { return Mueller::Diagonal; };
     314             : 
     315             :   // Local setApply
     316             :   using SolvableVisCal::setApply;
     317             :   virtual void setApply(const casacore::Record& apply);
     318             : 
     319             :   // Local setSolve
     320             :   using SolvableVisCal::setSolve;
     321             :   void setSolve(const casacore::Record& solvepar);
     322             : 
     323             :   // Turn off normalization by model....
     324             :   virtual casacore::Bool normalizable() { return false; };
     325             : 
     326             :   // X gathers/solves for itself
     327             :   virtual casacore::Bool useGenericGatherForSolve() { return false; };
     328             : 
     329             :   // X gathers/solves for itself 
     330             :   virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve) { newselfSolve(vs,ve); };
     331             :   virtual void newselfSolve(VisSet& vs, VisEquation& ve);  // new supports combine
     332             : 
     333             : 
     334             : protected:
     335             : 
     336             :   // X has just 1 complex parameter, storing a phase
     337             :   virtual casacore::Int nPar() { return 1; };
     338             : 
     339             :   // Jones matrix elements are trivial
     340             :   virtual casacore::Bool trivialMuellerElem() { return false; };
     341             : 
     342             :   // Calculate the X matrix for all ants
     343             :   virtual void calcAllMueller();
     344             : 
     345             :   // Solve in one VB for the position angle
     346             :   virtual void solveOneVB(const VisBuffer& vb);
     347             : 
     348             : private:
     349             : 
     350             :   // <nothing>
     351             : 
     352             : };
     353             : 
     354             : 
     355             : 
     356             : // **********************************************************
     357             : //  X: position angle calibration (for circulars!)
     358             : //
     359             : class XJones : public SolvableVisJones {
     360             : public:
     361             : 
     362             :   // Constructor
     363             :   XJones(VisSet& vs);
     364             :   XJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     365             :   XJones(const MSMetaInfoForCal& msmc);
     366             :   XJones(const casacore::Int& nAnt);
     367             : 
     368             : 
     369             :   virtual ~XJones();
     370             : 
     371             :   // Return the type enum
     372             :   virtual Type type() { return VisCal::X; };
     373             : 
     374             :   // Return type name as string
     375             :   virtual casacore::String typeName()     { return "X Jones"; };
     376             :   virtual casacore::String longTypeName() { return "X Jones (antenna-based)"; };
     377             : 
     378             :   // Type of Jones matrix according to nPar()
     379             :   virtual Jones::JonesType jonesType() { return Jones::Diagonal; };
     380             : 
     381             :   // Local setApply
     382             :   using SolvableVisCal::setApply;
     383             :   virtual void setApply(const casacore::Record& apply);
     384             : 
     385             :   // Local setSolve
     386             :   using SolvableVisCal::setSolve;
     387             :   void setSolve(const casacore::Record& solvepar);
     388             : 
     389             :   // X is normalizable by the model
     390             :   virtual casacore::Bool normalizable() { return true; };
     391             : 
     392             :   // X generically gathers, but solves for itself per solution
     393             :   virtual casacore::Bool useGenericGatherForSolve() { return true; };
     394             :   virtual casacore::Bool useGenericSolveOne() { return false; }
     395             : 
     396             :   // X gathers/solves for itself 
     397             :   virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve) { newselfSolve(vs,ve); };
     398             :   virtual void newselfSolve(VisSet& vs, VisEquation& ve);  // new supports combine
     399             : 
     400             :   // When genericall gathering, solve using first VB only in VBGA
     401             :   virtual void selfSolveOne(VisBuffGroupAcc& vbga) { this->solveOneVB(vbga(0)); };
     402             :   virtual void selfSolveOne(SDBList& sdbs) { this->solveOne(sdbs); };
     403             : 
     404             : 
     405             : protected:
     406             : 
     407             :   // X has just 1 complex parameter, storing a phase
     408             :   virtual casacore::Int nPar() { return 1; };
     409             : 
     410             :   // Jones matrix elements are trivial
     411             :   virtual casacore::Bool trivialJonesElem() { return false; };
     412             : 
     413             :   // Calculate the X matrix for all ants
     414             :   virtual void calcAllJones();
     415             : 
     416             :   // Solve in one VB for the position angle
     417             :   virtual void solveOneVB(const VisBuffer& vb);
     418             :   virtual void solveOneSDB(SolveDataBuffer& sdb);
     419             : 
     420             :   virtual void solveOne(SDBList& sdbs);
     421             : 
     422             : private:
     423             : 
     424             :   // <nothing>
     425             : 
     426             : };
     427             : 
     428             : 
     429             : // **********************************************************
     430             : //  Xf: position angle calibration (for circulars!)
     431             : //     (channel-dependent)
     432             : class XfJones : public XJones {
     433             : public:
     434             : 
     435             :   // Constructor
     436             :   XfJones(VisSet& vs);
     437             :   XfJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     438             :   XfJones(const MSMetaInfoForCal& msmc);
     439             :   XfJones(const casacore::Int& nAnt);
     440             : 
     441             :   virtual ~XfJones();
     442             : 
     443             :   // Return the type enum
     444             :   virtual Type type() { return VisCal::X; };
     445             : 
     446             :   // Return type name as string
     447             :   virtual casacore::String typeName()     { return "Xf Jones"; };
     448             :   virtual casacore::String longTypeName() { return "Xf Jones (antenna-based)"; };
     449             : 
     450             :   // This is the freq-dep version of X 
     451             :   //   (this is the ONLY fundamental difference from X)
     452             :   virtual casacore::Bool freqDepPar() { return true; };
     453             : 
     454             : protected:
     455             : 
     456             :   // Use nchan>=1 shaping
     457             :   //  (TBD: this should be generalized!)
     458             :   void initSolvePar();
     459             : 
     460             : 
     461             : };
     462             : 
     463             : 
     464             : // X-Y phase 
     465             : class GlinXphJones : public GJones {
     466             : public:
     467             : 
     468             :   // Constructor
     469             :   GlinXphJones(VisSet& vs);
     470             :   GlinXphJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     471             :   GlinXphJones(const MSMetaInfoForCal& msmc);
     472             :   GlinXphJones(const casacore::Int& nAnt);
     473             : 
     474             :   virtual ~GlinXphJones();
     475             : 
     476             :   // Return the type enum  (position UPSTREAM of D, not downstream like G)
     477             :   virtual Type type() { return VisCal::X; };
     478             : 
     479             :   // Return type name as string
     480             :   virtual casacore::String typeName()     { return "GlinXph Jones"; };
     481             :   virtual casacore::String longTypeName() { return "GlinXph Jones (X-Y phase)"; };
     482             : 
     483             :   // Local setapply  (unsets calWt)
     484             :   using SolvableVisJones::setApply;
     485             :   virtual void setApply(const casacore::Record& apply);
     486             : 
     487             :   // NOT FreqDep
     488             :   virtual casacore::Bool freqDepPar() { return false; };
     489             : 
     490             :   // Though derived from GJones, this type actually uses the cross-hands
     491             :   virtual casacore::Bool phandonly() { return false; };
     492             : 
     493             :   // GlinXphJones specialization
     494             :   virtual casacore::Bool useGenericGatherForSolve() { return true; }; 
     495             :   virtual casacore::Bool useGenericSolveOne() { return false; }
     496             : 
     497             :   virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve);
     498             : 
     499             :   // Handle trivial vbga generated by generic gather-for-solve
     500             :   virtual void selfSolveOne(VisBuffGroupAcc& vbga);
     501             :   virtual void selfSolveOne(SDBList& sdbs);
     502             : 
     503             : protected:
     504             : 
     505             : 
     506             :   // Solver for one VB, that collapses baselines and cross-hands first,
     507             :   //  then solves for XY-phase and QU
     508             :   virtual void solveOneVB(const VisBuffer& vb);
     509             :   virtual void solveOne(SDBList& sdbs);
     510             : 
     511             :   // Write QU info into table keywords
     512             :   virtual void globalPostSolveTinker();
     513             : 
     514             :   // Derived QU_ info
     515             :   casacore::Matrix<casacore::Float> QU_;
     516             : 
     517             : 
     518             : };
     519             : 
     520             : 
     521             : // Freq-dep XY-phase
     522             : class GlinXphfJones : public GlinXphJones {
     523             : public:
     524             : 
     525             :   // Constructor
     526             :   GlinXphfJones(VisSet& vs);
     527             :   GlinXphfJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     528             :   GlinXphfJones(const MSMetaInfoForCal& msmc);
     529             :   GlinXphfJones(const casacore::Int& nAnt);
     530             : 
     531             : 
     532             :   virtual ~GlinXphfJones();
     533             :   // Return type name as string
     534             :   // Return type name as string
     535             :   virtual casacore::String typeName()     { return "GlinXphf Jones"; };
     536             :   virtual casacore::String longTypeName() { return "GlinXphf Jones (X-Y phase)"; };
     537             : 
     538             :   // This is the freq-dep version of GlinXphJones
     539             :   //   (this is the ONLY fundamental difference from GlinXphJones)
     540             :   virtual casacore::Bool freqDepPar() { return true; };
     541             : 
     542             : 
     543             : };
     544             : 
     545             : */
     546             : 
     547             : 
     548             : } //# NAMESPACE CASA - END
     549             : 
     550             : #endif
     551             : 

Generated by: LCOV version 1.16