LCOV - code coverage report
Current view: top level - msvis/MSVis - LayeredVi2Factory.cc (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 0 73 0.0 %
Date: 2023-11-02 14:27:30 Functions: 0 10 0.0 %

          Line data    Source code
       1             : //# LayeredVi2Factory.cc: Implementation 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             : #include <msvis/MSVis/LayeredVi2Factory.h>
      24             : 
      25             : 
      26             : #include <stdcasa/UtilJ.h>
      27             : #include <msvis/MSVis/VisibilityIterator2.h>
      28             : #include <msvis/MSVis/VisibilityIteratorImpl2.h>
      29             : #include <msvis/MSVis/VisBuffer2.h>
      30             : #include <msvis/MSVis/AveragingTvi2.h>
      31             : #include <msvis/MSVis/IteratingParameters.h>
      32             : #include <msvis/MSVis/AveragingVi2Factory.h>
      33             : #include <msvis/MSVis/CalibratingVi2FactoryI.h>
      34             : #include <msvis/MSVis/ViFrequencySelection.h>
      35             : #include <casacore/casa/BasicSL/String.h>
      36             : 
      37             : using namespace casacore;
      38             : namespace casa { //# NAMESPACE CASA - BEGIN
      39             : namespace vi { //# NAMESPACE VI - BEGIN
      40             : 
      41             : 
      42             : // -----------------------------------------------------------------------
      43           0 : LayeredVi2Factory::LayeredVi2Factory(MeasurementSet* ms,
      44             :                                      IteratingParameters* iterpar,
      45           0 :                                      AveragingParameters* avepar) :
      46             :   ms_p(ms),
      47             :   iterpar_p(iterpar),
      48             :   avepar_p(avepar),
      49             :   doCal_p(false),
      50             :   callib_p(""),
      51             :   calrec_p(),  
      52             :   nlayer_p(1),
      53           0 :   calvi2factory_p(0)
      54             : {
      55             : 
      56             :   // Count requested layers
      57           0 :   if (avepar_p) ++nlayer_p;
      58             : 
      59           0 : }
      60             : // -----------------------------------------------------------------------
      61           0 : LayeredVi2Factory::LayeredVi2Factory(MeasurementSet* ms,
      62             :                                      IteratingParameters* iterpar,
      63             :                                      const Record& calrec,
      64           0 :                                      AveragingParameters* avepar) :
      65             :   ms_p(ms),
      66             :   iterpar_p(iterpar),
      67             :   avepar_p(avepar),
      68             :   doCal_p(false),
      69             :   callib_p(""),
      70             :   calrec_p(calrec),  // This ctor, by Record _only_
      71             :   nlayer_p(1),
      72           0 :   calvi2factory_p(0)
      73             : {
      74             : 
      75             :   // Count requested layers
      76           0 :   if (avepar_p) ++nlayer_p;
      77             : 
      78             :   // ...and arrange for calibration, if necessary
      79           0 :   if (calrec_p.nfields()>0) {
      80           0 :     ++nlayer_p;  
      81           0 :     doCal_p=true;
      82             : 
      83             :     // Set up the CalibratingVi2Factory (via Record)
      84           0 :     calvi2factory_p = CalibratingVi2FactoryI::generate();
      85           0 :     calvi2factory_p->initialize(ms,calrec);
      86             :   }
      87             : 
      88           0 : }
      89             : 
      90             : // -----------------------------------------------------------------------
      91           0 : LayeredVi2Factory::LayeredVi2Factory(MeasurementSet* ms,
      92             :                                      IteratingParameters* iterpar,
      93             :                                      const String& callib,
      94           0 :                                      AveragingParameters* avepar) :
      95             :   ms_p(ms),
      96             :   iterpar_p(iterpar),
      97             :   avepar_p(avepar),
      98             :   doCal_p(false),
      99             :   callib_p(callib),    // This ctor, by String _only_
     100             :   calrec_p(),
     101             :   nlayer_p(1),
     102           0 :   calvi2factory_p(0)
     103             : {
     104             : 
     105             :   // Count requested layers
     106           0 :   if (avepar_p) ++nlayer_p;
     107             : 
     108             : 
     109           0 :   if (callib_p.length()>0) {
     110           0 :     ++nlayer_p;  
     111           0 :     doCal_p=true;  // Calibration is turned on
     112             : 
     113             :     // Set up the CalibratingVi2Factory (via String)
     114           0 :     calvi2factory_p = CalibratingVi2FactoryI::generate();
     115           0 :     calvi2factory_p->initialize(ms,callib_p);
     116             :   }
     117             : 
     118           0 : }
     119             : 
     120             : // -----------------------------------------------------------------------
     121           0 : LayeredVi2Factory::~LayeredVi2Factory() {
     122             : 
     123             :   // Delete the CalibratingVi2FactorI*, if present
     124           0 :   if (calvi2factory_p)
     125           0 :     delete calvi2factory_p;
     126             : 
     127           0 : }
     128             : 
     129             : 
     130             : // -----------------------------------------------------------------------
     131           0 : vi::ViImplementation2 * LayeredVi2Factory::createVi () const
     132             : {
     133             : 
     134             :   //  cout << "MSVis::LayeredVi2Factor::createVi" << endl;
     135             : 
     136             : 
     137             :   // A Vector of Vii's to fill up and delegate, will return the last one
     138           0 :   Vector<vi::ViImplementation2*> viis(nlayer_p);
     139             : 
     140             :   // The bottom layer is the standard vii2 that does I/O
     141           0 :   Int ilayer(0);
     142           0 :   viis[ilayer]= new vi::VisibilityIteratorImpl2 (Block<const MeasurementSet*>(1,ms_p),
     143           0 :                                                  iterpar_p->getSortColumns(),
     144           0 :                                                  iterpar_p->getChunkInterval(),
     145           0 :                                                  true); // writable!  (hardwired?)
     146             :   
     147             :   // TBD: consider if this is the layer where weight scaling should be applied?
     148           0 :   viis[ilayer]->setWeightScaling(iterpar_p->getWeightScaling());
     149             : 
     150             :   // If calibration requested
     151           0 :   if (doCal_p) {
     152           0 :     ++ilayer;
     153           0 :     Assert(ilayer<nlayer_p);
     154             :     // Call the factory
     155           0 :     viis[ilayer] = calvi2factory_p->createVi(viis[ilayer-1]);
     156             :   }
     157             : 
     158             :   // If (time) averaging requested
     159           0 :   if (avepar_p) {
     160           0 :     ++ilayer;
     161           0 :     Assert(ilayer<nlayer_p);
     162             :     // TBD: update the AveragingVi2Factory to permit layered createVi...
     163           0 :     viis[ilayer] = new AveragingTvi2(viis[ilayer-1],*avepar_p);
     164             :   }
     165             : 
     166             :   // Must be at the last layer now
     167           0 :   Assert((nlayer_p-ilayer)==1);
     168           0 :   Assert(viis[nlayer_p-1]);
     169             : 
     170             :   // Return outermost ViImplementation2 layer
     171           0 :   return viis[nlayer_p-1];
     172             : 
     173             : }
     174             : 
     175             : //////////////////////////////////////////////////////////////////////
     176             : //
     177             : // Class VisIterImpl2LayerFactory
     178             : //
     179           0 : VisIterImpl2LayerFactory::VisIterImpl2LayerFactory(MeasurementSet* ms,
     180             :                                                    const IteratingParameters& pars,
     181             :                                                    Bool writable,
     182           0 :                                                    Bool useMSIter2)
     183             : : ViiLayerFactory(),
     184             :   ms_(ms),
     185             :   pars_(pars),
     186             :   writable_(writable),
     187             :   useMSIter2_(useMSIter2),
     188           0 :   fullSortingSpecification_p(false)
     189           0 : {}
     190             :   
     191           0 : VisIterImpl2LayerFactory::VisIterImpl2LayerFactory(casacore::MeasurementSet * ms,
     192             :                                                    const SortColumns & chunkSortColumns,
     193             :                                                    const SortColumns & subchunkSortColumns,
     194           0 :                                                    bool writable)
     195             : : ViiLayerFactory(),
     196             :   ms_(ms),
     197             :   writable_(writable),
     198             :   useMSIter2_(false),
     199             :   fullSortingSpecification_p(true),
     200             :   chunkSortColumns_p(chunkSortColumns),
     201           0 :   subchunkSortColumns_p(subchunkSortColumns)
     202           0 : {}
     203             : 
     204           0 : void VisIterImpl2LayerFactory::setFrequencySelections(std::shared_ptr<FrequencySelections> selections)
     205             : {
     206           0 :   frequencySelections_p = selections;
     207           0 : }
     208             : 
     209             : // VisIterImpl2-specific layer-creater
     210           0 : ViImplementation2 * VisIterImpl2LayerFactory::createInstance (ViImplementation2* /*vii0*/) const {
     211             : 
     212             :   // No deeper layers   (Uncomment and figure out pesky warning!)
     213             :   //  Assert(!vii0);
     214             :   
     215             :   // Make it and return it
     216             :   ViImplementation2 *vii;
     217           0 :   if(fullSortingSpecification_p)
     218           0 :     vii = new VisibilityIteratorImpl2(Block<const MeasurementSet*>(1,ms_),
     219           0 :                                       chunkSortColumns_p,
     220           0 :                                       subchunkSortColumns_p,
     221           0 :                                       writable_);
     222             : 
     223             :   else
     224           0 :     vii = new VisibilityIteratorImpl2(Block<const MeasurementSet*>(1,ms_),
     225           0 :                                       pars_.getSortColumns(),
     226           0 :                                       pars_.getChunkInterval(),
     227           0 :                                       writable_,
     228           0 :                                       useMSIter2_);
     229             :   
     230           0 :   if(frequencySelections_p)
     231           0 :     vii->setFrequencySelections(*frequencySelections_p);
     232             : 
     233           0 :   return vii;
     234             : }
     235             : 
     236             : 
     237             : 
     238             : 
     239             : } //# NAMESPACE VI - END
     240             : } //# NAMESPACE CASA - END
     241             : 
     242             : 

Generated by: LCOV version 1.16