LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - XJones.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 66 0.0 %
Date: 2024-10-10 19:51:30 Functions: 0 66 0.0 %

          Line data    Source code
       1             : //# XJones.h: Cross-hand phase calibration
       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_XJONES_H
      29             : #define SYNTHESIS_XJONES_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             : //  X: position angle calibration (for circulars!)
      47             : //    (rendered as a Mueller for now)
      48             : 
      49             : class XMueller : public SolvableVisMueller {
      50             : public:
      51             : 
      52             :   // Constructor
      53             :   XMueller(VisSet& vs);
      54             :   XMueller(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
      55             :   XMueller(const MSMetaInfoForCal& msmc);
      56             :   XMueller(const casacore::Int& nAnt);
      57             : 
      58             :   virtual ~XMueller();
      59             : 
      60             :   // Return the type enum
      61           0 :   virtual Type type() { return VisCal::X; };
      62             : 
      63             :   // Return type name as string
      64           0 :   virtual casacore::String typeName()     { return "X Mueller"; };
      65           0 :   virtual casacore::String longTypeName() { return "X Mueller (baseline-based)"; };
      66             : 
      67             :   // Type of Jones matrix according to nPar()
      68           0 :   virtual Mueller::MuellerType muellerType() { return Mueller::Diagonal; };
      69             : 
      70             :   // Local setApply
      71             :   using SolvableVisCal::setApply;
      72             :   virtual void setApply(const casacore::Record& apply);
      73             : 
      74             :   // Local setSolve
      75             :   using SolvableVisCal::setSolve;
      76             :   void setSolve(const casacore::Record& solvepar);
      77             : 
      78             :   // Turn off normalization by model....
      79           0 :   virtual casacore::Bool normalizable() { return false; };
      80             : 
      81             :   // X gathers/solves for itself
      82           0 :   virtual casacore::Bool useGenericGatherForSolve() { return false; };
      83             : 
      84             :   // X gathers/solves for itself 
      85           0 :   virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve) { newselfSolve(vs,ve); };
      86             :   virtual void newselfSolve(VisSet& vs, VisEquation& ve);  // new supports combine
      87             : 
      88             : 
      89             : protected:
      90             : 
      91             :   // X has just 1 complex parameter, storing a phase
      92           0 :   virtual casacore::Int nPar() { return 1; };
      93             : 
      94             :   // Jones matrix elements are trivial
      95           0 :   virtual casacore::Bool trivialMuellerElem() { return false; };
      96             : 
      97             :   // Calculate the X matrix for all ants
      98             :   virtual void calcAllMueller();
      99             : 
     100             :   // Solve in one VB for the position angle
     101             :   virtual void solveOneVB(const VisBuffer& vb);
     102             : 
     103             : private:
     104             : 
     105             :   // <nothing>
     106             : 
     107             : };
     108             : 
     109             : 
     110             : 
     111             : // **********************************************************
     112             : //  X: Cross-hand phase (generic) 
     113             : //
     114             : class XJones : public SolvableVisJones {
     115             : public:
     116             : 
     117             :   // Constructor
     118             :   XJones(VisSet& vs);
     119             :   XJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     120             :   XJones(const MSMetaInfoForCal& msmc);
     121             :   XJones(const casacore::Int& nAnt);
     122             : 
     123             : 
     124             :   virtual ~XJones();
     125             : 
     126             :   // Return the type enum
     127           0 :   virtual Type type() { return VisCal::X; };
     128             : 
     129             :   // Return type name as string
     130           0 :   virtual casacore::String typeName()     { return "X Jones"; };
     131           0 :   virtual casacore::String longTypeName() { return "X Jones (antenna-based)"; };
     132             : 
     133             :   // Type of Jones matrix according to nPar()
     134           0 :   virtual Jones::JonesType jonesType() { return Jones::Diagonal; };
     135             : 
     136             :   // Local setApply
     137             :   using SolvableVisCal::setApply;
     138             :   virtual void setApply(const casacore::Record& apply);
     139             : 
     140             :   // Local setSolve
     141             :   using SolvableVisCal::setSolve;
     142             :   void setSolve(const casacore::Record& solvepar);
     143             : 
     144             :   // X is normalizable by the model
     145           0 :   virtual casacore::Bool normalizable() { return true; };
     146             : 
     147             :   // X generically gathers, but solves for itself per solution
     148           0 :   virtual casacore::Bool useGenericGatherForSolve() { return true; };
     149           0 :   virtual casacore::Bool useGenericSolveOne() { return false; }
     150             : 
     151             :   // X gathers/solves for itself 
     152           0 :   virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve) { newselfSolve(vs,ve); };
     153             :   virtual void newselfSolve(VisSet& vs, VisEquation& ve);  // new supports combine
     154             : 
     155             :   // When genericall gathering, solve using first VB only in VBGA
     156           0 :   virtual void selfSolveOne(VisBuffGroupAcc& vbga) { this->solveOneVB(vbga(0)); };
     157           0 :   virtual void selfSolveOne(SDBList& sdbs) { this->solveOne(sdbs); };
     158             : 
     159             : 
     160             : protected:
     161             : 
     162             :   // X has just 1 complex parameter, storing a phase
     163           0 :   virtual casacore::Int nPar() { return 1; };
     164             : 
     165             :   // Jones matrix elements are trivial
     166           0 :   virtual casacore::Bool trivialJonesElem() { return false; };
     167             : 
     168             :   // Calculate the X matrix for all ants
     169             :   virtual void calcAllJones();
     170             : 
     171             :   // Solve in one VB for the position angle
     172             :   virtual void solveOneVB(const VisBuffer& vb);
     173             :   virtual void solveOneSDB(SolveDataBuffer& sdb);
     174             : 
     175             :   virtual void solveOne(SDBList& sdbs);
     176             : 
     177             : private:
     178             : 
     179             :   // <nothing>
     180             : 
     181             : };
     182             : 
     183             : 
     184             : // **********************************************************
     185             : //  Xf: position angle calibration (for circulars!)
     186             : //     (channel-dependent)
     187             : class XfJones : public XJones {
     188             : public:
     189             : 
     190             :   // Constructor
     191             :   XfJones(VisSet& vs);
     192             :   XfJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     193             :   XfJones(const MSMetaInfoForCal& msmc);
     194             :   XfJones(const casacore::Int& nAnt);
     195             : 
     196             :   virtual ~XfJones();
     197             : 
     198             :   // Return the type enum
     199           0 :   virtual Type type() { return VisCal::X; };
     200             : 
     201             :   // Return type name as string
     202           0 :   virtual casacore::String typeName()     { return "Xf Jones"; };
     203           0 :   virtual casacore::String longTypeName() { return "Xf Jones (antenna-based)"; };
     204             : 
     205             :   // This is the freq-dep version of X 
     206             :   //   (this is the ONLY fundamental difference from X)
     207           0 :   virtual casacore::Bool freqDepPar() { return true; };
     208             : 
     209             : protected:
     210             : 
     211             :   // Use nchan>=1 shaping
     212             :   //  (TBD: this should be generalized!)
     213             :   void initSolvePar();
     214             : 
     215             : 
     216             : };
     217             : 
     218             : 
     219             : // Cross-hand phase solved from data with parang coverage
     220             : class XparangJones : public XJones {
     221             : public:
     222             : 
     223             :   // Constructor
     224             :   XparangJones(VisSet& vs);
     225             :   XparangJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     226             :   XparangJones(const MSMetaInfoForCal& msmc);
     227             :   XparangJones(const casacore::Int& nAnt);
     228             : 
     229             :   virtual ~XparangJones();
     230             : 
     231             :   // Return the type enum  (position UPSTREAM of D, not downstream like G)
     232           0 :   virtual Type type() { return VisCal::X; };
     233             : 
     234             :   // Return type name as string
     235           0 :   virtual casacore::String typeName()     { return "Xparang Jones"; };
     236           0 :   virtual casacore::String longTypeName() { return "Xparang Jones (parang-dep X)"; };
     237             : 
     238             :   // Local setapply  (unsets calWt)
     239             :   using SolvableVisJones::setApply;
     240             :   virtual void setApply(const casacore::Record& apply);
     241             : 
     242             :   // NOT FreqDep
     243           0 :   virtual casacore::Bool freqDepPar() { return false; };
     244             : 
     245             :   // Requires cross-hands!
     246           0 :   virtual casacore::Bool phandonly() { return false; };
     247             : 
     248             :   // XparangJones specialization
     249           0 :   virtual casacore::Bool useGenericGatherForSolve() { return true; }; 
     250           0 :   virtual casacore::Bool useGenericSolveOne() { return false; }
     251             : 
     252             :   virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve);
     253             : 
     254             :   // Handle trivial vbga generated by generic gather-for-solve
     255             :   virtual void selfSolveOne(VisBuffGroupAcc& vbga);
     256             :   virtual void selfSolveOne(SDBList& sdbs);
     257             : 
     258             :   // Write QU info into table keywords
     259             :   virtual void globalPostSolveTinker();
     260             : 
     261             :   // Override for returning Q,U info via Record
     262             :   virtual casacore::Record solveActionRec();
     263             : 
     264             :   // Overide model division stuff...
     265           0 :   virtual casacore::Bool normalizable() { return false; };
     266           0 :   virtual casacore::Bool divideByStokesIModelForSolve() { return true; };
     267             : 
     268             : protected:
     269             : 
     270             :   // X has just 1 complex parameter, storing a phase
     271           0 :   virtual casacore::Int nPar() { return 1; };
     272             : 
     273             :   // Solver for one VB, that collapses baselines and cross-hands first,
     274             :   //  then solves for XY-phase and QU
     275             :   virtual void solveOneVB(const VisBuffer& vb);
     276             :   virtual void solveOne(SDBList& sdbs);
     277             : 
     278             :   // Derived QU_ info
     279             :   casacore::Matrix<casacore::Float> QU_;
     280             : 
     281             :   // Activity record
     282             :   casacore::Record QURec_;
     283             : 
     284             : };
     285             : 
     286             : 
     287             : 
     288             : // Freq-dep cross-hand phase
     289             : class XfparangJones : public XparangJones {
     290             : public:
     291             : 
     292             :   // Constructor
     293             :   XfparangJones(VisSet& vs);
     294             :   XfparangJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     295             :   XfparangJones(const MSMetaInfoForCal& msmc);
     296             :   XfparangJones(const casacore::Int& nAnt);
     297             : 
     298             : 
     299             :   virtual ~XfparangJones();
     300             :   // Return type name as string
     301             :   // Return type name as string
     302           0 :   virtual casacore::String typeName()     { return "Xfparang Jones"; };
     303           0 :   virtual casacore::String longTypeName() { return "Xfparang Jones (X-Y phase)"; };
     304             : 
     305             :   // This is the freq-dep version of XparangJones
     306             :   //   (this is the ONLY fundamental difference from XparangJones)
     307           0 :   virtual casacore::Bool freqDepPar() { return true; };
     308             : 
     309             : 
     310             : };
     311             : 
     312             : 
     313             : // **********************************************************
     314             : //  PosAng: Basis-agnostic position angle
     315             : //
     316             : class PosAngJones : public XJones {
     317             : public:
     318             : 
     319             :   // Constructor
     320             :   PosAngJones(VisSet& vs);
     321             :   PosAngJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     322             :   PosAngJones(const MSMetaInfoForCal& msmc);
     323             :   PosAngJones(const casacore::Int& nAnt);
     324             : 
     325             :   virtual ~PosAngJones();
     326             : 
     327             :   // PosAng had casacore::Float parameter
     328           0 :   virtual VisCalEnum::VCParType parType() { return VisCalEnum::REAL; };
     329             : 
     330             :   // Return the type enum (this is its position in the ME)
     331           0 :   virtual Type type() { return VisCal::C; };
     332             : 
     333             :   // Return type name as string
     334           0 :   virtual casacore::String typeName()     { return "PosAng Jones"; };
     335           0 :   virtual casacore::String longTypeName() { return "PosAng Jones (antenna-based)"; };
     336             : 
     337             :   // Type of Jones matrix (basis-sensitive)
     338           0 :   virtual Jones::JonesType jonesType() { return jonestype_; };
     339             : 
     340             :   // FreqDep
     341           0 :   virtual casacore::Bool freqDepPar() { return true; };
     342             : 
     343             :   // Local setApply
     344             :   using XJones::setApply;
     345             :   virtual void setApply(const casacore::Record& apply);
     346             : 
     347             :   // Local setSolve
     348             :   using XJones::setSolve;
     349             :   void setSolve(const casacore::Record& solvepar);
     350             : 
     351             :   // PosAng is NOT normalizable by the model (per correlation)
     352           0 :   virtual casacore::Bool normalizable() { return false; };
     353             :   // ...but we can divide by the I model!
     354           0 :   virtual casacore::Bool divideByStokesIModelForSolve() { return true; };
     355             : 
     356             :   // X generically gathers, but solves for itself per solution
     357           0 :   virtual casacore::Bool useGenericGatherForSolve() { return true; };
     358           0 :   virtual casacore::Bool useGenericSolveOne() { return false; }
     359             : 
     360             :   // Actually do the solve on ths SDBs
     361           0 :   virtual void selfSolveOne(SDBList& sdbs) { this->solveOne(sdbs); };
     362             : 
     363             : 
     364             : protected:
     365             : 
     366             :   // PosAng has just 1 float parameter, storing an angle
     367           0 :   virtual casacore::Int nPar() { return 1; };
     368             : 
     369             :   // Jones matrix elements are NOT trivial
     370           0 :   virtual casacore::Bool trivialJonesElem() { return false; };
     371             : 
     372             :   // Detect basis for this vb
     373             :   virtual void syncMeta(const VisBuffer& vb);
     374             :   virtual void syncMeta2(const vi::VisBuffer2& vb);
     375             : 
     376             :   // Calculate the PosAng matrix for all ants
     377             :   //  Don't use XJones::calcAllJones!!
     378             :   virtual void calcAllJones(); //  { VisJones::calcAllJones(); };
     379             : 
     380             :   // Calculate a single PosAngJones matrix 
     381             :   virtual void calcOneJonesRPar(casacore::Vector<casacore::Complex>& mat, casacore::Vector<casacore::Bool>& mOk,
     382             :                             const casacore::Vector<casacore::Float>& par, const casacore::Vector<casacore::Bool>& pOk );
     383             : 
     384             :   virtual void solveOne(SDBList& sdbs);
     385             : 
     386             : private:
     387             : 
     388             :   // X gathers/solves for itself 
     389           0 :   virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve) { newselfSolve(vs,ve); };
     390           0 :   virtual void newselfSolve(VisSet& , VisEquation& ) { throw(casacore::AipsError("PosAngJones::newselfsolve(vs,ve) NYI")); };  // new supports combine
     391             : 
     392             :   // When genericall gathering, solve using first VB only in VBGA
     393           0 :   virtual void selfSolveOne(VisBuffGroupAcc& vbga) { this->solveOneVB(vbga(0)); };
     394             : 
     395             :   // Solve in one VB for the position angle
     396           0 :   virtual void solveOneVB(const VisBuffer& ) { throw(casacore::AipsError("PosAngJones::solveOneVB(vb) NYI")); };
     397           0 :   virtual void solveOneSDB(SolveDataBuffer& ) { throw(casacore::AipsError("PosAngJones::solveOneSDB(sdb) NYI")); };
     398             : 
     399             :   // We sense basis in setMeta, and this sets the matrix type
     400             :   Jones::JonesType jonestype_;
     401             : 
     402             : };
     403             : 
     404             : 
     405             : 
     406             : 
     407             : 
     408             : 
     409             : 
     410             : 
     411             : 
     412             : // X-Y phase for ALMA -- ORIGINAL ad hoc version as GJones specialization, but in Xf position
     413             : class GlinXphJones : public GJones {
     414             : public:
     415             : 
     416             :   // Constructor
     417             :   GlinXphJones(VisSet& vs);
     418             :   GlinXphJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     419             :   GlinXphJones(const MSMetaInfoForCal& msmc);
     420             :   GlinXphJones(const casacore::Int& nAnt);
     421             : 
     422             :   virtual ~GlinXphJones();
     423             : 
     424             :   // Return the type enum  (position UPSTREAM of D, not downstream like G)
     425           0 :   virtual Type type() { return VisCal::X; };
     426             : 
     427             :   // Return type name as string
     428           0 :   virtual casacore::String typeName()     { return "GlinXph Jones"; };
     429           0 :   virtual casacore::String longTypeName() { return "GlinXph Jones (X-Y phase)"; };
     430             : 
     431             :   // Local setapply  (unsets calWt)
     432             :   using SolvableVisJones::setApply;
     433             :   virtual void setApply(const casacore::Record& apply);
     434             : 
     435             :   // NOT FreqDep
     436           0 :   virtual casacore::Bool freqDepPar() { return false; };
     437             : 
     438             :   // Though derived from GJones, this type actually uses the cross-hands
     439           0 :   virtual casacore::Bool phandonly() { return false; };
     440             : 
     441             :   // GlinXphJones specialization
     442           0 :   virtual casacore::Bool useGenericGatherForSolve() { return true; }; 
     443           0 :   virtual casacore::Bool useGenericSolveOne() { return false; }
     444             : 
     445             :   virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve);
     446             : 
     447             :   // Handle trivial vbga generated by generic gather-for-solve
     448             :   virtual void selfSolveOne(VisBuffGroupAcc& vbga);
     449             :   virtual void selfSolveOne(SDBList& sdbs);
     450             : 
     451             : protected:
     452             : 
     453             : 
     454             :   // Solver for one VB, that collapses baselines and cross-hands first,
     455             :   //  then solves for XY-phase and QU
     456             :   virtual void solveOneVB(const VisBuffer& vb);
     457             :   virtual void solveOne(SDBList& sdbs);
     458             : 
     459             :   // Write QU info into table keywords
     460             :   virtual void globalPostSolveTinker();
     461             : 
     462             :   // Derived QU_ info
     463             :   casacore::Matrix<casacore::Float> QU_;
     464             : 
     465             : 
     466             : };
     467             : 
     468             : 
     469             : // Freq-dep XY-phase
     470             : class GlinXphfJones : public GlinXphJones {
     471             : public:
     472             : 
     473             :   // Constructor
     474             :   GlinXphfJones(VisSet& vs);
     475             :   GlinXphfJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     476             :   GlinXphfJones(const MSMetaInfoForCal& msmc);
     477             :   GlinXphfJones(const casacore::Int& nAnt);
     478             : 
     479             : 
     480             :   virtual ~GlinXphfJones();
     481             :   // Return type name as string
     482             :   // Return type name as string
     483           0 :   virtual casacore::String typeName()     { return "GlinXphf Jones"; };
     484           0 :   virtual casacore::String longTypeName() { return "GlinXphf Jones (X-Y phase)"; };
     485             : 
     486             :   // This is the freq-dep version of GlinXphJones
     487             :   //   (this is the ONLY fundamental difference from GlinXphJones)
     488           0 :   virtual casacore::Bool freqDepPar() { return true; };
     489             : 
     490             : 
     491             : };
     492             : 
     493             : 
     494             : 
     495             : 
     496             : } //# NAMESPACE CASA - END
     497             : 
     498             : #endif
     499             : 

Generated by: LCOV version 1.16