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: aips2-request@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 740 : MSChecker::MSChecker(const MeasurementSet& ms) : _ms(ms) {} 36 : 37 740 : void MSChecker::checkReferentialIntegrity() const { 38 740 : Int nrows = 0; 39 1480 : String colname, tablename; 40 740 : uInt nAnts = _ms.antenna().nrow(); 41 4440 : for (uInt i=0; i<5; ++i) { 42 3700 : switch (i) { 43 740 : case 0: 44 740 : nrows = nAnts; 45 740 : tablename = _ms.antenna().tableName(); 46 740 : colname = _ms.columnName(MSMainEnums::ANTENNA1); 47 740 : break; 48 740 : case 1: 49 740 : nrows = nAnts; 50 740 : tablename = _ms.antenna().tableName(); 51 740 : colname = _ms.columnName(MSMainEnums::ANTENNA2); 52 740 : break; 53 740 : case 2: 54 740 : nrows = _ms.dataDescription().nrow(); 55 740 : tablename = _ms.dataDescription().tableName(); 56 740 : colname = _ms.columnName(MSMainEnums::DATA_DESC_ID); 57 740 : break; 58 740 : case 3: 59 740 : nrows = _ms.field().nrow(); 60 740 : tablename = _ms.field().tableName(); 61 740 : colname = _ms.columnName(MSMainEnums::FIELD_ID); 62 740 : break; 63 740 : case 4: 64 740 : nrows = _ms.observation().nrow(); 65 740 : tablename = _ms.observation().tableName(); 66 740 : colname = _ms.columnName(MSMainEnums::OBSERVATION_ID); 67 740 : break; 68 0 : default: 69 0 : break; 70 : } 71 7400 : Vector<Int> data; 72 3700 : ScalarColumn<Int>(_ms, colname).getColumn(data); 73 3700 : 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 740 : } 81 : 82 : }