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