LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - AMueller.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 23 29 79.3 %
Date: 2024-12-11 20:54:31 Functions: 16 21 76.2 %

          Line data    Source code
       1             : //# AMueller.h:  Additive closure errors
       2             : //# Copyright (C) 1996,1997,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             : 
      28             : #ifndef SYNTHESIS_AMUELLER_H
      29             : #define SYNTHESIS_AMUELLER_H
      30             : 
      31             : #include <casacore/casa/aips.h>
      32             : #include <casacore/casa/BasicSL/Complex.h>
      33             : #include <synthesis/MeasurementComponents/StandardVisCal.h>
      34             : #include <synthesis/MeasurementComponents/CalCorruptor.h>
      35             : 
      36             : namespace casa { //# NAMESPACE CASA - BEGIN
      37             : 
      38             : class VisBuffGroupAcc;
      39             : 
      40             : class AMueller : public MMueller {
      41             : public:
      42             : 
      43             :   // Constructor
      44             :   AMueller(VisSet& vs);
      45             :   AMueller(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
      46             :   AMueller(const MSMetaInfoForCal& msmc);
      47             :   AMueller(const casacore::Int& nAnt);
      48             :   
      49             :   virtual ~AMueller();
      50             : 
      51             :   // Return the type enum
      52           0 :   virtual Type type() { return VisCal::A; };
      53             : 
      54             :   // Return type name as string
      55          76 :   virtual casacore::String typeName()     { return "A Mueller"; };
      56           0 :   virtual casacore::String longTypeName() { return "A Mueller (baseline-based)"; };
      57             : 
      58             :   // Algebraic type of Mueller matrix 
      59             :   //  (this is the key distinguishing characteristic)
      60         264 :   virtual Mueller::MuellerType muellerType() { return Mueller::AddDiag2; };
      61             : 
      62             :   // Local setsolve (overrides preavg)
      63             :   using SolvableVisCal::setSolve;
      64             :   // Parameters particular to this class:
      65             :   //    fitorder: Order of the polynomial fit.  If 0, it is just an average.
      66             :   virtual void setSolve(const casacore::Record& solvepar);
      67             : 
      68             :   // AMueller's caltables have polynomial orders where channels would normally
      69             :   // go.  setSolve() above sets the number of "channels", but
      70             :   // SolvableVisCal::setSolveChannelization() would just reset it to 1 if it
      71             :   // was not overrode here.
      72             :   virtual void setSolveChannelization(VisSet& vs);
      73             : 
      74             :   // Size up the solving arrays, etc.  (supports combine)
      75             :   virtual casacore::Int sizeUpSolve(VisSet& vs, casacore::Vector<casacore::Int>& nChunkPerSol);
      76             : 
      77             :   // The fitorder = 0 version (in M) skips casacore::LinearFitSVD by just averaging.
      78           7 :   virtual casacore::Bool useGenericGatherForSolve() {return fitorder_p != 0;}
      79             : 
      80             :   // Only called if useGenericGatherForSolve() == true.  If
      81             :   // useGenericGatherForSolve() == true, then genericGatherAndSolve() will call
      82             :   // AMueller's selfSolveOne().  Otherwise MMueller's selfGatherAndSolve() will
      83             :   // do everything.
      84          39 :   virtual casacore::Bool useGenericSolveOne() {return false;}
      85             : 
      86             :   // Per-solution self-solving inside generic gather.  Flexible enough for
      87             :   // fitorder != 0, but overkill otherwise.
      88             :   virtual void selfSolveOne(VisBuffGroupAcc& vbga);
      89             : 
      90             :   virtual void storeNCT();
      91             : 
      92           0 :   virtual void setApply() {SolvableVisCal::setApply();}
      93             :   virtual void setApply(const casacore::Record& applypar);
      94             : 
      95             :   // Apply this calibration to vb.  AMueller does NOT support trial
      96             :   //                                and ignores it!
      97             :   virtual void applyCal(VisBuffer& vb, casacore::Cube<casacore::Complex>& Vout, casacore::Bool trial=false);
      98             :   // VB2 version (for apply context only!)
      99             :   virtual void applyCal2(vi::VisBuffer2& vb, 
     100             :                          casacore::Cube<casacore::Complex>& Vout,casacore::Cube<casacore::Float>& Wout,
     101             :                          casacore::Bool trial=false);
     102             : 
     103             :   // Freq dependence
     104         970 :   virtual casacore::Bool freqDepPar() { return false; };
     105      214253 :   virtual casacore::Bool freqDepMat() {
     106      214253 :     return fitorder_p != 0 || nChanPar() > 1; // The latter is for applying.
     107             :   }
     108             : 
     109             :   // We do not normalize by the model, since we are estimating
     110             :   //  directly from the data  (we should optimize here by avoiding 
     111             :   //  the model I/O)
     112         338 :   virtual casacore::Bool normalizable() {return false;};
     113             : 
     114             :   // Specialize corrupt to pre-zero model for corruption
     115             :   //using VisMueller::corrupt;
     116             :   virtual void corrupt(VisBuffer& vb);
     117             :   //virtual void corrupt(VisBuffer& vb, casacore::Cube<casacore::Complex>& Mout);
     118             : 
     119             :   // Set (repeatedly, unfortunately) whether or not subtraction is being done,
     120             :   // and IF fitorder == 0, sync matrices for current meta data (VisMueller
     121             :   // override).  (Mueller matrices aren't used for fitorder != 0.)
     122         377 :   void syncCalMat(const casacore::Bool& doInv)
     123             :   {
     124         377 :     doSub_p = doInv;
     125         377 :     if(fitorder_p == 0)
     126         264 :       VisMueller::syncCalMat(doInv);
     127         377 :   }
     128             : 
     129             : protected:
     130         211 :   virtual casacore::Int nPar() {
     131         211 :     if(nCorr_p < 0)
     132           0 :       hurl("nPar()", "nPar() called before being set.");
     133         211 :     return nCorr_p;
     134             :   }
     135             : 
     136             : private:
     137             :   void init();  // Common code for the c'tors.
     138             : 
     139             :   // Logs and throws msg as an exception from origin.
     140             :   void hurl(const casacore::String& origin, const casacore::String& msg);
     141             : 
     142             :   // Initialized to 0 in the initialization lists of the c'tors.
     143             :   casacore::Int fitorder_p;  // Stores the order of the fitted polynomials.
     144             : 
     145             :   casacore::Bool doSub_p; // For apply, whether or not to subtract or give the continuum
     146             :                 // estimate.
     147             :   casacore::Int  nCorr_p; // # of correlations.  -1 if not yet known.
     148             : 
     149             :   // Resized and set to impossible values in init().
     150             :   casacore::Vector<casacore::Double> lofreq_p; // Lowest and highest frequencies (Hz) used
     151             :   casacore::Vector<casacore::Double> hifreq_p; // to make the fit.
     152             :   casacore::Vector<casacore::uInt> totnumchan_p; // The total number of input channels that will be
     153             :                              // looked at (including masked ones!)
     154             :   casacore::Vector<casacore::Bool> spwApplied_p;  // Just keeps track of which spws have been
     155             :                               // applied to.
     156             : };
     157             : 
     158             : // Additive noise
     159             : // In practice, this is not really solvable, but it
     160             : //   is a SVM because we need access to general simulation methods
     161             : class ANoise : public SolvableVisMueller {
     162             : public:
     163             : 
     164             :   // Constructor
     165             :   ANoise(VisSet& vs);
     166             :   ANoise(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
     167             :   ANoise(const MSMetaInfoForCal& msmc);
     168             :   ANoise(const casacore::Int& nAnt);
     169             : 
     170             : 
     171             :   virtual ~ANoise();
     172             : 
     173             :   // Return the type enum
     174       13660 :   virtual Type type() { return VisCal::ANoise; };
     175             : 
     176             :   // Return type name as string
     177          32 :   virtual casacore::String typeName()     { return "A Noise"; };
     178           0 :   virtual casacore::String longTypeName() { return "A Noise (baseline-based)"; };
     179             : 
     180             :   // Algebraic type of Mueller matrix 
     181             :   //  (this is the key distinguishing characteristic)
     182       13596 :   virtual Mueller::MuellerType muellerType() { return Mueller::AddDiag2; };
     183             : 
     184             :   // Overide solvability
     185           0 :   virtual casacore::Bool isSolvable() { return false; };
     186             : 
     187             :   // this is inherently freqdep:
     188       80121 :   virtual casacore::Bool freqDepPar() { return true; };
     189             : 
     190             :   virtual void createCorruptor(const VisIter& vi, const casacore::Record& simpar, const casacore::Int nSim);
     191             : 
     192             : protected:
     193             :   // umm... 2 for each of parallel hands?
     194          96 :   virtual casacore::Int nPar() { return 2; };
     195             : 
     196             :   // Jones matrix elements are trivial
     197       19082 :   virtual casacore::Bool trivialMuellerElem() { return (!simOnTheFly()); };
     198             : 
     199             :   // override VC default of timeDepMat=F for OTF simulatio:
     200        4532 :   virtual casacore::Bool timeDepMat() { return simOnTheFly(); };
     201             : 
     202             :   // Calculate an ensemble of Mueller matrices (all baselines, channels)
     203             :   // overrriding VisCal::calcAllMueller
     204             :   virtual void calcAllMueller();
     205             : 
     206             :   // Calculate a single Mueller matrix by some means
     207             :   // override SolvableVisMueller::calcOneMueller
     208             :   virtual void calcOneMueller(casacore::Vector<casacore::Complex>& mat, casacore::Vector<casacore::Bool>& mOk,
     209             :                               const casacore::Vector<casacore::Complex>& par, const casacore::Vector<casacore::Bool>& pOk);
     210             : 
     211             : private:
     212             :   ANoiseCorruptor *acorruptor_p;
     213             : 
     214             : };
     215             : 
     216             : } //# NAMESPACE CASA - END
     217             : 
     218             : #endif

Generated by: LCOV version 1.16