CalibratingVi2.h

Go to the documentation of this file.
00001 //# CalibratingVi2.h: Interface definition of the CalibratingVi2 class.
00002 //#
00003 //#  CASA - Common Astronomy Software Applications (http://casa.nrao.edu/)
00004 //#  Copyright (C) Associated Universities, Inc. Washington DC, USA 2011, All rights reserved.
00005 //#  Copyright (C) European Southern Observatory, 2011, All rights reserved.
00006 //#
00007 //#  This library is free software; you can redistribute it and/or
00008 //#  modify it under the terms of the GNU Lesser General Public
00009 //#  License as published by the Free software Foundation; either
00010 //#  version 2.1 of the License, or (at your option) any later version.
00011 //#
00012 //#  This library is distributed in the hope that it will be useful,
00013 //#  but WITHOUT ANY WARRANTY, without even the implied warranty of
00014 //#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 //#  Lesser General Public License for more details.
00016 //#
00017 //#  You should have received a copy of the GNU Lesser General Public
00018 //#  License along with this library; if not, write to the Free Software
00019 //#  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00020 //#  MA 02111-1307  USA
00021 //# $Id: $
00022 
00023 #ifndef CalibratingVi2_H_
00024 #define CalibratingVi2_H_
00025 
00026 // Where TransformingVi2 interface is defined
00027 #include <msvis/MSVis/TransformingVi2.h>
00028 #include <synthesis/MeasurementComponents/Calibrater.h>
00029 #include <synthesis/MeasurementEquations/VisEquation.h>
00030 
00031 #include <casa/Containers/Record.h>
00032 
00033 namespace casa { //# NAMESPACE CASA - BEGIN
00034 namespace vi { //# NAMESPACE VI - BEGIN
00035 
00036 class CalibratingParameters {
00037 
00038 // TBD:  add solve-context parameters, like apply pivot (solved-for term), normalization
00039 
00040 public:
00041 
00042   CalibratingParameters();
00043 
00044   CalibratingParameters(const Record& calLibRecord);
00045   CalibratingParameters(const String& callib);
00046   CalibratingParameters(Float corrFactor); // temporary, for initial testing
00047 
00048   CalibratingParameters(const CalibratingParameters& other);
00049   CalibratingParameters& operator=(const CalibratingParameters & other);
00050 
00051   Bool byCalLib() const;
00052 
00053   const Record& getCalLibRecord() const;
00054   Float getCorrFactor() const;  
00055 
00056   void setCalLibRecord(const Record& calLibRecord);
00057   void setCorrFactor(Float corrFactor);  
00058 
00059 private:
00060 
00061   void validate() const;
00062   Bool byCalLib_p;
00063   Record calLibRecord_p;
00064   Float corrFactor_p;  // temporary, for initial testing
00065 };
00066 
00067 
00068 
00069 
00070 class CalibratingVi2 : public vi::TransformingVi2
00071 {
00072 
00073 public:
00074 
00075   CalibratingVi2( vi::ViImplementation2 * inputVii,
00076                   const CalibratingParameters& calpar);
00077 
00078   // From cal pars and an MS (used by OTF calibration outside synthesis)
00079   CalibratingVi2( vi::ViImplementation2 * inputVii,
00080                   const CalibratingParameters& calpar,
00081                   String msname);
00082 
00083   // From a VE pointer (used within synthesis, e.g., for solving)
00084   CalibratingVi2( vi::ViImplementation2 * inputVii,
00085                   VisEquation *ve);
00086 
00087   ~CalibratingVi2();
00088   
00089   // Report the the ViImplementation type
00090   virtual String ViiType() const { return String("Cal( ")+getVii()->ViiType()+" )"; };
00091 
00092 
00093   // Iterating management
00094   virtual void origin ();
00095   virtual void next ();
00096 
00097   // Smart corrected data/weights/flags accessors
00098   virtual void weight(Matrix<Float>& wt) const;
00099   virtual void weightSpectrum(Cube<Float>& wtsp) const;
00100   virtual void visibilityCorrected(Cube<Complex>& vis) const;
00101   virtual void flag(Cube<Bool>& flagC) const;
00102   //  virtual void flag(Matrix<Bool>& flagM) const;  // CORR-INDEP FLAGS DEPRECATED IN VI2/VB2?
00103 
00104   // Reports True in case of *Corrected columns
00105   //  (because this class provides it, even if it doesn't exist physically!)
00106   virtual Bool existsColumn (VisBufferComponent2 id) const;
00107   
00108 protected:
00109 
00110   // Correct the current VB
00111   virtual void calibrateCurrentVB() const;
00112 
00113   // Calibrater and VisEquation
00114   Calibrater cb_p;
00115   VisEquation *ve_p;   
00116 
00117   // A simple factor for testing
00118   Float corrFactor_p;  
00119 
00120   // signals whether or not correctCurrentVB has been called
00121   mutable Bool visCalibrationOK_p;
00122 
00123 };
00124 
00125 class CalVi2LayerFactory : public ViiLayerFactory {
00126 
00127  public:
00128 
00129   CalVi2LayerFactory(const CalibratingParameters& calpars);
00130 
00131   virtual ~CalVi2LayerFactory () {}
00132 
00133  protected:
00134 
00135   // CalVi2-specific layer-creater
00136   //   
00137   virtual ViImplementation2 * createInstance (ViImplementation2* vii0) const;
00138 
00139   // Store a copy of the parameters
00140   const CalibratingParameters calpars_;
00141 
00142 
00143 };
00144 
00145 class CalSolvingVi2 : public vi::CalibratingVi2
00146 {
00147 
00148 public:
00149 
00150   CalSolvingVi2( vi::ViImplementation2 * inputVii,
00151                  const CalibratingParameters& calpar);
00152 
00153   CalSolvingVi2( vi::ViImplementation2 * inputVii,
00154                  const CalibratingParameters& calpar,
00155                  String msname);
00156 
00157   CalSolvingVi2( vi::ViImplementation2 * inputVii,
00158                  VisEquation *ve);
00159 
00160   ~CalSolvingVi2();
00161 
00162   // Report the the ViImplementation type
00163   virtual String ViiType() const { return String("CalForSolve( ")+getVii()->ViiType()+" )"; };
00164 
00165   // Cal solving also involve modified model data
00166   virtual void visibilityModel(Cube<Complex>& vis) const;
00167   
00168 private:
00169 
00170   // specialized cal application for solving
00171   virtual void calibrateCurrentVB() const;
00172 
00173 };
00174 
00175 
00176 class CalSolvingVi2LayerFactory : public CalVi2LayerFactory {
00177 
00178  public:
00179 
00180   CalSolvingVi2LayerFactory(const CalibratingParameters& calpars);
00181 
00182   virtual ~CalSolvingVi2LayerFactory () {}
00183 
00184  protected:
00185 
00186   // CalSolvingVi2-specific layer-creater
00187   virtual ViImplementation2 * createInstance (ViImplementation2* vii0) const;
00188 
00189 };
00190 
00191 class CalSolvingVi2LayerFactoryByVE : public ViiLayerFactory {
00192 
00193  public:
00194 
00195   CalSolvingVi2LayerFactoryByVE(VisEquation* ve);  // From a VE pointer in calling scope
00196 
00197   virtual ~CalSolvingVi2LayerFactoryByVE () {}
00198 
00199  protected:
00200 
00201   // CalSolvingVi2-specific layer-creater
00202   virtual ViImplementation2 * createInstance (ViImplementation2* vii0) const;
00203 
00204  private:
00205   
00206   VisEquation *ve_p;
00207 
00208 };
00209 
00210 
00211 
00212 
00213 } //# NAMESPACE VI - END
00214 } //# NAMESPACE CASA - END
00215 
00216 
00217 #endif /* CalibratingVi2_H_ */
00218 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1