LCOV - code coverage report
Current view: top level - synthesis/CalTables - CTInterface.cc (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 0 37 0.0 %
Date: 2023-11-02 14:27:30 Functions: 0 8 0.0 %

          Line data    Source code
       1             : //# CTInterface.cc: Implementation of CTInterface class
       2             : //# Copyright (C) 1996,1997,1998,1999,2000,2001,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: 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             : //# $Id$
      27             : //----------------------------------------------------------------------------
      28             : 
      29             : #include <synthesis/CalTables/CTInterface.h>
      30             : #include <casacore/ms/MeasurementSets/MSColumns.h>
      31             : 
      32             : #include <unordered_set>
      33             : 
      34             : using namespace casacore;
      35             : namespace casa { //# NAMESPACE CASA - BEGIN
      36             : 
      37             :   //
      38             :   //----------------------------------------------------------------------------
      39             :   //
      40           0 :   CTInterface::CTInterface(const Table& table)
      41           0 :     :MSSelectableTable(table), fakeDDSubTable(),  ctMainCols_p(NULL) 
      42           0 :   {makeDDSubTable();};
      43             :   //
      44             :   //----------------------------------------------------------------------------
      45             :   //
      46           0 :   CTInterface::~CTInterface() 
      47           0 :   {if (ctMainCols_p) delete ctMainCols_p;};
      48             :   //
      49             :   //----------------------------------------------------------------------------
      50             :   //
      51           0 :   const NewCalTable* CTInterface::asCT()
      52             :   {
      53           0 :     return static_cast<const NewCalTable *>(table());
      54             :   };
      55             :   //
      56             :   //----------------------------------------------------------------------------
      57             :   //
      58           0 :   void CTInterface::makeDDSubTable()
      59             :   {
      60             :     //
      61             :     // Make an in-memory DataDescription table.
      62             :     //
      63           0 :     SetupNewTable setup(String(""), MSDataDescription::requiredTableDesc(), 
      64           0 :       Table::Scratch);
      65           0 :     const Table tmpTab(setup, Table::Memory, spectralWindow().nrow());
      66           0 :     fakeDDSubTable = MSDataDescription(tmpTab);
      67             :     //
      68             :     // Call the in-memory table what it is.
      69             :     //
      70           0 :     TableInfo& tabInfo=fakeDDSubTable.tableInfo();
      71           0 :     tabInfo.setType("FAKE_DATA_DESCRIPTION_ID");
      72             :     //
      73             :     // Fill the required columns (flagRow and spectralWindowId).
      74             :     // These should ideally be just referenced, but I (SB) could not
      75             :     // figure out how to do it.
      76             :     //
      77           0 :     Vector<Bool> spwFlagRow=MSSpWindowColumns(spectralWindow()).flagRow().getColumn();
      78           0 :     MSDataDescColumns(fakeDDSubTable).flagRow().putColumn(spwFlagRow);
      79             : 
      80           0 :     Vector<Int> spwId(fakeDDSubTable.nrow()); indgen(spwId);
      81           0 :     MSDataDescColumns(fakeDDSubTable).spectralWindowId().putColumn(spwId);
      82           0 :   }
      83             :   //
      84             :   //----------------------------------------------------------------------------
      85             :   //
      86           0 :   const MSDataDescription& CTInterface::dataDescription() 
      87             :   {
      88           0 :     return fakeDDSubTable;
      89             :   }
      90             :   //
      91             :   //----------------------------------------------------------------------------
      92             :   // For CalTables, MS::DATA_DESC_ID maps to
      93             :   // CTEnums::SPECTRAL_WINDOW_ID.  So do only that translation.
      94             :   //
      95           0 :   String CTInterface::columnName(MSMainEnums::PredefinedColumns nameEnum) 
      96             :   {
      97           0 :     if (nameEnum == MS::DATA_DESC_ID)
      98           0 :       return CTEnums::fieldName(CTEnums::SPECTRAL_WINDOW_ID);
      99             :     else
     100           0 :       return MS::columnName(nameEnum);
     101             :   }
     102             :   //
     103             :   //----------------------------------------------------------------------------
     104             :   // Return the type of the CalTable.  Possibilities are defined in
     105             :   // the MSSelectableTable::MSSDataType enum.
     106             :   //  o For MSSelectableTable::MSSDataType::PURE_ANTENNA_BASED, only 
     107             :   //    ANTENN1 is matched and the "&" operators in selection expressions
     108             :   //    are ignored.
     109             :   //  o For MSSelectableTable::MSSDataType::REF_ANTENNA_BASED, ANTENN2
     110             :   //    is interpreted as a reference antenna and matched against the
     111             :   //    the ANT2 in a ANT2&ANT2 type expressions.
     112             :   //
     113             :   // This is the method called in the MSSelection module to determine
     114             :   // the appropriate rule-resolution.  Any CalTable type based
     115             :   // determination of the MSDataType should be done here.
     116             : 
     117           0 :   MSSelectableTable::MSSDataType CTInterface::dataType()
     118             :   {
     119           0 :     const NewCalTable* nct = asCT();
     120           0 :     casacore::ScalarColumn<casacore::Int> ant1col(*nct, "ANTENNA1");
     121           0 :     casacore::Vector<casacore::Int> ant1 = ant1col.getColumn();
     122           0 :     casacore::ScalarColumn<casacore::Int> ant2col(*nct, "ANTENNA2");
     123           0 :     casacore::Vector<casacore::Int> ant2 = ant2col.getColumn();
     124             : 
     125             :     // Check if ant2 is -1, all antennas, or subset of antennas
     126             :     // For SD caltables where ANT1=ANT2 in all rows, treat as pure
     127           0 :     if ((ant2(0) == -1) || allEQ(ant1, ant2)) {
     128           0 :       return MSSelectableTable::PURE_ANTENNA_BASED;
     129             :     } else {
     130           0 :       std::unordered_set<casacore::Int> ant2set(ant2.begin(), ant2.end());
     131           0 :       if (ant2set.size() == nct->antenna().nrow()) {
     132           0 :         return MSSelectableTable::BASELINE_BASED;
     133             :       } else {
     134           0 :         return MSSelectableTable::REF_ANTENNA_BASED;
     135             :       }
     136             :     }
     137             :   }
     138             : 
     139             :   //
     140             :   //----------------------------------------------------------------------------
     141             :   // CalTables have no OBSERVATION sub-table.  So throw a tantrum if
     142             :   // it is asked for.
     143             :   //
     144             :   //  const MSObservation& CTInterface::observation()
     145             :   //  {
     146             :   //    throw(AipsError("Internal error: OBSERVATION sub-table for CalTables requested"));
     147             :   //  };
     148             :   //----------------------------------------------------------------------------
     149             : } //# NAMESPACE CASA - END
     150             : 

Generated by: LCOV version 1.16