LCOV - code coverage report
Current view: top level - msvis/MSVis - MSChecker.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 36 38 94.7 %
Date: 2024-12-11 20:54:31 Functions: 2 2 100.0 %

          Line data    Source code
       1             : //# MSChecker.cc: Some MS specific Utilities
       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 adressed 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             : //# $Id$
      28             : 
      29             : #include <msvis/MSVis/MSChecker.h>
      30             : 
      31             : #include <casacore/tables/Tables/ConcatScalarColumn.h>
      32             : 
      33             : using namespace casacore;
      34             : namespace casa {
      35         758 : MSChecker::MSChecker(const MeasurementSet& ms) : _ms(ms) {}
      36             : 
      37         758 : void MSChecker::checkReferentialIntegrity() const {
      38         758 :     Int nrows = 0;
      39         758 :     String colname, tablename;
      40         758 :     uInt nAnts = _ms.antenna().nrow();
      41        4548 :     for (uInt i=0; i<5; ++i) {
      42        3790 :         switch (i) {
      43         758 :         case 0:
      44         758 :             nrows = nAnts;
      45         758 :             tablename = _ms.antenna().tableName();
      46         758 :             colname = _ms.columnName(MSMainEnums::ANTENNA1);
      47         758 :             break;
      48         758 :         case 1:
      49         758 :             nrows = nAnts;
      50         758 :             tablename = _ms.antenna().tableName();
      51         758 :             colname = _ms.columnName(MSMainEnums::ANTENNA2);
      52         758 :             break;
      53         758 :         case 2:
      54         758 :             nrows = _ms.dataDescription().nrow();
      55         758 :             tablename = _ms.dataDescription().tableName();
      56         758 :             colname = _ms.columnName(MSMainEnums::DATA_DESC_ID);
      57         758 :             break;
      58         758 :         case 3:
      59         758 :             nrows = _ms.field().nrow();
      60         758 :             tablename = _ms.field().tableName();
      61         758 :             colname = _ms.columnName(MSMainEnums::FIELD_ID);
      62         758 :             break;
      63         758 :         case 4:
      64         758 :             nrows = _ms.observation().nrow();
      65         758 :             tablename = _ms.observation().tableName();
      66         758 :             colname = _ms.columnName(MSMainEnums::OBSERVATION_ID);
      67         758 :             break;
      68           0 :         default:
      69           0 :             break;
      70             :         }
      71        7580 :         Vector<Int> data;
      72        3790 :         ScalarColumn<Int>(_ms, colname).getColumn(data);
      73        3790 :         ThrowIf(
      74             :             anyGE(data, nrows),
      75             :             "Illegal " + colname + " value " + String::toString(max(data))
      76             :             + " found in main table. " + tablename + " only has "
      77             :             + String::toString(nrows) + " rows (IDs)"
      78             :         );
      79             :     }
      80         758 : }
      81             : 
      82             : }

Generated by: LCOV version 1.16