LCOV - code coverage report
Current view: top level - msvis/MSVis/statistics - Vi2StatsFlagsIterator.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 40 68 58.8 %
Date: 2024-11-06 17:42:47 Functions: 9 17 52.9 %

          Line data    Source code
       1             : //# Copyright (C) 1996,1997,1998,1999,2000,2002,2003,2015
       2             : //# Associated Universities, Inc. Washington DC, USA.
       3             : //#
       4             : //# This library is free software; you can redistribute it and/or modify it
       5             : //# under the terms of the GNU Library General Public License as published by
       6             : //# the Free Software Foundation; either version 2 of the License, or (at your
       7             : //# option) any later version.
       8             : //#
       9             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      10             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      11             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      12             : //# License for more details.
      13             : //#
      14             : //# You should have received a copy of the GNU Library General Public License
      15             : //# along with this library; if not, write to the Free Software Foundation,
      16             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      17             : //#
      18             : //# Correspondence concerning AIPS++ should be addressed as follows:
      19             : //#        Internet email: casa-feedback@nrao.edu.
      20             : //#        Postal address: AIPS++ Project Office
      21             : //#                        National Radio Astronomy Observatory
      22             : //#                        520 Edgemont Road
      23             : //#                        Charlottesville, VA 22903-2475 USA
      24             : //#
      25             : //
      26             : // Data provider mask iterators, based on a flag column.
      27             : //
      28             : #include <casacore/casa/Arrays/Cube.h>
      29             : #include <casacore/casa/Arrays/Vector.h>
      30             : #include <msvis/MSVis/statistics/Vi2StatsFlagsIterator.h>
      31             : 
      32             : using namespace casacore;
      33             : namespace casa {
      34             : 
      35      108941 : Vi2StatsFlagsCubeIterator::Vi2StatsFlagsCubeIterator(vi::VisBuffer2 *vb2)
      36             : {
      37      108941 :         if (vb2->existsColumn(vi::VisBufferComponent2::FlagCube)) {
      38      108941 :                 flags_array = &vb2->flagCube();
      39      108941 :                 expansion_factor = 1;
      40             :         } else {
      41           0 :                 flags_array = &vb2->flagRow();
      42           0 :                 expansion_factor = vb2->nChannels() * vb2->nCorrelations();
      43             :         }
      44      108941 :         flags_iter = flags_array->begin();
      45      108941 :         end_iter = flags_array->end();
      46      108941 :         replicate_count = expansion_factor;
      47      108941 : }
      48             : 
      49     5268400 : Vi2StatsFlagsCubeIterator::Vi2StatsFlagsCubeIterator()
      50     5268400 :         : Vi2StatsFlagsIterator() {}
      51             : 
      52             : Vi2StatsFlagsCubeIterator&
      53  4736199214 : Vi2StatsFlagsCubeIterator::operator++()
      54             : {
      55  4736199214 :         --replicate_count;
      56  4736199214 :         if (replicate_count == 0) {
      57  4736199214 :                 ++flags_iter;
      58  4736199214 :                 replicate_count = expansion_factor;
      59             :         }
      60  4736199214 :         return *this;
      61             : }
      62             : 
      63             : Vi2StatsFlagsCubeIterator
      64           0 : Vi2StatsFlagsCubeIterator::operator++(int)
      65             : {
      66           0 :         Vi2StatsFlagsCubeIterator tmp(*this);
      67           0 :         operator++();
      68           0 :         return tmp;
      69           0 : }
      70             : 
      71             : bool
      72           0 : Vi2StatsFlagsCubeIterator::operator==(const Vi2StatsFlagsCubeIterator& rhs)
      73             : {
      74           0 :         return (flags_iter == rhs.flags_iter
      75           0 :                 && replicate_count == rhs.replicate_count);
      76             : }
      77             : 
      78             : bool
      79           0 : Vi2StatsFlagsCubeIterator::operator!=(const Vi2StatsFlagsCubeIterator& rhs)
      80             : {
      81           0 :         return (flags_iter != rhs.flags_iter
      82           0 :                 || replicate_count != rhs.replicate_count);
      83             : }
      84             : 
      85             : Bool
      86   481839218 : Vi2StatsFlagsCubeIterator::operator*() {
      87             :         // Since this class is intended to be used in a StatsDataProvider instance,
      88             :         // and StatisticsAlgorithm classes expect a "True" mask value to indicate a
      89             :         // valid sample, the value returned by this method must be the inverted
      90             :         // value of the current flag value.
      91   481839218 :         return !*flags_iter;
      92             : }
      93             : 
      94             : bool
      95           0 : Vi2StatsFlagsCubeIterator::atEnd()
      96             : {
      97           0 :         return flags_iter == end_iter;
      98             : }
      99             : 
     100             : 
     101             : 
     102       74910 : Vi2StatsFlagsRowIterator::Vi2StatsFlagsRowIterator(vi::VisBuffer2 *vb2)
     103             : {
     104       74910 :         if (vb2->existsColumn(vi::VisBufferComponent2::FlagCube)) {
     105       74910 :                 flags_array = &vb2->flagCube();
     106       74910 :                 reduction_factor = vb2->nChannels() * vb2->nCorrelations();
     107             :         } else {
     108           0 :                 flags_array = &vb2->flagRow();
     109           0 :                 reduction_factor = 1;
     110             :         }
     111       74910 :         flags_iter = flags_array->begin();
     112       74910 :         end_iter = flags_array->end();
     113       74910 :         prepareNextRow();
     114       74910 : }
     115             : 
     116     2431680 : Vi2StatsFlagsRowIterator::Vi2StatsFlagsRowIterator()
     117     2431680 :         : Vi2StatsFlagsIterator() {}
     118             : 
     119             : Vi2StatsFlagsRowIterator&
     120     1992285 : Vi2StatsFlagsRowIterator::operator++()
     121             : {
     122     1992285 :         prepareNextRow();
     123     1992285 :         return *this;
     124             : }
     125             : 
     126             : Vi2StatsFlagsRowIterator
     127           0 : Vi2StatsFlagsRowIterator::operator++(int)
     128             : {
     129           0 :         Vi2StatsFlagsRowIterator tmp(*this);
     130           0 :         operator++();
     131           0 :         return tmp;
     132           0 : }
     133             : 
     134             : bool
     135           0 : Vi2StatsFlagsRowIterator::operator==(const Vi2StatsFlagsRowIterator& rhs)
     136             : {
     137           0 :         return flags_iter == rhs.flags_iter;
     138             : }
     139             : 
     140             : bool
     141           0 : Vi2StatsFlagsRowIterator::operator!=(const Vi2StatsFlagsRowIterator& rhs)
     142             : {
     143           0 :         return flags_iter != rhs.flags_iter;
     144             : }
     145             : 
     146             : Bool
     147     1992285 : Vi2StatsFlagsRowIterator::operator*() {
     148             :         // Since this class is intended to be used in a StatsDataProvider instance,
     149             :         // and StatisticsAlgorithm classes expect a "True" mask value to indicate a
     150             :         // valid sample, the value returned by this method must be the inverted
     151             :         // value of the current flag value.
     152     1992285 :         return !rowFlag;
     153             : }
     154             : 
     155             : bool
     156           0 : Vi2StatsFlagsRowIterator::atEnd()
     157             : {
     158           0 :         return flags_iter == end_iter;
     159             : }
     160             : 
     161             : void
     162     2067195 : Vi2StatsFlagsRowIterator::prepareNextRow() {
     163     2067195 :         rowFlag = *flags_iter;
     164    36112278 :         for (uInt n = reduction_factor - 1; n > 0; --n) {
     165    34045083 :                 ++flags_iter;
     166    34045083 :                 rowFlag = rowFlag && *flags_iter;
     167             :         }
     168     2067195 :         ++flags_iter;
     169     2067195 : }
     170             : 
     171             : using namespace casacore;
     172             : } // namespace casa

Generated by: LCOV version 1.16