LCOV - code coverage report
Current view: top level - synthesis/CalTables - CalSetMetaInfo.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 106 0.0 %
Date: 2024-12-11 20:54:31 Functions: 0 13 0.0 %

          Line data    Source code
       1             : //# CalSetMetaInfo.cc: Implementation of CalSetMetaInfo classes
       2             : //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
       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 addressed 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             : //# $Id$
      27             : 
      28             : #include <synthesis/CalTables/CalSetMetaInfo.h>
      29             : 
      30             : #include <msvis/MSVis/VisBuffer.h>
      31             : 
      32             : #include <casacore/casa/Arrays/ArrayMath.h>
      33             : #include <casacore/casa/Arrays/ArrayIter.h>
      34             : #include <casacore/scimath/Mathematics/MatrixMathLA.h>
      35             : #include <casacore/casa/BasicSL/String.h>
      36             : #include <casacore/casa/Utilities/Assert.h>
      37             : #include <casacore/casa/Quanta/MVTime.h>
      38             : #include <casacore/casa/Exceptions/Error.h>
      39             : #include <casacore/casa/OS/Memory.h>
      40             : #include <casacore/casa/Utilities/GenSort.h>
      41             : #include <casacore/casa/Quanta/Quantum.h>
      42             : #include <casacore/casa/Quanta/QuantumHolder.h>
      43             : #include <casacore/ms/MeasurementSets/MSAntennaColumns.h>
      44             : #include <casacore/ms/MeasurementSets/MSFieldColumns.h>
      45             : #include <casacore/ms/MeasurementSets/MSSpWindowColumns.h>
      46             : #include <sstream>
      47             : #include <iostream>
      48             : #include <iomanip>
      49             : 
      50             : #include <casacore/casa/Logging/LogMessage.h>
      51             : #include <casacore/casa/Logging/LogSink.h>
      52             : 
      53             : #include <fstream>
      54             : 
      55             : using namespace casacore;
      56             : namespace casa { //# NAMESPACE CASA - BEGIN
      57             :   //
      58             :   //----------------------------------------------------------------
      59             :   //
      60           0 :   CalSetMetaInfo::CalSetMetaInfo(const String& root):
      61           0 :     rootName(root),
      62           0 :     antTableName("ANTENNA"), 
      63           0 :     fieldTableName("FIELD"), 
      64           0 :     spwTableName("SPECTRAL_WINDOW"),
      65           0 :     calTableMSAC(NULL), calTableMSFC(NULL), calTableMSSpC(NULL),
      66           0 :     calAntTable(NULL), calFieldTable(NULL), calSpwTable(NULL)
      67             :   {
      68           0 :     antTableName   = "ANTENNA";
      69           0 :     fieldTableName = "FIELD";
      70           0 :     spwTableName   = "SPECTRAL_WINDOW";
      71           0 :     reset(root);
      72           0 :   }
      73             : 
      74           0 :   void CalSetMetaInfo::reset(const String& root)
      75             :   {
      76           0 :     cleanUp();
      77           0 :     setRootName(root);
      78             : 
      79           0 :     calAntTable = new MSAntenna(fullSubTableName(antTableName));
      80           0 :     calTableMSAC = new MSAntennaColumns(*calAntTable);
      81             : 
      82           0 :     calFieldTable = new MSField(fullSubTableName(fieldTableName));
      83           0 :     calTableMSFC = new MSFieldColumns(*calFieldTable);
      84             : 
      85           0 :     calSpwTable = new MSSpectralWindow(fullSubTableName(spwTableName));
      86           0 :     calTableMSSpC = new MSSpWindowColumns(*calSpwTable);
      87           0 :   }
      88             :   //
      89             :   //----------------------------------------------------------------
      90             :   //
      91           0 :   String CalSetMetaInfo::getAntName(Int ant)
      92             :   {
      93           0 :     return (*calTableMSAC).name().getColumn()(ant);
      94             :   }
      95             :   //
      96             :   //----------------------------------------------------------------
      97             :   //
      98           0 :   Vector<String> CalSetMetaInfo::getAntNames()
      99             :   {
     100           0 :     return Vector<String>((*calTableMSAC).name().getColumn());
     101             :   }
     102             :   //
     103             :   //----------------------------------------------------------------
     104             :   //
     105           0 :   String CalSetMetaInfo::getFieldName(Int field)
     106             :   {
     107           0 :     return (*calTableMSFC).name().getColumn()(field);
     108             :   }
     109             :   //
     110             :   //----------------------------------------------------------------
     111             :   //
     112           0 :   Vector<String> CalSetMetaInfo::getFieldNames()
     113             :   {
     114           0 :     return Vector<String>((*calTableMSFC).name().getColumn());
     115             :   }
     116             :   //
     117             :   //----------------------------------------------------------------
     118             :   //
     119           0 :   String CalSetMetaInfo::getSpwName(Int spw)
     120             :   {
     121           0 :         return (*calTableMSSpC).name().getColumn()(spw);
     122             :   }
     123             :   //
     124             :   //----------------------------------------------------------------
     125             :   //
     126           0 :   Vector<String> CalSetMetaInfo::getSpwNames()
     127             :   {
     128           0 :     return Vector<String>((*calTableMSSpC).name().getColumn());
     129             :   }
     130             :   //
     131             :   //----------------------------------------------------------------
     132             :   //
     133           0 :   Double CalSetMetaInfo::getSpwRefFreq(Int spw)
     134             :   {
     135           0 :     return (*calTableMSSpC).refFrequency().getColumn()(spw);
     136             :   }
     137             :   //
     138             :   //----------------------------------------------------------------
     139             :   //
     140           0 :   Vector<Double> CalSetMetaInfo::getSpwRefFreqs()
     141             :   {
     142           0 :     return Vector<Double>((*calTableMSSpC).refFrequency().getColumn());
     143             :   }
     144             :   //
     145             :   //----------------------------------------------------------------
     146             :   //
     147             :   /*
     148             :   Vector<Double> CalSetMetaInfo::getSpwChanWidth(Int spw)
     149             :   {
     150             :     return (*calTableMSSpC).chanWidth().getColumn()(spw);
     151             :   }
     152             :   */
     153             :   //
     154             :   //----------------------------------------------------------------
     155             :   //
     156           0 :   Double CalSetMetaInfo::getSpwTotalBandwidth(Int spw)
     157             :   {
     158           0 :     return (*calTableMSSpC).totalBandwidth().getColumn()(spw);
     159             :   }
     160             :   //
     161             :   //----------------------------------------------------------------
     162             :   //
     163           0 :   void CalSetMetaInfo::copyMetaTables(const String& target)
     164             :   {
     165             :     {
     166           0 :       String name(target+"/ANTENNA");
     167           0 :       MSAntenna antTable(fullSubTableName(antTableName));
     168           0 :       antTable.deepCopy(fullSubTableName(antTableName,target), Table::New);
     169           0 :     }
     170             :     {
     171           0 :       String name(target+"/FIELD");
     172           0 :       MSField fieldTable(fullSubTableName(fieldTableName));
     173           0 :       fieldTable.deepCopy(fullSubTableName(fieldTableName,target), Table::New);
     174           0 :     }
     175             :     {
     176           0 :       String name(target+"/SPECTRAL_WINDOW");
     177           0 :       MSSpectralWindow spwTable(fullSubTableName(spwTableName));
     178           0 :       spwTable.deepCopy(fullSubTableName(spwTableName,target), Table::New);
     179           0 :     }
     180           0 :   }
     181             :   //
     182             :   //----------------------------------------------------------------
     183             :   //
     184             :   // Verify that the entires in the meta-info tables of the CalSet are 
     185             :   // identical to those in the meta-info tables of the otherCSMI (typically
     186             :   // of the MS being processed).
     187             :   // 
     188             :   // This requirement for the entires to be identical is too
     189             :   // restrictive (I (SB) can think of simple real-life cases where
     190             :   // this restriction will show up).  However, this is a good first
     191             :   // step.
     192             :   //
     193           0 :   Bool CalSetMetaInfo::verify(CalSetMetaInfo& otherCSMI)
     194             :   {
     195           0 :     Bool spwVerified=false, antennaVerified=false, fieldVerified=false;
     196           0 :     ostringstream spwMesg, antMesg, fieldMesg;
     197             :     // Verify that the entires in the SPW table are identical
     198             :     {
     199           0 :       Vector<String> thisSpwNames=getSpwNames(),
     200           0 :         otherSpwNames=otherCSMI.getSpwNames();
     201           0 :       Vector<Double> thisSpwRefFreq=getSpwRefFreqs(),
     202           0 :         otherSpwRefFreq(otherCSMI.getSpwRefFreqs());
     203             : 
     204           0 :       uInt n=thisSpwNames.nelements();
     205           0 :       spwVerified = (n <= otherSpwNames.nelements());
     206           0 :       uInt i=0;
     207           0 :       if (spwVerified)
     208           0 :         for(i=0;i<n;i++)
     209             :           {
     210           0 :             if (thisSpwNames(i) != otherSpwNames(i))
     211           0 :               {spwVerified = false;break;}
     212           0 :             if (thisSpwRefFreq(i) != otherSpwRefFreq(i))
     213           0 :               {spwVerified = false;break;}
     214             :           }
     215           0 :       if (!spwVerified)
     216             :         spwMesg << "CalSetMetaInfo::verify: "
     217           0 :                 << "Spectral Window " << i << " is not identical in the CalTable and the MS.";
     218           0 :     }
     219             :     // Verify that the entires in the ANTENNA table are identical
     220             :     {
     221           0 :       Vector<String> thisAntNames=getAntNames(),
     222           0 :         otherAntNames=otherCSMI.getAntNames();
     223           0 :       uInt n=thisAntNames.nelements();
     224           0 :       antennaVerified = (n <= otherAntNames.nelements());
     225           0 :       uInt i=0;
     226           0 :       if (antennaVerified)
     227           0 :         for(i=0;i<n;i++)
     228             :           {
     229           0 :             if (thisAntNames(i) != otherAntNames(i))
     230           0 :               {antennaVerified = false;break;}
     231             :           }
     232           0 :       if (!antennaVerified)
     233             :           antMesg << "CalSetMetaInfo::verify: "
     234           0 :                   << "Antenna " << i << " is not identical in the CalTable and the MS.";
     235           0 :     }
     236             :     // Verify that the entires in the FIELD table are identical
     237             :     {
     238           0 :       Vector<String> thisFieldNames=getFieldNames(),
     239           0 :         otherFieldNames=otherCSMI.getFieldNames();
     240           0 :       uInt n=thisFieldNames.nelements();
     241           0 :       fieldVerified = (n <= otherFieldNames.nelements());
     242           0 :       uInt i = 0;
     243           0 :       if (fieldVerified)
     244           0 :         for(i=0;i<n;i++)
     245             :           {
     246           0 :             if (thisFieldNames(i) != otherFieldNames(i))
     247           0 :               {fieldVerified = false;break;}
     248             :           }
     249           0 :       if (!fieldVerified)
     250             :           fieldMesg << "CalSetMetaInfo::verify: "
     251           0 :                     << "Field " << i << " is not identical in the CalTable and the MS.";
     252           0 :     }
     253           0 :     if ((!spwVerified) || (!antennaVerified) || (!fieldVerified))
     254             :       {
     255           0 :         ostringstream mesg;
     256           0 :         if (spwMesg.str() != "")  mesg << spwMesg.str() << endl;
     257           0 :         if (antMesg.str() != "")  mesg << antMesg.str() << endl;
     258           0 :         if (fieldMesg.str() != "")mesg << fieldMesg.str() << endl;
     259           0 :         throw(AipsError(mesg.str()));
     260           0 :       }
     261           0 :     return (spwVerified & antennaVerified & fieldVerified);
     262           0 :   }
     263             : 
     264             : } //# NAMESPACE CASA - END

Generated by: LCOV version 1.16