LCOV - code coverage report
Current view: top level - msvis/MSVis - MSChecker.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 38 0.0 %
Date: 2024-10-09 13:55:54 Functions: 0 2 0.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           0 : MSChecker::MSChecker(const MeasurementSet& ms) : _ms(ms) {}
      36             : 
      37           0 : void MSChecker::checkReferentialIntegrity() const {
      38           0 :     Int nrows = 0;
      39           0 :     String colname, tablename;
      40           0 :     uInt nAnts = _ms.antenna().nrow();
      41           0 :     for (uInt i=0; i<5; ++i) {
      42           0 :         switch (i) {
      43           0 :         case 0:
      44           0 :             nrows = nAnts;
      45           0 :             tablename = _ms.antenna().tableName();
      46           0 :             colname = _ms.columnName(MSMainEnums::ANTENNA1);
      47           0 :             break;
      48           0 :         case 1:
      49           0 :             nrows = nAnts;
      50           0 :             tablename = _ms.antenna().tableName();
      51           0 :             colname = _ms.columnName(MSMainEnums::ANTENNA2);
      52           0 :             break;
      53           0 :         case 2:
      54           0 :             nrows = _ms.dataDescription().nrow();
      55           0 :             tablename = _ms.dataDescription().tableName();
      56           0 :             colname = _ms.columnName(MSMainEnums::DATA_DESC_ID);
      57           0 :             break;
      58           0 :         case 3:
      59           0 :             nrows = _ms.field().nrow();
      60           0 :             tablename = _ms.field().tableName();
      61           0 :             colname = _ms.columnName(MSMainEnums::FIELD_ID);
      62           0 :             break;
      63           0 :         case 4:
      64           0 :             nrows = _ms.observation().nrow();
      65           0 :             tablename = _ms.observation().tableName();
      66           0 :             colname = _ms.columnName(MSMainEnums::OBSERVATION_ID);
      67           0 :             break;
      68           0 :         default:
      69           0 :             break;
      70             :         }
      71           0 :         Vector<Int> data;
      72           0 :         ScalarColumn<Int>(_ms, colname).getColumn(data);
      73           0 :         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           0 : }
      81             : 
      82             : }

Generated by: LCOV version 1.16