LCOV - code coverage report
Current view: top level - msvis/MSVis - LayeredVi2Factory.h (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 1 1 100.0 %
Date: 2023-11-06 10:06:49 Functions: 2 2 100.0 %

          Line data    Source code
       1             : //# LayeredVi2Factory.h: Interface definition of the LayeredVi2Factory class.
       2             : //#
       3             : //#  CASA - Common Astronomy Software Applications (http://casa.nrao.edu/)
       4             : //#  Copyright (C) Associated Universities, Inc. Washington DC, USA 2011, All rights reserved.
       5             : //#  Copyright (C) European Southern Observatory, 2011, All rights reserved.
       6             : //#
       7             : //#  This library is free software; you can redistribute it and/or
       8             : //#  modify it under the terms of the GNU Lesser General Public
       9             : //#  License as published by the Free software Foundation; either
      10             : //#  version 2.1 of the License, or (at your option) any later version.
      11             : //#
      12             : //#  This library is distributed in the hope that it will be useful,
      13             : //#  but WITHOUT ANY WARRANTY, without even the implied warranty of
      14             : //#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             : //#  Lesser General Public License for more details.
      16             : //#
      17             : //#  You should have received a copy of the GNU Lesser General Public
      18             : //#  License along with this library; if not, write to the Free Software
      19             : //#  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      20             : //#  MA 02111-1307  USA
      21             : //# $Id: $
      22             : 
      23             : #ifndef LayeredVi2Factory_H_
      24             : #define LayeredVi2Factory_H_
      25             : 
      26             : // Where ViFactory interface is defined
      27             : #include <msvis/MSVis/VisibilityIterator2.h>
      28             : #include <msvis/MSVis/IteratingParameters.h>
      29             : 
      30             : #include <casacore/casa/Containers/Record.h>
      31             : 
      32             : namespace casa { //# NAMESPACE CASA - BEGIN
      33             : namespace vi { //# NAMESPACE VI - BEGIN
      34             : 
      35             : class IteratingParameters;
      36             : class AveragingParameters;
      37             : class CalibratingVi2FactoryI;
      38             : 
      39             : // <summary>
      40             : // A factory for generating ViImplementation2 layers that optionally include calibration
      41             : //  (via CalibratingVi2) and time-averaging (via AveragingTvi2).
      42             : // </summary>
      43             : //
      44             : // <use visibility=export>
      45             : //
      46             : // <prerequisite>
      47             : //   <li> <linkto class="VisibilityIterator2:description">VisibilityIterator2</linkto>
      48             : //   <li> <linkto class="CalibratingVi2:description">CalibratingVi2</linkto>
      49             : //   <li> <linkto class="AveragingTvi2:description">AveraringTvi2</linkto>
      50             : // </prerequisite>
      51             : //
      52             : // <etymology>
      53             : // Factory for layered ViImplementation2 construction
      54             : // </etymology>
      55             : //
      56             : // <synopsis>
      57             : // LayeredVi2Factory generates a Visibility Iterator implementation (ViImplementation2)
      58             : // object that can be plugged into a Visibility Iterator (VisibilityIterator2) object,
      59             : // so that the user can access the data using the Visibility Iterator interface.
      60             : // The ViImplementation2 generated by this factory consists of an underlying 
      61             : // VisibilityIteratorImpl2, and (optionally) CalibratingVi2 and AveragingTvi2 ViImplementation2s, 
      62             : // thereby supporting these operations in sequence.  When both calibration and averaging
      63             : // are invoked, calibration is hard-wired to occur first.
      64             : // </synopsis>
      65             : //
      66             : // <motivation>
      67             : // This class makes the combination of OTF calibration application and time-averaging portable,
      68             : // and available to all VisibilityIterator2 users.
      69             : // </motivation>
      70             : //
      71             : // <example>
      72             : // External usage is quite simple, and compliant with the 'normal' VI/VB framework.
      73             : //
      74             : // The user first makes objects describing the data iteration, calibration parameters,
      75             : // and averaging parameters:
      76             : //
      77             : // <srcblock>
      78             : //      IteratingParameters iterpar(60.0);  // 60s chunk interval
      79             : //
      80             : //      casacore::Float calfactor(100.0);             // a simple factor with which to multiply the data
      81             : //      casacore::Record calrec;                      //   (in leiu of full VisEquation functionality (TBD)
      82             : //      calrec.define("calfactor",calfactor); // in a casacore::Record   
      83             : //                                            
      84             : //      AveragingParameters avepar(10.0);   // 10s averaging
      85             : //
      86             : //
      87             : // </srcblock>
      88             : //
      89             : // Then these parameter objects, along with a casacore::MeasurementSet pointer, are used to make
      90             : //  a factory suitable for the generic VisibilityIterator2 ctor, which is then invoked
      91             : //
      92             : // <srcblock>
      93             : //      casacore::MeasurementSet *ms(....);   // typically from elsewhere, e.g., selected
      94             : //      LayeredVi2Factory factory(ms,&iterpar,calrec,&avepar);
      95             : //      vi::VisibilityIterator2 *visIter = new vi::VisibilityIterator2 (factory);
      96             : //      vi::VisBuffer2 *visBuffer = visIter->getVisBuffer();
      97             : // </srcblock>
      98             : //
      99             : // Once this is done one can normally iterate and access OTF calibrated and averaged data:
     100             : //
     101             : // <srcblock>
     102             : //      while (visIter->moreChunks())
     103             : //      {
     104             : //              visIter->origin();
     105             : //
     106             : //              while (visIter->more())
     107             : //              {
     108             : //
     109             : //                      // the following will have been calibrated and averaged to 10s
     110             : //                      casacore::Vector<casacore::Int> ddi = visBuffer->dataDescriptionIds();
     111             : //                      casacore::Vector<casacore::Int> antenna1 = visBuffer->antenna1();
     112             : //                      casacore::Vector<casacore::Int> antenna2 = visBuffer->antenna2();
     113             : //                      casacore::Cube<casacore::Complex> cvis = visBuffer->visCubeCorrected();
     114             : //
     115             : //                      visIter->next();
     116             : //              }
     117             : //
     118             : //              visIter->nextChunk();
     119             : //      }
     120             : // </srcblock>
     121             : //
     122             : // casacore::Notice that it is the responsibility of the application layer to delete the VisibilityIterator2
     123             : // pointer returned by the factory method. However the life cycle of the VisBuffer2 object is
     124             : // responsibility of the VisibilityIterator2 object.
     125             : //
     126             : // <srcblock>
     127             : //      delete visIter;
     128             : // </srcblock>
     129             : //
     130             : // </example>
     131             : 
     132             : 
     133             : 
     134             : class LayeredVi2Factory : public vi::ViFactory
     135             : {
     136             : 
     137             : public:
     138             : 
     139             :   // Non-calibrating version
     140             :   LayeredVi2Factory(casacore::MeasurementSet* ms,
     141             :                     IteratingParameters* iterpar,
     142             :                     AveragingParameters* avepar=0);
     143             :   // Calibrating version, via CalLib Record
     144             :   LayeredVi2Factory(casacore::MeasurementSet* ms,
     145             :                     IteratingParameters* iterpar,
     146             :                     const casacore::Record& calrec,
     147             :                     AveragingParameters* avepar=0);
     148             :   // Calibrating version, vis CalLib casacore::String (filename or casacore::String)
     149             :   LayeredVi2Factory(casacore::MeasurementSet* ms,
     150             :                     IteratingParameters* iterpar,
     151             :                     const casacore::String& callib,
     152             :                     AveragingParameters* avepar=0);
     153             :   ~LayeredVi2Factory();
     154             : 
     155             :   vi::ViImplementation2 * createVi () const;
     156             :   vi::ViImplementation2 * createVi (vi::ViImplementation2 *) const {throw(casacore::AipsError("NYI!"));};  // NYI
     157             : 
     158             : private:
     159             : 
     160             :   casacore::MeasurementSet* ms_p;
     161             : 
     162             :   vi::IteratingParameters* iterpar_p;
     163             :   vi::AveragingParameters* avepar_p;
     164             :   casacore::Bool doCal_p;
     165             :   casacore::String callib_p;
     166             :   casacore::Record calrec_p;
     167             :   casacore::Int nlayer_p;
     168             :   CalibratingVi2FactoryI* calvi2factory_p;
     169             : 
     170             : };
     171             : 
     172             : 
     173             : 
     174             : //////////////////////////////////////////////////////////////////////
     175             : //
     176             : // Class VisIterImpl2LayerFactory
     177             : //
     178             : //  (Ideally, this should be in ViiLayerFactory.h, but it has include problems there)
     179             : //
     180             : class VisIterImpl2LayerFactory : public ViiLayerFactory {
     181             : 
     182             :  public:
     183             :   
     184             :     VisIterImpl2LayerFactory(casacore::MeasurementSet* ms,
     185             :                              const IteratingParameters& pars,
     186             :                              bool writable,
     187             :                              bool useMSIter2=false);
     188             : 
     189             :     VisIterImpl2LayerFactory(casacore::MeasurementSet * ms,
     190             :                              const SortColumns & chunkSortColumns,
     191             :                              const SortColumns & subchunkSortColumns,
     192             :                              bool writable);
     193             : 
     194             :   void setFrequencySelections(std::shared_ptr<FrequencySelections> selections);
     195             : 
     196        2608 :   virtual ~VisIterImpl2LayerFactory () {}
     197             : 
     198             :  protected:
     199             : 
     200             :   // VisibilityIteratorImpl2-specific layer-creater
     201             :   //   
     202             :   virtual ViImplementation2 * createInstance (ViImplementation2* vii0) const;
     203             : 
     204             :  private:
     205             : 
     206             :   // Pointer to _external_ ms  (support only one, for now)
     207             :   casacore::MeasurementSet* ms_;
     208             : 
     209             :   // Store a copy of the parameters
     210             :   const vi::IteratingParameters pars_;
     211             : 
     212             :   // Should VisibilityIteratorImpl2 be generated w/ write-permission
     213             :   bool writable_;
     214             : 
     215             :   // Control use of ~experimental MSIter2, which has smarter time iteration
     216             :   bool useMSIter2_;
     217             : 
     218             :   // Whether full sorting specification has been configured
     219             :   bool fullSortingSpecification_p;
     220             : 
     221             :   //Frequency selections to be applied to the generated visibility iterator 
     222             :   std::shared_ptr<FrequencySelections> frequencySelections_p;
     223             : 
     224             :   // Sorting specification for chunks
     225             :   SortColumns chunkSortColumns_p;
     226             : 
     227             :   // Sorting specification for subchunks
     228             :   SortColumns subchunkSortColumns_p;
     229             : 
     230             : };
     231             : 
     232             : 
     233             : 
     234             : } //# NAMESPACE VI - END
     235             : } //# NAMESPACE CASA - END
     236             : 
     237             : 
     238             : #endif /* LayeredVi2Factory_H_ */
     239             : 

Generated by: LCOV version 1.16