LCOV - code coverage report
Current view: top level - msvis/MSVis - VisBuffGroup.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 57 0.0 %
Date: 2024-10-09 13:55:54 Functions: 0 6 0.0 %

          Line data    Source code
       1             : //# VisBuffGroup.cc: Implementation of VisBuffGroup.h
       2             : //# Copyright (C) 2011
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This library is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU Library General Public License as published by
       7             : //# the Free Software Foundation; either version 2 of the License, or (at your
       8             : //# option) any later version.
       9             : //#
      10             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      11             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      13             : //# License for more details.
      14             : //#
      15             : //# You should have received a copy of the GNU Library General Public License
      16             : //# along with this library; if not, write to the Free Software Foundation,
      17             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed as follows:
      20             : //#        Internet email: casa-feedback@nrao.edu.
      21             : //#        Postal address: AIPS++ Project Office
      22             : //#                        National Radio Astronomy Observatory
      23             : //#                        520 Edgemont Road
      24             : //#                        Charlottesville, VA 22903-2475 USA
      25             : //#
      26             : //----------------------------------------------------------------------------
      27             : 
      28             : #include <msvis/MSVis/VisBuffGroup.h>
      29             : #include <casacore/casa/Exceptions/Error.h>
      30             : #include <casacore/casa/Logging/LogIO.h>
      31             : 
      32             : using namespace casacore;
      33             : namespace casa { //# NAMESPACE CASA - BEGIN
      34             : 
      35           0 : VisBuffGroup::VisBuffGroup() :
      36           0 :     nBuf_p(0),
      37           0 :     VB_p()
      38             : {
      39           0 :   endChunk_p.resize(0);
      40           0 : }
      41             : 
      42           0 : VisBuffGroup::~VisBuffGroup()
      43             : {
      44             :   // Null default destructor
      45             : 
      46             :   // Delete all VBs.
      47           0 :   for(uInt i = 0; i < nBuf_p; ++i)
      48           0 :     if(VB_p[i])
      49           0 :       delete VB_p[i];
      50             : 
      51           0 :   VB_p.resize(0);
      52           0 : }
      53             : 
      54           0 : Bool VisBuffGroup::store(const VisBuffer& vb)
      55             : {
      56             :   // Int spw=vb.spectralWindow();
      57             :   // Int fld=vb.fieldId();
      58             :   // Int ibuf=spwfldids_p(spw,fld);
      59             : 
      60           0 :   LogIO os(LogOrigin("VisBuffGroup", "store"));
      61           0 :   uInt ibuf = nBuf_p;
      62           0 :   Bool retval = false;
      63             : 
      64             :   // realize channel shape inside vb
      65           0 :   vb.nChannel();
      66             :   
      67             :   try{
      68           0 :     VB_p.resize(nBuf_p + 1, false, true); // n, forceSmaller, copyElements
      69           0 :     endChunk_p.resize(nBuf_p + 1, true);   // n, copyElements
      70           0 :     VB_p[ibuf] = new VisBuffer(vb);  // The copy is detached from the VisIter.
      71           0 :     endChunk_p[ibuf] = false;           // until notified otherwise.
      72           0 :     ++nBuf_p;
      73           0 :     retval = true;
      74             :   }
      75           0 :   catch(AipsError x){
      76             :     os << LogIO::SEVERE
      77             :        << "Error " << x.getMesg() << " storing a VisBuffer."
      78           0 :        << LogIO::POST;
      79           0 :   }
      80           0 :   catch(...){
      81             :     os << LogIO::SEVERE
      82             :        << "Unknown exception caught while storing a VisBuffer."
      83           0 :        << LogIO::POST;
      84           0 :   }
      85           0 :   return retval;
      86           0 : }
      87             : 
      88           0 : void VisBuffGroup::endChunk()
      89             : {
      90           0 :   endChunk_p[nBuf_p - 1] = true;
      91           0 : }
      92             : 
      93           0 : VisBuffer& VisBuffGroup::operator()(const Int buf) 
      94             : {
      95           0 :   if(buf < 0 || buf >= static_cast<Int>(nBuf_p))
      96           0 :     throw(AipsError("VisBuffGroup: operator(buf) index out of range."));
      97             : 
      98           0 :   return *(VB_p[buf]);
      99             : }
     100             : 
     101           0 : Bool VisBuffGroup::applyChanMask(Cube<Bool>& chanmaskedflags,
     102             :                                  const Vector<Bool> *chanmask,
     103             :                                  const VisBuffer& vb)
     104             : {
     105           0 :   Bool retval = true;
     106           0 :   Int chan0 = vb.channel()(0);
     107           0 :   Int nchan = vb.nChannel();
     108             :   //initialize
     109           0 :   chanmaskedflags.resize(vb.flagCube().shape());
     110           0 :   chanmaskedflags.set(false);
     111           0 :   if(sum((*chanmask)(Slice(chan0, nchan))) > 0){
     112             :     // There are some channels to mask...
     113           0 :     Vector<Bool> fr(vb.flagRow());
     114           0 :     Vector<Bool> fc;
     115           0 :     Vector<Bool> chm((*chanmask)(Slice(chan0, nchan)));
     116           0 :     uInt nr = vb.nRow();
     117           0 :     uInt ncor = vb.nCorr();
     118             : 
     119           0 :     chanmaskedflags = vb.flagCube();
     120           0 :     for(uInt irow = 0; irow < nr; ++irow){
     121           0 :       for(uInt corr = 0; corr < ncor; ++corr){
     122           0 :         if(!fr[irow]){
     123             :           //fc.reference(chanmaskedflags.xzPlane(corr).column(irow));
     124           0 :           fc.reference(chanmaskedflags.yzPlane(corr).column(irow));
     125           0 :           fc = fc || chm;
     126             :         }
     127             :       }
     128             :     }
     129           0 :   }
     130           0 :   return retval;
     131             : }
     132             : 
     133             : } //# NAMESPACE CASA - END
     134             : 

Generated by: LCOV version 1.16