LCOV - code coverage report
Current view: top level - synthesis/CalTables - CalMainBuffer.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 1 6 16.7 %
Date: 2024-11-06 17:42:47 Functions: 1 5 20.0 %

          Line data    Source code
       1             : //# CalMainBuffer.h: Calibration main table buffer
       2             : //# Copyright (C) 1996,1997,1998,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 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             : #ifndef CALIBRATION_CALMAINBUFFER_H
      30             : #define CALIBRATION_CALMAINBUFFER_H
      31             : 
      32             : #include <synthesis/CalTables/CalDescBuffer.h>
      33             : #include <synthesis/CalTables/CalHistoryBuffer.h>
      34             : #include <synthesis/CalTables/CalTable.h>
      35             : #include <synthesis/CalTables/CalMainColumns.h>
      36             : #include <msvis/MSVis/MSCalEnums.h>
      37             : #include <msvis/MSVis/VisBuffer.h>
      38             : #include <synthesis/CalTables/CalIterBase.h>
      39             : 
      40             : namespace casa { //# NAMESPACE CASA - BEGIN
      41             : 
      42             : // <summary> 
      43             : // CalMainBuffer: Calibration main table buffer
      44             : // </summary>
      45             : 
      46             : // <use visibility=export>
      47             : 
      48             : // <reviewed reviewer="" date="" tests="" demos="">
      49             : 
      50             : // <prerequisite>
      51             : //   <li> <linkto class="CalTable">CalTable</linkto> module
      52             : //   <li> <linkto class="CalIterBase">CalIterBase</linkto> module
      53             : // </prerequisite>
      54             : //
      55             : // <etymology>
      56             : // From "calibration main table" and "buffer"
      57             : // </etymology>
      58             : //
      59             : // <synopsis>
      60             : // The CalMainBuffer class holds a buffer, optionally connected to a 
      61             : // calibration main table iterator (of base type CalIterBase). 
      62             : // Specializations for baseline-based, time-variable and solvable 
      63             : // VisJones calibration table formats are provided through 
      64             : // inheritance.
      65             : // </synopsis>
      66             : //
      67             : // <example>
      68             : // <srcblock>
      69             : // </srcblock>
      70             : // </example>
      71             : //
      72             : // <motivation>
      73             : // Encapsulate calibration main table data buffers.
      74             : // </motivation>
      75             : //
      76             : // <todo asof="01/08/01">
      77             : // (i) Deal with non-standard columns.
      78             : // </todo>
      79             : 
      80             : class CalMainBuffer 
      81             : {
      82             :  public:
      83             :   // Default constructor. No connection to an underlying
      84             :   // calibration table iterator in this case.
      85             :   CalMainBuffer();
      86             : 
      87             :   // Construct from a set of calibration buffer indices and
      88             :   // their specified values. Non-index columns will be set 
      89             :   // to default values. There is no connection to an underlying 
      90             :   // calibration table iterator in this case.
      91             :   CalMainBuffer (const casacore::Vector<casacore::Int>& calIndices, 
      92             :                  const casacore::Block<casacore::Vector<casacore::Int> >& indexValues);
      93             : 
      94             :   // Construct from a calibration table iterator. The calibration
      95             :   // buffer will remain synchronized with the iterator.
      96             :   CalMainBuffer (CalIterBase& calIter);
      97             : 
      98             :   // Default destructor
      99             :   virtual ~CalMainBuffer();
     100             : 
     101             :   // Synchronize the buffer (if attached to an iterator)
     102             :   virtual void synchronize();
     103             : 
     104             :   // Force an explicit read to cache for all columns 
     105             :   // (if attached to an iterator)
     106             :   virtual void fillCache();
     107             : 
     108             :   // Write the current buffer at the end of a specified cal table;
     109             :   // returns the number of rows appended.
     110             :   virtual casacore::Int append (CalTable& calTable);
     111             : 
     112             :   // Maximum number of rows in the calibration buffer
     113             :   virtual casacore::Int nRow();
     114             : 
     115             :   // Accessors for the contained cal_desc and cal_history buffers
     116           0 :   virtual CalDescBuffer& calDescBuffer() {return *calDescBuf_p;};
     117           0 :   virtual CalHistoryBuffer& calHistoryBuffer() {return *calHistBuf_p;};
     118             : 
     119             :   // casacore::Data field accessors
     120             :   virtual casacore::Vector<casacore::MEpoch>& timeMeas();
     121             :   virtual casacore::Vector<casacore::Quantity>& timeEPQuant();
     122             :   virtual casacore::Vector<casacore::Quantity>& intervalQuant();
     123             :   virtual casacore::Vector<casacore::Int>& antenna1();
     124             :   virtual casacore::Vector<casacore::Int>& feed1();
     125             :   virtual casacore::Vector<casacore::Int>& fieldId();
     126             :   virtual casacore::Vector<casacore::Int>& arrayId();
     127             :   virtual casacore::Vector<casacore::Int>& obsId();
     128             :   virtual casacore::Vector<casacore::Int>& scanNo();
     129             :   virtual casacore::Vector<casacore::Int>& processorId();
     130             :   virtual casacore::Vector<casacore::Int>& stateId();
     131             :   virtual casacore::Vector<casacore::Int>& phaseId();
     132             :   virtual casacore::Vector<casacore::Int>& pulsarBin();
     133             :   virtual casacore::Vector<casacore::Int>& pulsarGateId();
     134             :   virtual casacore::Vector<casacore::Int>& freqGrp();
     135             :   virtual casacore::Vector<casacore::String>& freqGrpName();
     136             :   virtual casacore::Vector<casacore::String>& fieldName();
     137             :   virtual casacore::Vector<casacore::String>& fieldCode();
     138             :   virtual casacore::Vector<casacore::String>& sourceName();
     139             :   virtual casacore::Vector<casacore::String>& sourceCode();
     140             :   virtual casacore::Vector<casacore::Int>& calGrp();
     141             :   virtual casacore::Array<casacore::Complex>& gain();
     142             :   virtual casacore::Array<casacore::Int>& refAnt();
     143             :   virtual casacore::Array<casacore::Int>& refFeed();
     144             :   virtual casacore::Array<casacore::Int>& refReceptor();
     145             :   virtual casacore::Array<casacore::MFrequency>& refFreqMeas();
     146             :   virtual casacore::Vector<casacore::Int>& measFreqRef();
     147             :   virtual casacore::Array<casacore::MDirection>& refDirMeas();
     148             :   virtual casacore::Vector<casacore::Int>& measDirRef();
     149             :   virtual casacore::Vector<casacore::Int>& calDescId();
     150             :   virtual casacore::Vector<casacore::Int>& calHistoryId(); 
     151             : 
     152             :   // Generic access to integer columns by MSCalEnums enumeration. Throws
     153             :   // an exception if the column is not recognized or is not an integer column.
     154             :   virtual casacore::Vector<casacore::Int>& asVecInt (const MSCalEnums::colDef& calEnum);
     155             : 
     156             :   // Generic access to string columns by MSCalEnums enumeration. Throws
     157             :   // an exception if the column is not recognized or is not a string column.
     158             :   virtual casacore::Vector<casacore::String>& asVecString (const MSCalEnums::colDef& calEnum);
     159             : 
     160             :   // Find the matching rows for a given antenna1 id.
     161             :   virtual casacore::Vector<casacore::Int> matchAntenna1 (const casacore::Int& antennaId);
     162             : 
     163             :   // Find the matching rows for a given antenna1 id. and field id. pair
     164             :   virtual casacore::Vector<casacore::Int> matchAntenna1AndFieldId (const casacore::Int& antennaId,
     165             :                                                const casacore::Int& fldId);
     166             : 
     167             :   // Find the matching rows for a given antenna1 id. and freq. group name
     168             :   virtual casacore::Vector<casacore::Int> matchAntenna1AndFreqGrp (const casacore::Int& antennaId,
     169             :                                                const casacore::String& frqGrpName);
     170             : 
     171             :  protected:
     172             :   // Factory method to create a columns accessor object of the appropriate type
     173           0 :   virtual CalMainColumns* newCalMainCol (CalTable& calTable)
     174           0 :     {return new CalMainColumns (calTable);};
     175             : 
     176             :   // Access to the columns accessor object
     177           0 :   virtual CalMainColumns* calMainCol() {return calMainCol_p;};
     178             : 
     179             :   // Is the buffer connected to an underlying iterator ?
     180        3760 :   casacore::Bool connectedToIter() {return connectedToIter_p;};
     181             : 
     182             :   // Invalidate the current cache. 
     183             :   virtual void invalidate();
     184             : 
     185             :   // <group>
     186             :   // Span an empty cal buffer by taking all permutations of the
     187             :   // values of a specified set of cal indices, specified as
     188             :   // enums from class MSCalEnums:
     189             :   //
     190             :   // Use a visibility buffer to define the index values 
     191             :   virtual void fillIndices (const casacore::Vector<casacore::Int>& calIndices,
     192             :                             const VisBuffer& vb);
     193             : 
     194             :   // Define the index values directly
     195             :   virtual void fillIndices (const casacore::Vector<casacore::Int>& calIndices,
     196             :                             const casacore::Block<casacore::Vector<casacore::Int> >& indexValues);
     197             :   // </group>
     198             : 
     199             :   // <group>
     200             :   // Fill the cal buffer attribute columns in an empty cal buffer,
     201             :   // after the cal indices have been set using fillIndices(). The 
     202             :   // cal indices, specified as enums from class MSCalEnums, are excluded
     203             :   // as non-attribute columns.
     204             :   //
     205             :   // Use a visibility buffer to define the attribute values
     206             :   virtual void fillAttributes(const casacore::Vector<casacore::Int>& calIndices,
     207             :                               const VisBuffer& vb);
     208             : 
     209             :   // Set default attribute values
     210             :   virtual void fillAttributes(const casacore::Vector<casacore::Int>& calIndices);
     211             : 
     212             :   // </group>
     213             : 
     214             :   // Utility function to test for membership in a list of calibration enums
     215             :   casacore::Bool excluded(const MSCalEnums::colDef& calEnum, 
     216             :                 const casacore::Vector<casacore::Int>& excludeIndices);
     217             : 
     218             :  private:
     219             :   // true if connected to underlying iterator
     220             :   casacore::Bool connectedToIter_p;
     221             : 
     222             :   // Ptr to calibration table iterator
     223             :   CalIterBase* calIter_p;
     224             : 
     225             :   // Ptr to cal main columns accessor
     226             :   CalMainColumns* calMainCol_p;
     227             : 
     228             :   // Contained sub-table cal_desc and cal_history buffers
     229             :   CalDescBuffer* calDescBuf_p;
     230             :   CalHistoryBuffer* calHistBuf_p;
     231             : 
     232             :   // Buffer fields
     233             :   casacore::Vector<casacore::MEpoch> timeMeas_p;
     234             :   casacore::Vector<casacore::Quantity> timeEPQuant_p;
     235             :   casacore::Vector<casacore::Quantity> intervalQuant_p;
     236             :   casacore::Vector<casacore::Int> antenna1_p;
     237             :   casacore::Vector<casacore::Int> feed1_p;
     238             :   casacore::Vector<casacore::Int> fieldId_p;
     239             :   casacore::Vector<casacore::Int> arrayId_p;
     240             :   casacore::Vector<casacore::Int> obsId_p;
     241             :   casacore::Vector<casacore::Int> scanNo_p;
     242             :   casacore::Vector<casacore::Int> processorId_p;
     243             :   casacore::Vector<casacore::Int> stateId_p;
     244             :   casacore::Vector<casacore::Int> phaseId_p;
     245             :   casacore::Vector<casacore::Int> pulsarBin_p;
     246             :   casacore::Vector<casacore::Int> pulsarGateId_p;
     247             :   casacore::Vector<casacore::Int> freqGrp_p;
     248             :   casacore::Vector<casacore::String> freqGrpName_p;
     249             :   casacore::Vector<casacore::String> fieldName_p;
     250             :   casacore::Vector<casacore::String> fieldCode_p;
     251             :   casacore::Vector<casacore::String> sourceName_p;
     252             :   casacore::Vector<casacore::String> sourceCode_p;
     253             :   casacore::Vector<casacore::Int> calGrp_p;
     254             :   casacore::Array<casacore::Complex> gain_p;
     255             :   casacore::Array<casacore::Int> refAnt_p;
     256             :   casacore::Array<casacore::Int> refFeed_p;
     257             :   casacore::Array<casacore::Int> refReceptor_p;
     258             :   casacore::Array<casacore::MFrequency> refFreqMeas_p;
     259             :   casacore::Vector<casacore::Int> measFreqRef_p;
     260             :   casacore::Array<casacore::MDirection> refDirMeas_p;
     261             :   casacore::Vector<casacore::Int> measDirRef_p;
     262             :   casacore::Vector<casacore::Int> calDescId_p;
     263             :   casacore::Vector<casacore::Int> calHistoryId_p;
     264             : 
     265             :   // Buffer field status flags
     266             :   casacore::Bool timeMeasOK_p;
     267             :   casacore::Bool timeEPQuantOK_p;
     268             :   casacore::Bool intervalQuantOK_p;
     269             :   casacore::Bool antenna1OK_p;
     270             :   casacore::Bool feed1OK_p;
     271             :   casacore::Bool fieldIdOK_p;
     272             :   casacore::Bool arrayIdOK_p;
     273             :   casacore::Bool obsIdOK_p;
     274             :   casacore::Bool scanNoOK_p;
     275             :   casacore::Bool processorIdOK_p;
     276             :   casacore::Bool stateIdOK_p;
     277             :   casacore::Bool phaseIdOK_p;
     278             :   casacore::Bool pulsarBinOK_p;
     279             :   casacore::Bool pulsarGateIdOK_p;
     280             :   casacore::Bool freqGrpOK_p;
     281             :   casacore::Bool freqGrpNameOK_p;
     282             :   casacore::Bool fieldNameOK_p;
     283             :   casacore::Bool fieldCodeOK_p;
     284             :   casacore::Bool sourceNameOK_p;
     285             :   casacore::Bool sourceCodeOK_p;
     286             :   casacore::Bool calGrpOK_p;
     287             :   casacore::Bool gainOK_p;
     288             :   casacore::Bool refAntOK_p;
     289             :   casacore::Bool refFeedOK_p;
     290             :   casacore::Bool refReceptorOK_p;
     291             :   casacore::Bool refFreqMeasOK_p;
     292             :   casacore::Bool measFreqRefOK_p;
     293             :   casacore::Bool refDirMeasOK_p;
     294             :   casacore::Bool measDirRefOK_p;
     295             :   casacore::Bool calDescIdOK_p;
     296             :   casacore::Bool calHistoryIdOK_p;
     297             : };
     298             : 
     299             : 
     300             : } //# NAMESPACE CASA - END
     301             : 
     302             : #endif
     303             :    
     304             :   
     305             : 
     306             : 
     307             : 

Generated by: LCOV version 1.16