LCOV - code coverage report
Current view: top level - synthesis/CalTables - CTIter.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 4 4 100.0 %
Date: 2024-10-10 15:00:01 Functions: 4 4 100.0 %

          Line data    Source code
       1             : //# CTIter.h: Iterating interfaces for modern CalTables
       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             : 
      28             : #ifndef CALIBRATION_CALTABITER_H
      29             : #define CALIBRATION_CALTABITER_H
      30             : 
      31             : #include <casacore/casa/aips.h>
      32             : #include <casacore/tables/Tables/TableIter.h>
      33             : #include <casacore/measures/Measures/MBaseline.h>
      34             : #include <casacore/measures/Measures/MEpoch.h>
      35             : #include <casacore/ms/MSOper/MSDerivedValues.h>
      36             : #include <synthesis/CalTables/NewCalTable.h>
      37             : #include <synthesis/CalTables/CTMainColumns.h>
      38             : #include <synthesis/CalTables/CTColumns.h>
      39             : 
      40             : namespace casa { //# NAMESPACE CASA - BEGIN
      41             : 
      42             : // <summary> 
      43             : // ROCTIter: Read-only iterating interface to New Calibration tables
      44             : // </summary>
      45             : 
      46             : // <reviewed reviewer="" date="" tests="" demos="">
      47             : 
      48             : // <prerequisite>
      49             : //   <li> <linkto class="CalTableDesc">NewCalTable</linkto> module
      50             : // </prerequisite>
      51             : //
      52             : // <etymology>
      53             : // From "calibration", "table", and "iteration".
      54             : // </etymology>
      55             : //
      56             : // <synopsis>
      57             : // The ROCTIter class provide basic iterated access to the contents
      58             : // of a NewCalTable.  The iteration is initialized according to sort 
      59             : // columns specified in the constructor, and access to the contents
      60             : // of each iteration is provided via a NewCalTable object (referencing
      61             : // the iterated subset of the original NewCalTable) or methods that return
      62             : // Vectors or Arrays of the contents of specific columns.  For the latter,
      63             : // the Vectors/Arrays are generated only on-demand.
      64             : // </synopsis>
      65             : //
      66             : // <example>
      67             : // <srcblock>
      68             : // </srcblock>
      69             : // </example>
      70             : //
      71             : // <motivation>
      72             : // This class is used by calibration table clients to access calibration tables
      73             : //  in a piecemeal fashion, e.g., for plotting, interpolation, etc.
      74             : // </motivation>
      75             : //
      76             : // <todo asof="11/06/10">
      77             : // </todo>
      78             : 
      79             : class ROCTIter
      80             : {
      81             : public:
      82             :   // Constructor/Destructor 
      83             :   ROCTIter(NewCalTable tab,const casacore::Block<casacore::String>& sortcol);
      84             :   virtual ~ROCTIter();
      85             :   
      86             :   // Iteration operators
      87           2 :   inline void reset() { ti_->reset(); this->attach(); };
      88         284 :   inline casacore::Bool pastEnd() { return ti_->pastEnd(); };
      89             :   void next();
      90             :   void next0();
      91             : 
      92             :   // Return the current table iteration
      93         764 :   NewCalTable table() const { return NewCalTable(ti_->table()); };
      94             : 
      95         120 :   casacore::Int nrow() const { return ti_->table().nrow(); };
      96             : 
      97             :   // When not included in ctor table
      98             :   void setCTColumns(const NewCalTable& tab);
      99             : 
     100             :   // Column accessors
     101             :   // Those methods that return scalars for data coordinates 
     102             :   //  (e.g., thisTime(), thisField(), etc.) return the first element
     103             :   //  of the corresponding vector of values in the current 
     104             :   //  iteration.  This makes the most sense when the corresponding
     105             :   //  column is a sort column in the iteration, such that the contents
     106             :   //  of the vector is in fact a unique value.  (TBD: return -1 from
     107             :   //  scalar methods when column is not unique?)
     108             : 
     109             :   casacore::Double thisTime() const;
     110             :   casacore::Vector<casacore::Double> time() const;
     111             :   void time(casacore::Vector<casacore::Double>& v) const;
     112             : 
     113             :   casacore::Int thisField() const;
     114             :   casacore::Vector<casacore::Int> field() const;
     115             :   void field(casacore::Vector<casacore::Int>& v) const;
     116             : 
     117             :   casacore::Int thisSpw() const;
     118             :   casacore::Vector<casacore::Int> spw() const;
     119             :   void spw(casacore::Vector<casacore::Int>& v) const;
     120             : 
     121             :   casacore::Int thisScan() const;
     122             :   casacore::Vector<casacore::Int> scan() const;
     123             :   void scan(casacore::Vector<casacore::Int>& v) const;
     124             : 
     125             :   casacore::Int thisObs() const;
     126             :   casacore::Vector<casacore::Int> obs() const;
     127             :   void obs(casacore::Vector<casacore::Int>& v) const;
     128             : 
     129             :   casacore::Int thisAntenna1() const;
     130             :   casacore::Vector<casacore::Int> antenna1() const;
     131             :   void antenna1(casacore::Vector<casacore::Int>& v) const;
     132             :   casacore::Int thisAntenna2() const;
     133             :   casacore::Vector<casacore::Int> antenna2() const;
     134             :   void antenna2(casacore::Vector<casacore::Int>& v) const;
     135             : 
     136             :   casacore::Double thisInterval() const;
     137             :   casacore::Vector<casacore::Double> interval() const;
     138             :   void interval(casacore::Vector<casacore::Double>& v) const;
     139             : 
     140             :   casacore::Cube<casacore::Complex> cparam() const;
     141             :   void cparam(casacore::Cube<casacore::Complex>& c) const;
     142             : 
     143             :   casacore::Cube<casacore::Float> fparam() const;
     144             :   void fparam(casacore::Cube<casacore::Float>& c) const;
     145             : 
     146             :   casacore::Cube<casacore::Float> casfparam(casacore::String what="") const;
     147             :   void casfparam(casacore::Cube<casacore::Float>& casf, casacore::String what="") const;
     148             : 
     149             :   casacore::Cube<casacore::Float> paramErr() const;
     150             :   void paramErr(casacore::Cube<casacore::Float>& c) const;
     151             : 
     152             :   casacore::Cube<casacore::Float> snr() const;
     153             :   void snr(casacore::Cube<casacore::Float>& c) const;
     154             : 
     155             :   casacore::Cube<casacore::Float> wt() const;
     156             :   void wt(casacore::Cube<casacore::Float>& c) const;
     157             : 
     158             :   casacore::Cube<casacore::Bool> flag() const;
     159             :   void flag(casacore::Cube<casacore::Bool>& c) const;
     160             : 
     161             :   casacore::Int nchan() const;
     162             :   casacore::Vector<casacore::Int> chan() const;
     163             :   void chan(casacore::Vector<casacore::Int>& v) const;
     164             :   casacore::Vector<casacore::Double> freq() const;
     165             :   void freq(casacore::Vector<casacore::Double>& v) const;
     166             :   int freqFrame(int spwId) const;
     167             : 
     168             :   casacore::MDirection azel0(casacore::Double time);
     169             :   casacore::Double hourang(casacore::Double time);
     170             :   casacore::Float parang0(casacore::Double time);
     171             : 
     172             :   casacore::Matrix<casacore::Double> uvw();
     173             :  protected:
     174             : 
     175             :   // Attach accessors
     176             :   virtual void attach();
     177             :   
     178             :  private:
     179             : 
     180             :   // Prohibit public use of copy, assignment
     181             :   ROCTIter (const ROCTIter& other);
     182             :   ROCTIter& operator= (const ROCTIter& other);
     183             : 
     184             :   // Set epoch_ from first time measure
     185             :   void initEpoch();
     186             : 
     187             :   // Update phase center in MSDerivedValues
     188             :   void updatePhaseCenter();
     189             : 
     190             :   // Initialize and calculate uvw for each antenna.
     191             :   // Based on msvis MSUVWGenerator
     192             :   void initUVW();
     193             :   void updateAntennaUVW();
     194             : 
     195             :   // Remember the sort columns...
     196             :   casacore::Vector<casacore::String> sortCols_;
     197             : 
     198             :   // If true, spw is unique per iteration, and it is
     199             :   //   safe to access channel axis info
     200             :   casacore::Bool singleSpw_;
     201             : 
     202             :   // The parent NewCalTable (casacore::Table) object
     203             :   // (stays in scope for the life of the CTIter)
     204             :   NewCalTable parentNCT_;
     205             : 
     206             :   // Access to subtables (e.g., for frequencies)
     207             :   ROCTColumns* calCol_;
     208             : 
     209             :   // The underlying TableIterator
     210             :   casacore::TableIterator *ti_;
     211             : 
     212             :   // Per-iteration table
     213             :   NewCalTable *inct_;
     214             : 
     215             :   // Per-iteration columns
     216             :   ROCTMainColumns *iROCTMainCols_;
     217             : 
     218             :   // For calculated axes
     219             :   bool init_epoch_, init_uvw_;
     220             :   casacore::Int nAnt_;
     221             :   casacore::MDirection phaseCenter_;
     222             :   casacore::MEpoch epoch_;
     223             :   casacore::MPosition refAntPos_;
     224             :   casacore::MBaseline::Types baseline_type_;
     225             :   casacore::Vector<casacore::MVBaseline> mvbaselines_;              // ant pos rel to ant0
     226             :   casacore::Vector<casacore::Vector<casacore::Double>> antennaUVW_; // [u,v,w] for each ant
     227             : };
     228             : 
     229             : // Writable version (limited to certain 'columns')
     230             : class CTIter : public ROCTIter
     231             : {
     232             : public:
     233             :   // Constructor/Destructor 
     234             :   CTIter(NewCalTable tab,const casacore::Block<casacore::String>& sortcol);
     235             :   virtual ~CTIter();
     236             : 
     237             :   // Set fieldid
     238             :   void setfield(casacore::Int fieldid);
     239             : 
     240             :   // Set scan number
     241             :   void setscan(casacore::Int scan);
     242             : 
     243             :   // Set obsid
     244             :   void setobs(casacore::Int obs);
     245             : 
     246             :   // Set antenna2 (e.g., used for setting refant)
     247             :   void setantenna2(const casacore::Vector<casacore::Int>& a2);
     248             : 
     249             :   // Set the flags
     250             :   void setflag(const casacore::Cube<casacore::Bool>& flag);
     251             : 
     252             :   // Set the parameters
     253             :   void setfparam(const casacore::Cube<casacore::Float>& f);
     254             :   void setcparam(const casacore::Cube<casacore::Complex>& c);
     255             : 
     256             : protected:
     257             : 
     258             :   // Attach writable column access
     259             :   virtual void attach();
     260             : 
     261             : private:
     262             : 
     263             :   // Prohibit public use of copy, assignment
     264             :   CTIter (const CTIter& other);
     265             :   CTIter& operator= (const CTIter& other);
     266             : 
     267             :   // Per-iteration table
     268             :   NewCalTable *irwnct_;
     269             : 
     270             :   // Writable column access
     271             :   CTMainColumns *iRWCTMainCols_;
     272             : 
     273             : };
     274             : 
     275             : 
     276             : } //# NAMESPACE CASA - END
     277             : 
     278             : #endif

Generated by: LCOV version 1.16