AMueller.h

Go to the documentation of this file.
00001 //# AMueller.h:  Additive closure errors
00002 //# Copyright (C) 1996,1997,2000,2001,2002,2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be adressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 
00028 #ifndef SYNTHESIS_AMUELLER_H
00029 #define SYNTHESIS_AMUELLER_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/BasicSL/Complex.h>
00033 #include <synthesis/MeasurementComponents/StandardVisCal.h>
00034 #include <synthesis/MeasurementComponents/CalCorruptor.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 class VisBuffGroupAcc;
00039 
00040 class AMueller : public MMueller {
00041 public:
00042 
00043   // Constructor
00044   AMueller(VisSet& vs);
00045   AMueller(String msname,Int MSnAnt,Int MSnSpw);
00046   AMueller(const MSMetaInfoForCal& msmc);
00047   AMueller(const Int& nAnt);
00048 
00049   virtual ~AMueller();
00050 
00051   // Return the type enum
00052   virtual Type type() { return VisCal::A; };
00053 
00054   // Return type name as string
00055   virtual String typeName()     { return "A Mueller"; };
00056   virtual String longTypeName() { return "A Mueller (baseline-based)"; };
00057 
00058   // Algebraic type of Mueller matrix 
00059   //  (this is the key distinguishing characteristic)
00060   virtual Mueller::MuellerType muellerType() { return Mueller::AddDiag2; };
00061 
00062   // Local setsolve (overrides preavg)
00063   using SolvableVisCal::setSolve;
00064   // Parameters particular to this class:
00065   //    fitorder: Order of the polynomial fit.  If 0, it is just an average.
00066   virtual void setSolve(const Record& solvepar);
00067 
00068   // AMueller's caltables have polynomial orders where channels would normally
00069   // go.  setSolve() above sets the number of "channels", but
00070   // SolvableVisCal::setSolveChannelization() would just reset it to 1 if it
00071   // was not overrode here.
00072   virtual void setSolveChannelization(VisSet& vs);
00073 
00074   // Size up the solving arrays, etc.  (supports combine)
00075   virtual Int sizeUpSolve(VisSet& vs, Vector<Int>& nChunkPerSol);
00076 
00077   // The fitorder = 0 version (in M) skips LinearFitSVD by just averaging.
00078   virtual Bool useGenericGatherForSolve() {return fitorder_p != 0;}
00079 
00080   // Only called if useGenericGatherForSolve() == True.  If
00081   // useGenericGatherForSolve() == True, then genericGatherAndSolve() will call
00082   // AMueller's selfSolveOne().  Otherwise MMueller's selfGatherAndSolve() will
00083   // do everything.
00084   virtual Bool useGenericSolveOne() {return False;}
00085 
00086   // Per-solution self-solving inside generic gather.  Flexible enough for
00087   // fitorder != 0, but overkill otherwise.
00088   virtual void selfSolveOne(VisBuffGroupAcc& vbga);
00089 
00090   virtual void storeNCT();
00091 
00092   virtual void setApply() {SolvableVisCal::setApply();}
00093   virtual void setApply(const Record& applypar);
00094 
00095   // Apply this calibration to vb.  AMueller does NOT support trial
00096   //                                and ignores it!
00097   virtual void applyCal(VisBuffer& vb, Cube<Complex>& Vout, Bool trial=False);
00098 
00099   // Freq dependence
00100   virtual Bool freqDepPar() { return False; };
00101   virtual Bool freqDepMat() {
00102     return fitorder_p != 0 || nChanPar() > 1; // The latter is for applying.
00103   }
00104 
00105   // We do not normalize by the model, since we are estimating
00106   //  directly from the data  (we should optimize here by avoiding 
00107   //  the model I/O)
00108   virtual Bool normalizable() {return False;};
00109 
00110   // Specialize corrupt to pre-zero model for corruption
00111   //using VisMueller::corrupt;
00112   virtual void corrupt(VisBuffer& vb);
00113   //virtual void corrupt(VisBuffer& vb, Cube<Complex>& Mout);
00114 
00115   // Set (repeatedly, unfortunately) whether or not subtraction is being done,
00116   // and IF fitorder == 0, sync matrices for current meta data (VisMueller
00117   // override).  (Mueller matrices aren't used for fitorder != 0.)
00118   void syncCalMat(const Bool& doInv)
00119   {
00120     doSub_p = doInv;
00121     if(fitorder_p == 0)
00122       VisMueller::syncCalMat(doInv);
00123   }
00124 
00125 protected:
00126   virtual Int nPar() {
00127     if(nCorr_p < 0)
00128       hurl("nPar()", "nPar() called before being set.");
00129     return nCorr_p;
00130   }
00131 
00132 private:
00133   void init();  // Common code for the c'tors.
00134 
00135   // Logs and throws msg as an exception from origin.
00136   void hurl(const String& origin, const String& msg);
00137 
00138   // Initialized to 0 in the initialization lists of the c'tors.
00139   Int fitorder_p;  // Stores the order of the fitted polynomials.
00140 
00141   Bool doSub_p; // For apply, whether or not to subtract or give the continuum
00142                 // estimate.
00143   Int  nCorr_p; // # of correlations.  -1 if not yet known.
00144 
00145   // Resized and set to impossible values in init().
00146   Vector<Double> lofreq_p; // Lowest and highest frequencies (Hz) used
00147   Vector<Double> hifreq_p; // to make the fit.
00148   Vector<uInt> totnumchan_p; // The total number of input channels that will be
00149                              // looked at (including masked ones!)
00150   Vector<Bool> spwApplied_p;  // Just keeps track of which spws have been
00151                               // applied to.
00152 };
00153 
00154 // Additive noise
00155 // In practice, this is not really solvable, but it
00156 //   is a SVM because we need access to general simulation methods
00157 class ANoise : public SolvableVisMueller {
00158 public:
00159 
00160   // Constructor
00161   ANoise(VisSet& vs);
00162   ANoise(String msname,Int MSnAnt,Int MSnSpw);
00163   ANoise(const MSMetaInfoForCal& msmc);
00164   ANoise(const Int& nAnt);
00165 
00166   virtual ~ANoise();
00167 
00168   // Return the type enum
00169   virtual Type type() { return VisCal::ANoise; };
00170 
00171   // Return type name as string
00172   virtual String typeName()     { return "A Noise"; };
00173   virtual String longTypeName() { return "A Noise (baseline-based)"; };
00174 
00175   // Algebraic type of Mueller matrix 
00176   //  (this is the key distinguishing characteristic)
00177   virtual Mueller::MuellerType muellerType() { return Mueller::AddDiag2; };
00178 
00179   // Overide solvability
00180   virtual Bool isSolvable() { return False; };
00181 
00182   // this is inherently freqdep:
00183   virtual Bool freqDepPar() { return True; };
00184 
00185   virtual void createCorruptor(const VisIter& vi, const Record& simpar, const Int nSim);
00186 
00187 protected:
00188   // umm... 2 for each of parallel hands?
00189   virtual Int nPar() { return 2; };
00190 
00191   // Jones matrix elements are trivial
00192   virtual Bool trivialMuellerElem() { return (!simOnTheFly()); };
00193 
00194   // override VC default of timeDepMat=F for OTF simulatio:
00195   virtual Bool timeDepMat() { return simOnTheFly(); };
00196 
00197   // Calculate an ensemble of Mueller matrices (all baselines, channels)
00198   // overrriding VisCal::calcAllMueller
00199   virtual void calcAllMueller();
00200 
00201   // Calculate a single Mueller matrix by some means
00202   // override SolvableVisMueller::calcOneMueller
00203   virtual void calcOneMueller(Vector<Complex>& mat, Vector<Bool>& mOk,
00204                               const Vector<Complex>& par, const Vector<Bool>& pOk);
00205 
00206 private:
00207   ANoiseCorruptor *acorruptor_p;
00208 
00209 };
00210 
00211 } //# NAMESPACE CASA - END
00212 
00213 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1