VisEquation.h

Go to the documentation of this file.
00001 //# VisEquation.h: Interface definition for Vis Equation
00002 //# Copyright (C) 1996,1997,1999,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_VISEQUATION_H
00029 #define SYNTHESIS_VISEQUATION_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/BasicSL/Complex.h>
00033 #include <casa/Arrays/Array.h>
00034 #include <casa/Arrays/Cube.h>
00035 #include <msvis/MSVis/VisBuffer.h>
00036 #include <msvis/MSVis/VisBuffer2.h>
00037 #include <synthesis/MeasurementComponents/VisCal.h>
00038 #include <synthesis/MeasurementComponents/SolvableVisCal.h>
00039 
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 
00042 // <summary> 
00043 // Visibility Measurement Equation
00044 // </summary>
00045 
00046 // <use visibility=export>
00047 
00048 // <reviewed reviewer="" date="" tests="" demos="">
00049 
00050 // <prerequisite>
00051 //   <li> <linkto module="MeasurementComponents">MeasurementComponents</linkto> module
00052 // </prerequisite>
00053 //
00054 // <etymology>
00055 // Visibility Equation describes a model for measurements from a
00056 // generic synthesis telescope
00057 // </etymology>
00058 //
00059 // <synopsis> 
00060 // This is responsible for the Measurement Equation of the Generic
00061 // Interferometer due to Hamaker, Bregman and Sault and later extended
00062 // by Noordam, and Cornwell.
00063 //
00064 // See <linkto module="MeasurementEquations">MeasurementEquations</linkto>
00065 // for more details of the form of the VisEquation.
00066 //
00067 // VisEquation provides the following:
00068 // <ul>
00069 // <li> Sorting of calibration terms (VisCals) in the Visibility Equation
00070 // <li> Application of calibration terms to data (via delegation to VisCals)
00071 // <li> Delivery of other evaluations of the VisEquation, e.g., (differentiated) residuals
00072 // </ul>
00073 // </synopsis> 
00074 //
00075 // <example>
00076 // <srcblock>
00077 //
00078 // </srcblock>
00079 // </example>
00080 //
00081 // <motivation>
00082 // VisEquation is part of a framework of classes that are
00083 // designed for synthesis calibration and imaging. The others are the 
00084 // <linkto module=MeasurementComponents>MeasurementComponents</linkto>.
00085 // </motivation>
00086 //
00087 // <todo asof="">
00088 // </todo>
00089 
00090   class SolveDataBuffer;  // VI2
00091 
00092 class VisEquation {
00093 public:
00094 
00095   // Contructor
00096   VisEquation();
00097   
00098   // Copy ctor
00099   VisEquation(const VisEquation& other);
00100 
00101   // Destructor
00102   virtual ~VisEquation();
00103   
00104   // Assignment
00105   VisEquation& operator=(const VisEquation& other);
00106 
00107   // Arrange for apply of a VisCal list (i.e., sort them into the correct order)
00108   void setapply(PtrBlock<VisCal*>& vcin);
00109 
00110   // Arrange for solve of a single SolvableVisCal
00111   void setsolve(SolvableVisCal& svc);
00112 
00113   // Arrange a pivot point for evaluating the equation in collapseForSim
00114   void setPivot(VisCal::Type pivot);
00115 
00116   // Where is the pivot?
00117   VisCal::Type pivot() const { return pivot_; };
00118 
00119   // Arrange the model to use for calibration
00120   void setModel(const Vector<Float>& stokes);
00121   inline void unSetModel() { useInternalModel_=False; };
00122 
00123   // How many terms are arranged for apply?
00124   inline Int nTerms() const { return napp_; };
00125 
00126   // List the terms
00127   Vector<VisCal::Type> listTypes() const;
00128   
00129   // Report if spw has solutions available from all applied tables
00130   Bool spwOK(const Int& spw);
00131 
00132   // Correct in place the OBSERVED visibilities in a VisBuffer
00133   //  with the apply-able VisCals
00134   void correct(VisBuffer& vb, Bool trial=False);
00135   void correct2(vi::VisBuffer2& vb, Bool trial=False, Bool doWtSp=False);
00136 
00137   // Report flag-by-cal statistics
00138   Record actionRec();
00139 
00140   // Corrupt in place the MODEL visibilities in a VisBuffer
00141   //  with the apply-able VisCals
00142   void corrupt(VisBuffer& vb);
00143 
00144   // Correct/Corrupt in place the OBSERVED/MODEL visibilities in a VisBuffer
00145   //  with the apply-able VisCals on either side of the SolvableVisCal
00146   void collapse(VisBuffer& vb);
00147   void collapse2(vi::VisBuffer2& vb); // VB2 version
00148 
00149 
00150   // This collapse avoids I/O (assumes the vb data/model are ready),
00151   //  and uses a generic pivot (see setPivot) rather than the svc
00152   //  void collapseForSim(VisBuffer& vb);
00153   void collapseForSim(VisBuffer& vb);
00154 
00155   // Calculate residuals 
00156   //   (optionally for specific chan)
00157   void residuals(VisBuffer& vb, 
00158                  Cube<Complex>& R,
00159                  const Int chan=-1);
00160   
00161   // Calculate residuals and differentiated residuals
00162   //   (optionally for specific chan)
00163   void diffResiduals(CalVisBuffer& cvb);
00164   void diffResiduals(VisBuffer& vb, 
00165                      Cube<Complex>& R, 
00166                      Array<Complex>& dR,
00167                      Matrix<Bool>& Rflg); 
00168   void diffResiduals(VisBuffer& R,
00169                      VisBuffer& dR0,
00170                      VisBuffer& dR1,
00171                      Matrix<Bool>& Rflg);
00172 
00173   // SolveDataBuffer version
00174   void differentiate(SolveDataBuffer& sdb);  // VI2
00175  
00176   // Report the VisEq's state
00177   void state();
00178 
00179   // Set the print level
00180   inline void setPrtlev(const Int& prtlev) { prtlev_=prtlev; };
00181   
00182 protected:
00183 
00184   Bool ok();
00185 
00186   // Access to the PB of apply terms 
00187   inline PtrBlock<VisCal*>& vc()  { return (*vcpb_); };
00188 
00189   // Access to SVC
00190   inline SolvableVisCal&    svc() { return *svc_; };
00191 
00192   // Detect freq dependence along the Vis Equation
00193   void setFreqDep();
00194 
00195   // Divide corr data by model 
00196   void divideCorrByModel(vi::VisBuffer2& vb);
00197 
00198 
00199 private:
00200 
00201   // Diagnostic print level access
00202   inline Int& prtlev() { return prtlev_; };
00203 
00204   // A local copy of the list of VisCal (pointers) for applying
00205   //  (No ownership responsibilities)
00206   PtrBlock<VisCal*>* vcpb_;
00207 
00208   // Number of apply VisCals in vc_
00209   Int napp_;
00210 
00211   // Frequency dependence indices
00212   Int lfd_;     // Right-most freq-dep term on LEFT  side
00213   Int rfd_;     // Left-most  freq-dep term on RIGHT side
00214 
00215   // Trap for frequency averaging in collapse
00216   Bool freqAveOK_;
00217 
00218   // VisCal with solving interface
00219   //  (No ownership responsibilities)
00220   SolvableVisCal* svc_;
00221 
00222   // The pivot point used by collapse2
00223   VisCal::Type pivot_;
00224 
00225   // An internal (global) point source model
00226   Bool useInternalModel_;
00227   Vector<Float> stokesModel_;
00228 
00229   // Diagnostic print level
00230   Int prtlev_;
00231 
00232 };
00233 
00234 } //# NAMESPACE CASA - END
00235 
00236 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1