LayeredVi2Factory.h

Go to the documentation of this file.
00001 //# LayeredVi2Factory.h: Interface definition of the LayeredVi2Factory 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 LayeredVi2Factory_H_
00024 #define LayeredVi2Factory_H_
00025 
00026 // Where ViFactory interface is defined
00027 #include <msvis/MSVis/VisibilityIterator2.h>
00028 #include <msvis/MSVis/IteratingParameters.h>
00029 
00030 #include <casa/Containers/Record.h>
00031 
00032 namespace casa { //# NAMESPACE CASA - BEGIN
00033 namespace vi { //# NAMESPACE VI - BEGIN
00034 
00035 class IteratingParameters;
00036 class AveragingParameters;
00037 class CalibratingVi2FactoryI;
00038 
00039 // <summary>
00040 // A factory for generating ViImplementation2 layers that optionally include calibration
00041 //  (via CalibratingVi2) and time-averaging (via AveragingTvi2).
00042 // </summary>
00043 //
00044 // <use visibility=export>
00045 //
00046 // <prerequisite>
00047 //   <li> <linkto class="VisibilityIterator2:description">VisibilityIterator2</linkto>
00048 //   <li> <linkto class="CalibratingVi2:description">CalibratingVi2</linkto>
00049 //   <li> <linkto class="AveragingTvi2:description">AveraringTvi2</linkto>
00050 // </prerequisite>
00051 //
00052 // <etymology>
00053 // Factory for layered ViImplementation2 construction
00054 // </etymology>
00055 //
00056 // <synopsis>
00057 // LayeredVi2Factory generates a Visibility Iterator implementation (ViImplementation2)
00058 // object that can be plugged into a Visibility Iterator (VisibilityIterator2) object,
00059 // so that the user can access the data using the Visibility Iterator interface.
00060 // The ViImplementation2 generated by this factory consists of an underlying 
00061 // VisibilityIteratorImpl2, and (optionally) CalibratingVi2 and AveragingTvi2 ViImplementation2s, 
00062 // thereby supporting these operations in sequence.  When both calibration and averaging
00063 // are invoked, calibration is hard-wired to occur first.
00064 // </synopsis>
00065 //
00066 // <motivation>
00067 // This class makes the combination of OTF calibration application and time-averaging portable,
00068 // and available to all VisibilityIterator2 users.
00069 // </motivation>
00070 //
00071 // <example>
00072 // External usage is quite simple, and compliant with the 'normal' VI/VB framework.
00073 //
00074 // The user first makes objects describing the data iteration, calibration parameters,
00075 // and averaging parameters:
00076 //
00077 // <srcblock>
00078 //      IteratingParameters iterpar(60.0);  // 60s chunk interval
00079 //
00080 //      Float calfactor(100.0);             // a simple factor with which to multiply the data
00081 //      Record calrec;                      //   (in leiu of full VisEquation functionality (TBD)
00082 //      calrec.define("calfactor",calfactor); // in a Record   
00083 //                                            
00084 //      AveragingParameters avepar(10.0);   // 10s averaging
00085 //
00086 //
00087 // </srcblock>
00088 //
00089 // Then these parameter objects, along with a MeasurementSet pointer, are used to make
00090 //  a factory suitable for the generic VisibilityIterator2 ctor, which is then invoked
00091 //
00092 // <srcblock>
00093 //      MeasurementSet *ms(....);   // typically from elsewhere, e.g., selected
00094 //      LayeredVi2Factory factory(ms,&iterpar,calrec,&avepar);
00095 //      vi::VisibilityIterator2 *visIter = new vi::VisibilityIterator2 (factory);
00096 //      vi::VisBuffer2 *visBuffer = visIter->getVisBuffer();
00097 // </srcblock>
00098 //
00099 // Once this is done one can normally iterate and access OTF calibrated and averaged data:
00100 //
00101 // <srcblock>
00102 //      while (visIter->moreChunks())
00103 //      {
00104 //              visIter->origin();
00105 //
00106 //              while (visIter->more())
00107 //              {
00108 //
00109 //                      // the following will have been calibrated and averaged to 10s
00110 //                      Vector<Int> ddi = visBuffer->dataDescriptionIds();
00111 //                      Vector<Int> antenna1 = visBuffer->antenna1();
00112 //                      Vector<Int> antenna2 = visBuffer->antenna2();
00113 //                      Cube<Complex> cvis = visBuffer->visCubeCorrected();
00114 //
00115 //                      visIter->next();
00116 //              }
00117 //
00118 //              visIter->nextChunk();
00119 //      }
00120 // </srcblock>
00121 //
00122 // Notice that it is the responsibility of the application layer to delete the VisibilityIterator2
00123 // pointer returned by the factory method. However the life cycle of the VisBuffer2 object is
00124 // responsibility of the VisibilityIterator2 object.
00125 //
00126 // <srcblock>
00127 //      delete visIter;
00128 // </srcblock>
00129 //
00130 // </example>
00131 
00132 
00133 
00134 class LayeredVi2Factory : public vi::ViFactory
00135 {
00136 
00137 public:
00138 
00139   // Non-calibrating version
00140   LayeredVi2Factory(MeasurementSet* ms,
00141                     IteratingParameters* iterpar,
00142                     AveragingParameters* avepar=0);
00143   // Calibrating version, via CalLib Record
00144   LayeredVi2Factory(MeasurementSet* ms,
00145                     IteratingParameters* iterpar,
00146                     const Record& calrec,
00147                     AveragingParameters* avepar=0);
00148   // Calibrating version, vis CalLib String (filename or String)
00149   LayeredVi2Factory(MeasurementSet* ms,
00150                     IteratingParameters* iterpar,
00151                     const String& callib,
00152                     AveragingParameters* avepar=0);
00153   ~LayeredVi2Factory();
00154 
00155   vi::ViImplementation2 * createVi () const;
00156   vi::ViImplementation2 * createVi (vi::ViImplementation2 *) const {throw(AipsError("NYI!"));};  // NYI
00157 
00158 private:
00159 
00160   MeasurementSet* ms_p;
00161 
00162   vi::IteratingParameters* iterpar_p;
00163   vi::AveragingParameters* avepar_p;
00164   Bool doCal_p;
00165   String callib_p;
00166   Record calrec_p;
00167   Int nlayer_p;
00168   CalibratingVi2FactoryI* calvi2factory_p;
00169 
00170 };
00171 
00172 
00173 
00175 //
00176 // Class VisIterImpl2LayerFactory
00177 //
00178 //  (Ideally, this should be in ViiLayerFactory.h, but it has include problems there)
00179 //
00180 class VisIterImpl2LayerFactory : public ViiLayerFactory {
00181 
00182  public:
00183   
00184   VisIterImpl2LayerFactory(MeasurementSet* ms,
00185                            const IteratingParameters& pars,
00186                            Bool writable);
00187 
00188   virtual ~VisIterImpl2LayerFactory () {}
00189 
00190  protected:
00191 
00192   // VisibilityIteratorImpl2-specific layer-creater
00193   //   
00194   virtual ViImplementation2 * createInstance (ViImplementation2* vii0) const;
00195 
00196  private:
00197 
00198   // Pointer to _external_ ms  (support only one, for now)
00199   MeasurementSet* ms_;
00200   
00201   // Store a copy of the parameters
00202   const vi::IteratingParameters pars_;
00203   
00204   // Should VisibilityIteratorImpl2 be generated w/ write-permission
00205   Bool writable_;
00206   
00207 };
00208 
00209 
00210 
00211 } //# NAMESPACE VI - END
00212 } //# NAMESPACE CASA - END
00213 
00214 
00215 #endif /* LayeredVi2Factory_H_ */
00216 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1