LCOV - code coverage report
Current view: top level - msvis/MSVis/statistics - Vi2StatsFlagsIterator.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 18 68 26.5 %
Date: 2024-10-04 18:58:15 Functions: 4 17 23.5 %

          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        2022 : Vi2StatsFlagsCubeIterator::Vi2StatsFlagsCubeIterator(vi::VisBuffer2 *vb2)
      36             : {
      37        2022 :         if (vb2->existsColumn(vi::VisBufferComponent2::FlagCube)) {
      38        2022 :                 flags_array = &vb2->flagCube();
      39        2022 :                 expansion_factor = 1;
      40             :         } else {
      41           0 :                 flags_array = &vb2->flagRow();
      42           0 :                 expansion_factor = vb2->nChannels() * vb2->nCorrelations();
      43             :         }
      44        2022 :         flags_iter = flags_array->begin();
      45        2022 :         end_iter = flags_array->end();
      46        2022 :         replicate_count = expansion_factor;
      47        2022 : }
      48             : 
      49      517632 : Vi2StatsFlagsCubeIterator::Vi2StatsFlagsCubeIterator()
      50      517632 :         : Vi2StatsFlagsIterator() {}
      51             : 
      52             : Vi2StatsFlagsCubeIterator&
      53     3124056 : Vi2StatsFlagsCubeIterator::operator++()
      54             : {
      55     3124056 :         --replicate_count;
      56     3124056 :         if (replicate_count == 0) {
      57     3124056 :                 ++flags_iter;
      58     3124056 :                 replicate_count = expansion_factor;
      59             :         }
      60     3124056 :         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     1444056 : 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     1444056 :         return !*flags_iter;
      92             : }
      93             : 
      94             : bool
      95           0 : Vi2StatsFlagsCubeIterator::atEnd()
      96             : {
      97           0 :         return flags_iter == end_iter;
      98             : }
      99             : 
     100             : 
     101             : 
     102           0 : Vi2StatsFlagsRowIterator::Vi2StatsFlagsRowIterator(vi::VisBuffer2 *vb2)
     103             : {
     104           0 :         if (vb2->existsColumn(vi::VisBufferComponent2::FlagCube)) {
     105           0 :                 flags_array = &vb2->flagCube();
     106           0 :                 reduction_factor = vb2->nChannels() * vb2->nCorrelations();
     107             :         } else {
     108           0 :                 flags_array = &vb2->flagRow();
     109           0 :                 reduction_factor = 1;
     110             :         }
     111           0 :         flags_iter = flags_array->begin();
     112           0 :         end_iter = flags_array->end();
     113           0 :         prepareNextRow();
     114           0 : }
     115             : 
     116           0 : Vi2StatsFlagsRowIterator::Vi2StatsFlagsRowIterator()
     117           0 :         : Vi2StatsFlagsIterator() {}
     118             : 
     119             : Vi2StatsFlagsRowIterator&
     120           0 : Vi2StatsFlagsRowIterator::operator++()
     121             : {
     122           0 :         prepareNextRow();
     123           0 :         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           0 : 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           0 :         return !rowFlag;
     153             : }
     154             : 
     155             : bool
     156           0 : Vi2StatsFlagsRowIterator::atEnd()
     157             : {
     158           0 :         return flags_iter == end_iter;
     159             : }
     160             : 
     161             : void
     162           0 : Vi2StatsFlagsRowIterator::prepareNextRow() {
     163           0 :         rowFlag = *flags_iter;
     164           0 :         for (uInt n = reduction_factor - 1; n > 0; --n) {
     165           0 :                 ++flags_iter;
     166           0 :                 rowFlag = rowFlag && *flags_iter;
     167             :         }
     168           0 :         ++flags_iter;
     169           0 : }
     170             : 
     171             : using namespace casacore;
     172             : } // namespace casa

Generated by: LCOV version 1.16