LCOV - code coverage report
Current view: top level - msvis/MSVis - VisibilityIteratorImpl.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 42 87 48.3 %
Date: 2024-11-06 17:42:47 Functions: 21 61 34.4 %

          Line data    Source code
       1             : //# VisibilityIterator.h: Step through the MeasurementEquation by visibility
       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: VisibilityIterator.h,v 19.14 2006/02/28 04:48:58 mvoronko Exp $
      27             : 
      28             : #ifndef MSVIS_VISIBILITYITERATORIMPL_H
      29             : #define MSVIS_VISIBILITYITERATORIMPL_H
      30             : 
      31             : #include <stack>
      32             : #include <casacore/casa/aips.h>
      33             : #include <casacore/casa/Arrays/Matrix.h>
      34             : #include <casacore/casa/Arrays/Cube.h>
      35             : #include <casacore/casa/Arrays/Slicer.h>
      36             : #include <casacore/ms/MeasurementSets/MeasurementSet.h>
      37             : #include <casacore/measures/Measures/Stokes.h>
      38             : #include <casacore/measures/Measures/MeasConvert.h>
      39             : #include <casacore/casa/Quanta/MVDoppler.h>
      40             : #include <casacore/measures/Measures/MCDoppler.h>
      41             : #include <casacore/measures/Measures/MDoppler.h>
      42             : #include <casacore/tables/Tables/ArrayColumn.h>
      43             : #include <casacore/tables/Tables/ScalarColumn.h>
      44             : #include <casacore/casa/BasicSL/String.h>
      45             : #include <casacore/scimath/Mathematics/SquareMatrix.h>
      46             : #include <casacore/scimath/Mathematics/RigidVector.h>
      47             : 
      48             : #include <casacore/ms/MSOper/MSDerivedValues.h>
      49             : #include <msvis/MSVis/StokesVector.h>
      50             : #include <msvis/MSVis/VisImagingWeight.h>
      51             : #include <msvis/MSVis/VisibilityIterator.h>
      52             : #include <msvis/MSVis/VisBufferComponents.h>
      53             : #include <casacore/ms/MeasurementSets/MSIter.h>
      54             : 
      55             : #include <map>
      56             : #include <vector>
      57             : 
      58             : namespace casa { //# NAMESPACE CASA - BEGIN
      59             : 
      60             : //# forward decl
      61             : class VisBuffer;
      62             : 
      63             : 
      64             : 
      65             : // <summary>
      66             : // ROVisibilityIterator iterates through one or more readonly MeasurementSets
      67             : // </summary>
      68             : 
      69             : // <use visibility=export>
      70             : 
      71             : // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
      72             : // </reviewed>
      73             : 
      74             : // <prerequisite>
      75             : //   <li> <linkto class="MSIter">MSIter</linkto>
      76             : //   <li> <linkto class="casacore::MeasurementSet">casacore::MeasurementSet</linkto>
      77             : //   <li> <linkto class="VisSet">VisSet</linkto>
      78             : // </prerequisite>
      79             : //
      80             : // <etymology>
      81             : // The ROVisibilityIterator is a readonly iterator returning visibilities
      82             : // </etymology>
      83             : //
      84             : // <synopsis>
      85             : // ROVisibilityIterator provides iteration with various sort orders
      86             : // for one or more MSs. It has member functions to retrieve the fields
      87             : // commonly needed in synthesis calibration and imaging.
      88             : //
      89             : // One should use <linkto class="VisBuffer">VisBuffer</linkto>
      90             : // to access chunks of data.
      91             : // </synopsis>
      92             : //
      93             : // <example>
      94             : // <code>
      95             : // //
      96             : // </code>
      97             : // </example>
      98             : //
      99             : // <motivation>
     100             : // For imaging and calibration you need to access an casacore::MS in some consistent
     101             : // order (by field, spectralwindow, time interval etc.). This class provides
     102             : // that access.
     103             : // </motivation>
     104             : //
     105             : // <thrown>
     106             : //    <li>
     107             : //    <li>
     108             : // </thrown>
     109             : //
     110             : // <todo asof="1997/05/30">
     111             : //   <li> cleanup the currently dual interface for visibilities and flags
     112             : //   <li> sort out what to do with weights when interpolating
     113             : // </todo>
     114             : 
     115             : class VisibilityIteratorReadImpl {
     116             : 
     117             :     friend class AsyncEnabler;
     118             :     friend class ViReadImplAsync;
     119             :     friend class VisibilityIteratorWriteImpl;
     120             :     friend class ROVisibilityIterator;
     121             :     friend class ROVisIterator;
     122             :     friend class VisIterator;
     123             :     friend class VLAT; // allow VI lookahead thread class to access protected functions
     124             :     // VLAT should not access private parts, especially variables
     125             : 
     126             : public:
     127             : 
     128             :     //# the following is a copy of the enum in MSIter
     129             :     //# can't think of a way to get one that known to the outside world from here
     130             :     //  enum PolFrame {
     131             :     //    // Circular polarization
     132             :     //    Circular=0,
     133             :     //    // Linear polarization
     134             :     //    Linear=1
     135             :     //  };
     136             :     //
     137             :     //  enum DataColumn {
     138             :     //    // Observed data
     139             :     //    Observed=0,
     140             :     //    // Model data
     141             :     //    Model,
     142             :     //    // Corrected data
     143             :     //    Corrected
     144             :     //  };
     145             : 
     146             :     typedef ROVisibilityIterator::DataColumn DataColumn;
     147             : 
     148             :     //    class AsyncEnabler {
     149             :     //    public:
     150             :     //        AsyncEnabler (ROVisibilityIterator &);
     151             :     //        AsyncEnabler (ROVisibilityIterator *);
     152             :     //        ~AsyncEnabler ();
     153             :     //
     154             :     //        void release ();
     155             :     //
     156             :     //    private:
     157             :     //
     158             :     //        casacore::Bool oldEnabledState_p;
     159             :     //        ROVisibilityIterator * roVisibilityIterator_p;
     160             :     //    };
     161             : 
     162             :     // Default constructor - useful only to assign another iterator later
     163             :     VisibilityIteratorReadImpl ();
     164             : 
     165             :     // Construct from an casacore::MS and a casacore::Block of casacore::MS column enums specifying the
     166             :     // iteration order.  If no order is specified, it uses the default sort
     167             :     // order of MSIter, which is not necessarily the raw order of ms!
     168             :     // The default ordering is ARRAY_ID, FIELD_ID, DATA_DESC_ID,
     169             :     // and TIME, but check MSIter.h to be sure.
     170             :     // These columns will be added first if they are not specified.
     171             :     //
     172             :     // An optional timeInterval (in seconds) can be given to iterate through
     173             :     // chunks of time.  The default interval of 0 groups all times together.
     174             :     // Every 'chunk' of data contains all data within a certain time interval and
     175             :     // with identical values of the other iteration columns (e.g.  DATA_DESC_ID
     176             :     // and FIELD_ID).  Using selectChannel (), a number of groups of channels can
     177             :     // be requested.  At present the channel group iteration will always occur
     178             :     // before the interval iteration.
     179             : //    VisibilityIteratorReadImpl (const casacore::MeasurementSet & ms,
     180             : //                                const casacore::Block<casacore::Int> & sortColumns,
     181             : //                                casacore::Double timeInterval = 0);
     182             : 
     183             :     // Same as above, but with the option of using the raw order of ms
     184             :     // (addDefaultSortCols=false).
     185             : //    VisibilityIteratorReadImpl (const casacore::MeasurementSet & ms,
     186             : //                                const casacore::Block<casacore::Int> & sortColumns, const casacore::Bool addDefaultSortCols,
     187             : //                                casacore::Double timeInterval = 0);
     188             : 
     189             :     // Same as previous constructors, but with multiple MSs to iterate over.
     190             : //    VisibilityIteratorReadImpl (const casacore::Block<casacore::MeasurementSet> & mss,
     191             : //                                const casacore::Block<casacore::Int> & sortColumns,
     192             : //                                casacore::Double timeInterval = 0);
     193             : 
     194             :     VisibilityIteratorReadImpl (ROVisibilityIterator * rovi,
     195             :                                 const casacore::Block<casacore::MeasurementSet> & mss,
     196             :                                 const casacore::Block<casacore::Int> & sortColumns,
     197             :                                 const casacore::Bool addDefaultSortCols,
     198             :                                 casacore::Double timeInterval);
     199             : 
     200             :     // Copy construct. This calls the assigment operator.
     201             :     VisibilityIteratorReadImpl (const VisibilityIteratorReadImpl & other,
     202             :                                 ROVisibilityIterator * rovi);
     203             : 
     204             :     // Assigment. Any attached VisBuffers are lost in the assign.
     205             :     VisibilityIteratorReadImpl & operator= (const VisibilityIteratorReadImpl & other);
     206             : 
     207             :     // Destructor
     208             :     virtual ~VisibilityIteratorReadImpl ();
     209             : 
     210             :     virtual VisibilityIteratorReadImpl * clone (ROVisibilityIterator * rovi) const;
     211             : 
     212             :     // Members
     213             : 
     214             :     casacore::Bool isAsyncEnabled () const;
     215             : 
     216           0 :     virtual casacore::Bool isWritable () const {
     217           0 :         return false;
     218             :     }
     219             : 
     220             :     // Reset iterator to origin/start of data (of current chunk)
     221             :     virtual void origin ();
     222             :     // Reset iterator to true start of data (first chunk)
     223             :     virtual void originChunks ();
     224             : 
     225             :     // Return the time interval (in seconds) used for iteration.
     226             :     // This is not the same as the INTERVAL column.
     227           0 :     virtual casacore::Double getInterval() const { return timeInterval_p; }
     228             : 
     229             :     // Set or reset the time interval (in seconds) to use for iteration.
     230             :     // You should call originChunks () to reset the iteration after
     231             :     // calling this.
     232           0 :     virtual void setInterval (casacore::Double timeInterval) {
     233           0 :         msIter_p.setInterval (timeInterval);
     234           0 :         timeInterval_p = timeInterval;
     235           0 :     }
     236             : 
     237             :     // Set the 'blocking' size for returning data.
     238             :     // With the default (0) only a single integration is returned at a time, this
     239             :     // is what is currently required for the calibration software. With blocking
     240             :     // set, up to nRows can be returned in one go. The chunk
     241             :     // size determines the actual maximum.
     242             :     virtual void setRowBlocking (casacore::Int nRows = 0);
     243             : 
     244             :     virtual casacore::Bool existsColumn (VisBufferComponents::EnumType id) const;
     245             : 
     246             :     // Return false if no more data (in current chunk)
     247             :     virtual casacore::Bool more () const;
     248             : 
     249             :     virtual SubChunkPair getSubchunkId () const;
     250             : 
     251             :     virtual const casacore::Block<casacore::Int>& getSortColumns() const;
     252             : 
     253             :     // Return false if no more 'Chunks' of data left
     254       21390 :     virtual casacore::Bool moreChunks () const {
     255       21390 :         return msIter_p.more ();
     256             :     }
     257             : 
     258             :     // Check if ms has change since last iteration
     259        6344 :     virtual casacore::Bool newMS () const {
     260        6344 :         return msIter_p.newMS ();
     261             :     }
     262             : 
     263       82516 :     virtual casacore::Int msId () const {
     264       82516 :         return msIter_p.msId ();
     265             :     }
     266             : 
     267             :     virtual VisBuffer * getVisBuffer ();
     268             : 
     269             :     //reference to actual ms in interator
     270        7087 :     virtual const casacore::MeasurementSet & ms () const {
     271        7087 :         return msIter_p.ms ();
     272             :     }
     273             :     // Advance to the next Chunk of data
     274             :     virtual VisibilityIteratorReadImpl & nextChunk ();
     275             : 
     276             :     // Return antenna1
     277             :     virtual casacore::Vector<casacore::Int> & antenna1 (casacore::Vector<casacore::Int> & ant1) const;
     278             : 
     279             :     // Return antenna2
     280             :     virtual casacore::Vector<casacore::Int> & antenna2 (casacore::Vector<casacore::Int> & ant2) const;
     281             : 
     282             :     // Return feed1
     283             :     virtual casacore::Vector<casacore::Int> & feed1 (casacore::Vector<casacore::Int> & fd1) const;
     284             : 
     285             :     // Return feed2
     286             :     virtual casacore::Vector<casacore::Int> & feed2 (casacore::Vector<casacore::Int> & fd2) const;
     287             : 
     288             :     // Return channel numbers in selected VisSet spectrum
     289             :     // (i.e. disregarding possible selection on the iterator, but
     290             :     //  including the selection set when creating the VisSet)
     291             :     virtual casacore::Vector<casacore::Int> & channel (casacore::Vector<casacore::Int> & chan) const;
     292             : 
     293             :     // Return feed configuration matrix for specified antenna
     294             :     virtual casacore::Vector<casacore::SquareMatrix<casacore::Complex, 2> > &
     295             :     CJones (casacore::Vector<casacore::SquareMatrix<casacore::Complex, 2> > & cjones) const;
     296             : 
     297             :     // Return receptor angles for all antennae and feeds
     298             :     // First axis of the cube is a receptor number,
     299             :     // 2nd is antennaId, 3rd is feedId
     300             :     // Note: the method is intended to provide an access to MSIter::receptorAngles
     301             :     // for VisBuffer in the multi-feed case. It may be worth to change the
     302             :     // interface of feed_pa to return the information for all feeds.
     303             :     virtual const casacore::Cube<casacore::Double> & receptorAngles () const;
     304             : 
     305             :     // return a string mount identifier for each antenna
     306             :     virtual const casacore::Vector<casacore::String> & antennaMounts () const;
     307             : 
     308             :     // Return a cube containing pairs of coordinate offsets for each
     309             :     // receptor of each feed (values are in radians, coordinate system is fixed
     310             :     // with antenna and is the same one as used to define the BEAM_OFFSET
     311             :     // parameter in the feed table). The cube axes are receptor, antenna, feed.
     312             :     virtual const casacore::Cube<casacore::RigidVector<casacore::Double, 2> > & getBeamOffsets () const;
     313             : 
     314             :     // true if all elements of the cube returned by getBeamOffsets are zero
     315             :     virtual casacore::Bool allBeamOffsetsZero () const;
     316             : 
     317             :     // Return feed parallactic angles casacore::Vector (nant) (1 feed/ant)
     318             :     virtual casacore::Vector<casacore::Float> feed_pa (casacore::Double time) const;
     319             :     static casacore::Vector<casacore::Float> feed_paCalculate (casacore::Double time, casacore::MSDerivedValues & msd,
     320             :                                            casacore::Int nAntennas, const casacore::MEpoch & mEpoch0,
     321             :                                            const casacore::Vector<casacore::Float> & receptor0Angle);
     322             : 
     323             :     // Return nominal parallactic angle at specified time
     324             :     // (does not include feed position angle offset--see feed_pa)
     325             :     // A global value for all antennas (e.g., small array)
     326             :     virtual const casacore::Float & parang0 (casacore::Double time) const;
     327             :     static casacore::Float parang0Calculate (casacore::Double time, casacore::MSDerivedValues & msd, const casacore::MEpoch & epoch0);
     328             : 
     329             :     // Per antenna:
     330             :     virtual casacore::Vector<casacore::Float> parang (casacore::Double time) const;
     331             :     static casacore::Vector<casacore::Float> parangCalculate (casacore::Double time, casacore::MSDerivedValues & msd,
     332             :                                           int nAntennas, const casacore::MEpoch mEpoch0);
     333             : 
     334             :     // Return the antenna AZ/EL casacore::Vector (nant)
     335             :     virtual casacore::MDirection azel0 (casacore::Double time) const;
     336             :     static void azel0Calculate (casacore::Double time, casacore::MSDerivedValues & msd,
     337             :                                 casacore::MDirection & azel0, const casacore::MEpoch & mEpoch0);
     338             : 
     339             :     virtual casacore::Vector<casacore::MDirection> azel (casacore::Double time) const;
     340             :     static void azelCalculate (casacore::Double time, casacore::MSDerivedValues & msd, casacore::Vector<casacore::MDirection> & azel,
     341             :                                casacore::Int nAnt, const casacore::MEpoch & mEpoch0);
     342             : 
     343             : 
     344             :     // Return the hour angle for the specified time
     345             :     virtual casacore::Double hourang (casacore::Double time) const;
     346             :     static casacore::Double hourangCalculate (casacore::Double time, casacore::MSDerivedValues & msd, const casacore::MEpoch & mEpoch0);
     347             : 
     348             :     // Return the current FieldId
     349       24089 :     virtual casacore::Int fieldId () const {
     350       24089 :         return msIter_p.fieldId ();
     351             :     }
     352             : 
     353             :     // Return the current ArrayId
     354         629 :     virtual casacore::Int arrayId () const {
     355         629 :         return msIter_p.arrayId ();
     356             :     }
     357             : 
     358             :     // Return the current Field Name
     359           4 :     virtual casacore::String fieldName () const {
     360           4 :         return msIter_p.fieldName ();
     361             :     }
     362             : 
     363             :     // Return the current Source Name
     364           0 :     virtual casacore::String sourceName () const {
     365           0 :         return msIter_p.sourceName ();
     366             :     }
     367             : 
     368             :     // Return flag for each polarization, channel and row
     369             :     virtual casacore::Cube<casacore::Bool> & flag (casacore::Cube<casacore::Bool> & flags) const;
     370             : 
     371             :     // Return flag for each channel & row
     372             :     virtual casacore::Matrix<casacore::Bool> & flag (casacore::Matrix<casacore::Bool> & flags) const;
     373             : 
     374             :     // Determine whether FLAG_CATEGORY is valid.
     375             :     casacore::Bool existsFlagCategory() const;
     376             : 
     377             :     // Return flags for each polarization, channel, category, and row.
     378             :     virtual casacore::Array<casacore::Bool> & flagCategory (casacore::Array<casacore::Bool> & flagCategories) const;
     379             : 
     380             :     // Return row flag
     381             :     virtual casacore::Vector<casacore::Bool> & flagRow (casacore::Vector<casacore::Bool> & rowflags) const;
     382             : 
     383             :     // Return scan number
     384             :     virtual casacore::Vector<casacore::Int> & scan (casacore::Vector<casacore::Int> & scans) const;
     385             : 
     386             :     // Return the OBSERVATION_IDs
     387             :     virtual casacore::Vector<casacore::Int> & observationId (casacore::Vector<casacore::Int> & obsids) const;
     388             : 
     389             :     // Return the PROCESSOR_IDs
     390             :     virtual casacore::Vector<casacore::Int> & processorId (casacore::Vector<casacore::Int> & procids) const;
     391             : 
     392             :     // Return the STATE_IDs
     393             :     virtual casacore::Vector<casacore::Int> & stateId (casacore::Vector<casacore::Int> & stateids) const;
     394             : 
     395             :     // Return current frequencies (in Hz, acc. to the casacore::MS def'n v.2)
     396             :     virtual casacore::Vector<casacore::Double> & frequency (casacore::Vector<casacore::Double> & freq) const;
     397             : 
     398             :     // Return frequencies  (in Hz, acc. to the casacore::MS def'n v.2) in selected velocity frame,
     399             :     // returns the same as frequency () if there is no vel selection active.
     400             :     virtual casacore::Vector<casacore::Double> & lsrFrequency (casacore::Vector<casacore::Double> & freq) const;
     401             : 
     402             :     // Return the current phase center as an MDirection
     403         355 :     virtual const casacore::MDirection & phaseCenter () const {
     404         355 :         return msIter_p.phaseCenter ();
     405             :     }
     406             :     
     407        6239 :     virtual const casacore::MDirection  phaseCenter (const casacore::Int fieldId, const casacore::Double time=-1.0) const {
     408        6239 :       return time >0.0 ? msIter_p.phaseCenter (fieldId, time) : msIter_p.phaseCenter () ;
     409             :     }
     410             :     // Return frame for polarization (returns PolFrame enum)
     411       12494 :     virtual casacore::Int polFrame () const {
     412       12494 :         return msIter_p.polFrame ();
     413             :     }
     414             : 
     415             :     // Return the correlation type (returns casacore::Stokes enums)
     416             :     virtual casacore::Vector<casacore::Int> & corrType (casacore::Vector<casacore::Int> & corrTypes) const;
     417             : 
     418             :     // Return sigma
     419             :     virtual casacore::Vector<casacore::Float> & sigma (casacore::Vector<casacore::Float> & sig) const;
     420             : 
     421             :     // Return sigma matrix (pol-dep)
     422             :     virtual casacore::Matrix<casacore::Float> & sigmaMat (casacore::Matrix<casacore::Float> & sigmat) const;
     423             : 
     424             :     // Return current SpectralWindow
     425       35372 :     virtual casacore::Int spectralWindow () const {
     426       35372 :         return msIter_p.spectralWindowId ();
     427             :     }
     428             : 
     429             :     // Return current Polarization Id
     430          42 :     virtual casacore::Int polarizationId () const {
     431          42 :         return msIter_p.polarizationId ();
     432             :     }
     433             : 
     434             :     // Return current DataDescription Id
     435         264 :     virtual casacore::Int dataDescriptionId () const {
     436         264 :         return msIter_p.dataDescriptionId ();
     437             :     }
     438             : 
     439             :     // Return MJD midpoint of interval.
     440             :     virtual casacore::Vector<casacore::Double> & time (casacore::Vector<casacore::Double> & t) const;
     441             : 
     442             :     // Return MJD centroid of interval.
     443             :     virtual casacore::Vector<casacore::Double> & timeCentroid (casacore::Vector<casacore::Double> & t) const;
     444             : 
     445             :     // Return nominal time interval
     446             :     virtual casacore::Vector<casacore::Double> & timeInterval (casacore::Vector<casacore::Double> & ti) const;
     447             : 
     448             :     // Return actual time interval
     449             :     virtual casacore::Vector<casacore::Double> & exposure (casacore::Vector<casacore::Double> & expo) const;
     450             : 
     451             :     // Return the visibilities as found in the casacore::MS, casacore::Cube (npol,nchan,nrow).
     452             :     virtual casacore::Cube<casacore::Complex> & visibility (casacore::Cube<casacore::Complex> & vis,
     453             :                                         DataColumn whichOne) const;
     454             : 
     455             :     // Return FLOAT_DATA as a casacore::Cube (npol, nchan, nrow) if found in the MS.
     456             :     virtual casacore::Cube<casacore::Float> & floatData (casacore::Cube<casacore::Float> & fcube) const;
     457             : 
     458             :     // Return the visibility 4-vector of polarizations for each channel.
     459             :     // If the casacore::MS doesn't contain all polarizations, it is assumed it
     460             :     // contains one or two parallel hand polarizations.
     461             :     virtual casacore::Matrix<CStokesVector> & visibility (casacore::Matrix<CStokesVector> & vis,
     462             :                                                 DataColumn whichOne) const;
     463             : 
     464             :     // Return the shape of the visibility Cube
     465             :     virtual casacore::IPosition visibilityShape () const;
     466             : 
     467             :     // Return u,v and w (in meters)
     468             :     virtual casacore::Vector<casacore::RigidVector<casacore::Double, 3> > & uvw (casacore::Vector<casacore::RigidVector<casacore::Double, 3> > & uvwvec) const;
     469             :     virtual casacore::Matrix<casacore::Double> & uvwMat (casacore::Matrix<casacore::Double> & uvwmat) const;
     470             : 
     471             :     // Return weight
     472             :     virtual casacore::Vector<casacore::Float> & weight (casacore::Vector<casacore::Float> & wt) const;
     473             : 
     474             :     // Returns the nPol_p x curNumRow_p weight matrix
     475             :     virtual casacore::Matrix<casacore::Float> & weightMat (casacore::Matrix<casacore::Float> & wtmat) const;
     476             : 
     477             :     // Determine whether WEIGHT_SPECTRUM exists.
     478             :     casacore::Bool existsWeightSpectrum () const;
     479             : 
     480             :     // Return weightspectrum (a weight for each channel)
     481             :     virtual casacore::Cube<casacore::Float> & weightSpectrum (casacore::Cube<casacore::Float> & wtsp) const;
     482             : 
     483             :     // Return imaging weight (a weight for each channel)
     484             :     //virtual casacore::Matrix<casacore::Float> & imagingWeight (casacore::Matrix<casacore::Float> & wt) const;
     485             :     const VisImagingWeight & getImagingWeightGenerator () const;
     486             : 
     487             :     // Return true if FieldId/Source has changed since last iteration
     488           0 :     virtual casacore::Bool newFieldId () const {
     489           0 :         return (curStartRow_p == 0 && msIter_p.newField ());
     490             :     }
     491             : 
     492             :     // Return true if arrayID has changed since last iteration
     493           0 :     virtual casacore::Bool newArrayId () const {
     494           0 :         return (curStartRow_p == 0 && msIter_p.newArray ());
     495             :     }
     496             : 
     497             :     // Return true if SpectralWindow has changed since last iteration
     498           0 :     virtual casacore::Bool newSpectralWindow () const {
     499           0 :         return (curStartRow_p == 0 && msIter_p.newSpectralWindow ());
     500             :     }
     501             : 
     502             :     // Return the index of the first channel of the current channel group
     503             :     // in the total (selected) spectrum.
     504             :     virtual casacore::Int channelIndex () const;
     505             : 
     506             :     // Return the width of the current group of channels, i.e.,
     507             :     // the number of channels returned by visibility () and frequency ().
     508             :     virtual casacore::Int channelGroupSize () const;
     509             : 
     510             :     // Return the number of correlations in the current iteration
     511           2 :     virtual casacore::Int nCorr () const {
     512           2 :         return nPol_p;
     513             :     };
     514             : 
     515             :     // Return the number of rows in the current iteration
     516             :     virtual casacore::Int nRow () const;
     517             : 
     518             :     // Return the row ids as from the original root table. This is useful
     519             :     // to find correspondance between a given row in this iteration to the
     520             :     // original ms row
     521             :     virtual casacore::Vector<casacore::rownr_t> & rowIds (casacore::Vector<casacore::rownr_t> & rowids) const;
     522             : 
     523             :     // Return the numbers of rows in the current chunk
     524             :     virtual casacore::Int nRowChunk () const;
     525             : 
     526             :     // Return the number of sub-intervals in the current chunk
     527             :     virtual casacore::Int nSubInterval () const;
     528             : 
     529             :     // Call to use the slurp i/o method for all scalar columns. This
     530             :     // will set the casacore::BucketCache cache size to the full column length
     531             :     // and cause the full column to be cached in memory, if
     532             :     // any value of the column is used. In case of out-of-memory,
     533             :     // it will automatically fall-back on the smaller cache size.
     534             :     // Slurping the column is to be considered as a work-around for the
     535             :     // casacore::Table i/o code, which uses casacore::BucketCache and performs extremely bad
     536             :     // for random access. Slurping is useful when iterating non-sequentially
     537             :     // an casacore::MS or parts of an casacore::MS, it is not tested with multiple MSs.
     538             :     virtual void slurp () const;
     539             : 
     540             :     // Velocity selection - specify the output channels in velocity:
     541             :     // nChan - number of output channels, vStart - start velocity,
     542             :     // vInc - velocity increment. So channel i will have velocity
     543             :     // vStart + i*vInc (i=0,nChan-1).
     544             :     // Specify velocities as in e.g., casacore::MVRadialVelocity (casacore::Quantity (2001.,"km/s")).
     545             :     // The reference type and velocity definition are specified separately.
     546             :     // Note that no averaging is performed, the visibilities will be interpolated
     547             :     // and sampled at the specified velocities, it's up to you to choose a vInc
     548             :     // appropriate to the channel width.
     549             :     // The REST_FREQUENCY column in the SPECTRAL_WINDOW subtable is used to
     550             :     // determine the velocity-frequency conversion.
     551             :     // By default calculations are done for a single velocity with offsets
     552             :     // applied for the others (ok for non-rel velocities with RADIO defn),
     553             :     // set precise to true to do a full conversion for each output channel. (NYI)
     554             :     virtual VisibilityIteratorReadImpl &
     555             :     selectVelocity (casacore::Int nChan,
     556             :                     const casacore::MVRadialVelocity & vStart, const casacore::MVRadialVelocity & vInc,
     557             :                     casacore::MRadialVelocity::Types rvType = casacore::MRadialVelocity::LSR,
     558             :                     casacore::MDoppler::Types dType = casacore::MDoppler::RADIO, casacore::Bool precise = false);
     559             : 
     560             :     // Select the velocity interpolation scheme.
     561             :     // At present the choice is limited to : nearest and linear, linear
     562             :     // is the default.
     563             :     // TODO: add cubic, spline and possibly FFT
     564           0 :     virtual VisibilityIteratorReadImpl & velInterpolation (const casacore::String & /*type*/) {return * this; }
     565             : 
     566             :     // Channel selection - only the selected channels will be returned by the
     567             :     // access functions. The default spectralWindow is the current one (or 0)
     568             :     // This allows selection of the input channels, producing
     569             :     // nGroup groups of width output channels. Default is to return all channels
     570             :     // in a single group.
     571             :     virtual VisibilityIteratorReadImpl & selectChannel (casacore::Int nGroup = 1, casacore::Int start = 0, casacore::Int width = 0,
     572             :                                                         casacore::Int increment = 1, casacore::Int spectralWindow = -1);
     573             : 
     574             :     //Same as above except when multiple ms's are to be accessed
     575             : 
     576             :     virtual VisibilityIteratorReadImpl & selectChannel (const casacore::Block< casacore::Vector<casacore::Int> > & blockNGroup,
     577             :                                                         const casacore::Block< casacore::Vector<casacore::Int> > & blockStart,
     578             :                                                         const casacore::Block< casacore::Vector<casacore::Int> > & blockWidth,
     579             :                                                         const casacore::Block< casacore::Vector<casacore::Int> > & blockIncr,
     580             :                                                         const casacore::Block< casacore::Vector<casacore::Int> > & blockSpw);
     581             : 
     582             : 
     583             :     //get the channel selection ...the block over the number of ms's associated
     584             :     // with this iterator
     585             :     virtual void getChannelSelection (casacore::Block< casacore::Vector<casacore::Int> > & blockNGroup,
     586             :                                       casacore::Block< casacore::Vector<casacore::Int> > & blockStart,
     587             :                                       casacore::Block< casacore::Vector<casacore::Int> > & blockWidth,
     588             :                                       casacore::Block< casacore::Vector<casacore::Int> > & blockIncr,
     589             :                                       casacore::Block< casacore::Vector<casacore::Int> > & blockSpw);
     590             : 
     591             :     // Translate slicesv from the form returned by casacore::MSSelection::getChanSlices ()
     592             :     // to matv as used by setChanAveBounds ().  widthsv is the channel averaging
     593             :     // width for each _selected_ spw.
     594             :     void slicesToMatrices (casacore::Vector<casacore::Matrix<casacore::Int> > & matv,
     595             :                            const casacore::Vector<casacore::Vector<casacore::Slice> > & slicesv,
     596             :                            const casacore::Vector<casacore::Int> & widthsv) const;
     597             : 
     598             :     // Get the spw, start  and nchan for all the ms's is this Visiter that
     599             :     // match the frequecy "freqstart-freqStep" and "freqEnd+freqStep" range
     600             :     // Can help in doing channel selection above..
     601             :     // freqFrame is the frame the caller frequency values are in (freqStart and freqEnd)
     602             :     // These will be converted to the frame of the selected spw to match
     603             : 
     604             :     virtual void getSpwInFreqRange (casacore::Block<casacore::Vector<casacore::Int> > & spw,
     605             :                                     casacore::Block<casacore::Vector<casacore::Int> > & start,
     606             :                                     casacore::Block<casacore::Vector<casacore::Int> > & nchan,
     607             :                                     casacore::Double freqStart, casacore::Double freqEnd,
     608             :                                     casacore::Double freqStep, casacore::MFrequency::Types freqFrame = casacore::MFrequency::LSRK) const;
     609             : 
     610             :     // Get the range of frequency convered by the selected data in the frame requested
     611             : 
     612             :     virtual void getFreqInSpwRange(casacore::Double& freqStart, casacore::Double& freqEnd, casacore::MFrequency::Types freqframe = casacore::MFrequency::LSRK) const;
     613             : 
     614             :     // Attach a VisBuffer object.
     615             :     // Note that while more than one VisBuffer may be attached, only the
     616             :     // last one is actively updated. A casacore::Stack is kept internally, so after
     617             :     // a detach, the previous VisBuffer becomes active again.
     618             :     virtual void attachVisBuffer (VisBuffer & vb);
     619             : 
     620             :     // Detach a VisBuffer object.
     621             :     // If the object detached is not the last one attached an exception
     622             :     // is thrown.
     623             :     virtual void detachVisBuffer (VisBuffer & vb);
     624             : 
     625             :     // Access the current casacore::MSColumns object in MSIter
     626      252624 :     virtual const casacore::MSColumns & msColumns () const {
     627      252624 :         return msIter_p.msColumns ();
     628             :     }
     629             : 
     630             :     // get back the selected spectral windows and spectral channels for
     631             :     // current ms
     632             : 
     633             :     virtual void allSelectedSpectralWindows (casacore::Vector<casacore::Int> & spws, casacore::Vector<casacore::Int> & nvischan);
     634             : 
     635             :     // Convert the frequency from the observe frame to lsr frame.
     636             :     // Returns true in convert if given spw was not observed
     637             :     // in the LSRK frame
     638             :     // if ignoreconv=true then conversion from frame in data 
     639             :     //is ignored by request
     640             :     virtual void lsrFrequency (const casacore::Int & spw, casacore::Vector<casacore::Double> & freq, casacore::Bool & convert, const casacore::Bool ignoreconv=false);
     641             :     //assign a VisImagingWeight object to this iterator
     642             :     virtual void useImagingWeight (const VisImagingWeight & imWgt);
     643             :     //return number  of Ant
     644             :     virtual casacore::Int numberAnt ();
     645             :     //Return number of rows in all selected ms's
     646             :     virtual casacore::Int numberCoh ();
     647             : 
     648             :     // Return number of spws, polids, ddids
     649             :     virtual casacore::Int numberSpw ();
     650             :     virtual casacore::Int numberPol ();
     651             :     virtual casacore::Int numberDDId ();
     652             : 
     653             :     casacore::ArrayColumn <casacore::Double> & getChannelFrequency () const;
     654             :     casacore::Block<casacore::Int> getChannelGroupNumber () const;
     655             :     casacore::Block<casacore::Int> getChannelIncrement () const;
     656             :     casacore::Block<casacore::Int> getChannelStart () const;
     657             :     casacore::Block<casacore::Int> getChannelWidth () const;
     658             :     casacore::Int getDataDescriptionId () const;
     659             :     const casacore::MeasurementSet & getMeasurementSet () const;;
     660             :     casacore::Int getMeasurementSetId () const;
     661             :     casacore::Int getNAntennas () const;
     662             :     virtual casacore::MEpoch getEpoch () const;
     663             :     casacore::MFrequency::Types getObservatoryFrequencyType () const; //???
     664             :     casacore::MPosition getObservatoryPosition () const;
     665             :     casacore::MDirection getPhaseCenter () const;
     666             :     casacore::Vector<casacore::Float> getReceptor0Angle ();
     667             :     casacore::Vector<casacore::rownr_t> getRowIds () const;
     668             : 
     669             :     static void lsrFrequency (const casacore::Int & spw,
     670             :                               casacore::Vector<casacore::Double> & freq,
     671             :                               casacore::Bool & convert,
     672             :                               const casacore::Block<casacore::Int> & chanStart,
     673             :                               const casacore::Block<casacore::Int> & chanWidth,
     674             :                               const casacore::Block<casacore::Int> & chanInc,
     675             :                               const casacore::Block<casacore::Int> & numChanGroup,
     676             :                               const casacore::ArrayColumn <casacore::Double> & chanFreqs,
     677             :                               const casacore::ScalarColumn<casacore::Int> & obsMFreqTypes,
     678             :                               const casacore::MEpoch & ep,
     679             :                               const casacore::MPosition & obsPos,
     680             :                               const casacore::MDirection & dir,
     681             :                               const casacore::Bool ignoreconv=false);
     682             : 
     683             : protected:
     684             : 
     685             :     void attachColumnsSafe (const casacore::Table & t);
     686             : 
     687             :     // advance the iteration
     688             :     virtual void advance ();
     689             :     // set the currently selected table
     690             :     virtual void setSelTable ();
     691             :     // set the iteration state
     692             :     virtual void setState ();
     693             :     // get the TOPO frequencies from the selected velocities and the obs. vel.
     694             :     virtual void getTopoFreqs ();
     695             :     virtual void getTopoFreqs (casacore::Vector<casacore::Double> & lsrFreq, casacore::Vector<casacore::Double> & selFreq); // for async i/o
     696             : 
     697             :     virtual void getLsrInfo (casacore::Block<casacore::Int> & channelGroupNumber,
     698             :                              casacore::Block<casacore::Int> & channelIncrement,
     699             :                              casacore::Block<casacore::Int> & channelStart,
     700             :                              casacore::Block<casacore::Int> & channelWidth,
     701             :                              casacore::MPosition & observatoryPositon,
     702             :                              casacore::MDirection & phaseCenter,
     703             :                              casacore::Bool & velocitySelection) const;
     704             : 
     705             :     std::vector<casacore::MeasurementSet> getMeasurementSets () const;
     706             : 
     707             :     const casacore::MSDerivedValues & getMSD () const; // for use by Async I/O *ONLY*
     708             : 
     709             :     // update the DATA slicer
     710             :     virtual void updateSlicer ();
     711             :     // attach the column objects to the currently selected table
     712             :     virtual void attachColumns (const casacore::Table & t);
     713             :     // returns the table, to which columns are attached,
     714             :     // can be overridden in derived classes
     715             :     virtual const casacore::Table attachTable () const;
     716             : 
     717             :     // get the (velocity selected) interpolated visibilities, flags and weights.
     718             :     // It is not really const at all (it seems to use This-> trickery so callers
     719             :     // like flag () can be declared const).
     720             : 
     721             : //    virtual void getInterpolatedVisFlagWeight (DataColumn whichOne) const;
     722             : 
     723             :     // get the (velocity selected) interpolated FLOAT_DATA (as real Floats),
     724             :     // flags and weights.
     725             : 
     726             : //    void getInterpolatedFloatDataFlagWeight () const;
     727             : 
     728             :     casacore::Bool usesTiledDataManager (const casacore::String & columnName, const casacore::MeasurementSet & ms) const;
     729             : 
     730             :     // get the visibility data (observed, corrected or model);
     731             :     // deals with casacore::Float and casacore::Complex observed data (DATA or FLOAT_DATA)
     732             :     virtual void getDataColumn (ROVisibilityIterator::DataColumn whichOne, const casacore::Slicer & slicer,
     733             :                                 casacore::Cube<casacore::Complex> & data) const;
     734             :     virtual void getDataColumn (DataColumn whichOne, casacore::Cube<casacore::Complex> & data) const;
     735             : 
     736             :     // get FLOAT_DATA as real Floats.
     737             :     virtual void getFloatDataColumn (const casacore::Slicer & slicer, casacore::Cube<casacore::Float> & data) const;
     738             :     virtual void getFloatDataColumn (casacore::Cube<casacore::Float> & data) const;
     739             : 
     740             :     //constructor helpers
     741             :     virtual void initialize (const casacore::Block<casacore::MeasurementSet> & mss);
     742             : 
     743             :     virtual void originChunks (casacore::Bool forceRewind);
     744             : 
     745             :     //Re-Do the channel selection in multi ms case
     746             :     virtual void doChannelSelection ();
     747             :     //Set the tile cache size....when using slice access if tile cache size is
     748             :     // not set memory usage can go wild.  Specifically, the caching scheme is
     749             :     // ephemeral and lives for that instance of setting the caching scheme.
     750             :     //
     751             :     // If you don't set any then the defaults come into play and caches a few
     752             :     // tiles along every axis at the tile you requested...which is a waste when
     753             :     // say you know you want to proceed along the row axis for example...and in
     754             :     // fact now VisIter just reads one tile (thus the commenting in setTileCache)
     755             :     // and lets the OS do the caching rather than than having the table system
     756             :     // cache extra tiles.
     757             :     virtual void setTileCache ();
     758             :     //Check if spw is in selected SPW for actual ms
     759             :     virtual casacore::Bool isInSelectedSPW (const casacore::Int & spw);
     760             : 
     761             :     // Updates, if necessary, rowIds_p member for the current chunk
     762             :     virtual void update_rowIds () const;
     763             : 
     764             :     void setAsyncEnabled (casacore::Bool enable);
     765             : 
     766             :     template<class T>
     767             :     void getColScalar (const casacore::ScalarColumn<T> & column, casacore::Vector<T> & array, casacore::Bool resize) const;
     768             : 
     769             :     template<class T>
     770             :     void getColArray (const casacore::ArrayColumn<T> & column, casacore::Array<T> & array, casacore::Bool resize) const;
     771             : 
     772             :     // column access functions, can be overridden in derived classes
     773             :     virtual void getCol (const casacore::ScalarColumn<casacore::Bool> & column, casacore::Vector<casacore::Bool> & array, casacore::Bool resize = false) const;
     774             :     virtual void getCol (const casacore::ScalarColumn<casacore::Int> & column, casacore::Vector<casacore::Int> & array, casacore::Bool resize = false) const;
     775             :     virtual void getCol (const casacore::ScalarColumn<casacore::Double> & column, casacore::Vector<casacore::Double> & array, casacore::Bool resize = false) const;
     776             : 
     777             :     virtual void getCol (const casacore::ArrayColumn<casacore::Bool> & column, casacore::Array<casacore::Bool> & array, casacore::Bool resize = false) const;
     778             :     virtual void getCol (const casacore::ArrayColumn<casacore::Float> & column, casacore::Array<casacore::Float> & array, casacore::Bool resize = false) const;
     779             :     virtual void getCol (const casacore::ArrayColumn<casacore::Double> & column, casacore::Array<casacore::Double> & array, casacore::Bool resize = false) const;
     780             :     virtual void getCol (const casacore::ArrayColumn<casacore::Complex> & column, casacore::Array<casacore::Complex> & array, casacore::Bool resize = false) const;
     781             : 
     782             :     virtual void getCol (const casacore::ArrayColumn<casacore::Bool> & column, const casacore::Slicer & slicer, casacore::Array<casacore::Bool> & array, casacore::Bool resize = false) const;
     783             :     virtual void getCol (const casacore::ArrayColumn<casacore::Float> & column, const casacore::Slicer & slicer, casacore::Array<casacore::Float> & array, casacore::Bool resize = false) const;
     784             :     virtual void getCol (const casacore::ArrayColumn<casacore::Complex> & column, const casacore::Slicer & slicer, casacore::Array<casacore::Complex> & array, casacore::Bool resize = false) const;
     785             : 
     786             :     //  virtual void getCol (const casacore::String & colName, casacore::Array<casacore::Double> & array,
     787             :     //                      casacore::Array<casacore::Double> & all, casacore::Bool resize = false) const;
     788             :     //  virtual void getCol (const casacore::String & colName, casacore::Vector<casacore::Bool> & array,
     789             :     //                      casacore::Vector<casacore::Bool> & all, casacore::Bool resize = false) const;
     790             :     //  virtual void getCol (const casacore::String & colName, casacore::Vector<casacore::Int> & array,
     791             :     //                      casacore::Vector<casacore::Int> & all, casacore::Bool resize = false) const;
     792             :     //  virtual void getCol (const casacore::String & colName, casacore::Vector<casacore::Double> & array,
     793             :     //                      casacore::Vector<casacore::Double> & all, casacore::Bool resize = false) const;
     794             : 
     795             :     template<class T>
     796             :     void swapyz (casacore::Cube<T> & out, const casacore::Cube<T> & in) const;
     797             : 
     798             :     class Cache {
     799             : 
     800             :     public:
     801             : 
     802             :         Cache ();
     803             : 
     804             :         Cache & operator= (const Cache & other);
     805             : 
     806             :         casacore::MDirection         azel0_p;
     807             :         casacore::Vector<casacore::MDirection> azel_p;
     808             :         casacore::Vector<casacore::Float>      feedpa_p;
     809             :         casacore::Cube<casacore::Bool>         flagCube_p;
     810             :         casacore::Bool               flagOK_p;
     811             :         casacore::Bool               floatDataCubeOK_p;
     812             :         casacore::Cube<casacore::Float>        floatDataCube_p;
     813             :         casacore::Bool               freqCacheOK_p;
     814             :         casacore::Vector<casacore::Double>     frequency_p;
     815             :         casacore::Double             hourang_p;
     816             :         casacore::Matrix<casacore::Float>      imagingWeight_p;
     817             :         casacore::Double             lastParang0UT_p; // cache update timestamp
     818             :         casacore::Double             lastParangUT_p; // cache update timestamp
     819             :         casacore::Double             lastazelUT_p; // cache update timestamp
     820             :         casacore::Double             lastazel0UT_p; // cache update timestamp
     821             :         casacore::Double             lasthourangUT_p; // cache update timestamp
     822             :         casacore::Double             lastfeedpaUT_p; // cache update timestamp
     823             :         casacore::Bool               msHasFC_p;   // Does the current casacore::MS have a valid FLAG_CATEGORY?
     824             :         casacore::Bool               msHasWtSp_p; // Does the current casacore::MS have a valid WEIGHT_SPECTRUM?
     825             :         casacore::Float              parang0_p;
     826             :         casacore::Vector<casacore::Float>      parang_p;
     827             :         casacore::Vector<casacore::rownr_t>    rowIds_p;
     828             :         casacore::Matrix<casacore::Double>     uvwMat_p;
     829             :         casacore::Cube<casacore::Complex>      visCube_p;
     830             :         casacore::Block<casacore::Bool>        visOK_p;
     831             :         casacore::Bool               weightSpOK_p;
     832             :         casacore::Cube<casacore::Float>        wtSp_p;
     833             :     };
     834             : 
     835             :     class Channels { // channel selection
     836             : 
     837             :     public:
     838             : 
     839             :         casacore::Block<casacore::Int> inc_p;
     840             :         casacore::Block<casacore::Int> start_p;
     841             :         casacore::Block<casacore::Int> width_p;
     842             :         casacore::Block<casacore::Int> nGroups_p;
     843             :         casacore::Block<casacore::Int> preselectedChanStart_p;
     844             :         casacore::Block<casacore::Int> preselectednChan_p;
     845             : 
     846             :     };
     847             : 
     848             :     class Columns {
     849             : 
     850             :     public:
     851             : 
     852             :         Columns & operator= (const Columns & other);
     853             : 
     854             :         casacore::ScalarColumn<casacore::Int>    antenna1_p;
     855             :         casacore::ScalarColumn<casacore::Int>    antenna2_p;
     856             :         casacore::ArrayColumn<casacore::Complex> corrVis_p;
     857             :         casacore::ScalarColumn<casacore::Double> exposure_p;
     858             :         casacore::ScalarColumn<casacore::Int>    feed1_p;
     859             :         casacore::ScalarColumn<casacore::Int>    feed2_p;
     860             :         casacore::ArrayColumn<casacore::Bool>    flagCategory_p;
     861             :         casacore::ScalarColumn<casacore::Bool>   flagRow_p;
     862             :         casacore::ArrayColumn<casacore::Bool>    flag_p;
     863             :         casacore::ArrayColumn<casacore::Float>   floatVis_p;
     864             :         casacore::ArrayColumn<casacore::Complex> modelVis_p;
     865             :         casacore::ScalarColumn<casacore::Int>    observation_p;
     866             :         casacore::ScalarColumn<casacore::Int>    processor_p;
     867             :         casacore::ScalarColumn<casacore::Int>    scan_p;
     868             :         casacore::ArrayColumn<casacore::Float>   sigma_p;
     869             :         casacore::ScalarColumn<casacore::Int>    state_p;
     870             :         casacore::ScalarColumn<casacore::Double> timeCentroid_p;
     871             :         casacore::ScalarColumn<casacore::Double> timeInterval_p;
     872             :         casacore::ScalarColumn<casacore::Double> time_p;
     873             :         casacore::ArrayColumn<casacore::Double>  uvw_p;
     874             :         casacore::ArrayColumn<casacore::Complex> vis_p;
     875             :         casacore::ArrayColumn<casacore::Float>   weightSpectrum_p;
     876             :         casacore::ArrayColumn<casacore::Float>   weight_p;
     877             : 
     878             :     };
     879             : 
     880             :     class MeasurementSetChannels {
     881             : 
     882             :     public:
     883             : 
     884             :         casacore::Block < casacore::Vector<casacore::Int> > inc_p;
     885             :         casacore::Block < casacore::Vector<casacore::Int> > nGroups_p;
     886             :         casacore::Block < casacore::Vector<casacore::Int> > start_p;
     887             :         casacore::Block < casacore::Vector<casacore::Int> > width_p;
     888             :         casacore::Block < casacore::Vector<casacore::Int> > spw_p;
     889             : 
     890             :     };
     891             : 
     892             :     class Velocity { // for velocity selection and conversion
     893             : 
     894             :     public:
     895             : 
     896             :         Velocity ();
     897             :         Velocity & operator= (const Velocity & other);
     898             : 
     899             :         casacore::MDoppler::Convert cFromBETA_p;
     900             :         casacore::Vector<casacore::Double>    lsrFreq_p;
     901             :         casacore::Int               nVelChan_p;
     902             :         casacore::Vector<casacore::Double>    selFreq_p;
     903             :         casacore::MDoppler::Types   vDef_p;
     904             :         casacore::MVRadialVelocity  vInc_p;
     905             :         casacore::String            vInterpolation_p;
     906             :         casacore::Bool              velSelection_p;
     907             :         casacore::Bool              vPrecise_p;
     908             :         casacore::MVRadialVelocity  vStart_p;
     909             : 
     910             :     };
     911             : 
     912             : 
     913             :     typedef std::vector<casacore::MeasurementSet> MeasurementSets;
     914             : 
     915             :     casacore::Bool                    addDefaultSort_p;
     916             :     casacore::Bool                    asyncEnabled_p; // Allows lower-level code to make an async "copy" of this VI.
     917             :     casacore::Bool                    autoTileCacheSizing_p;
     918             :     mutable Cache           cache_p;
     919             :     casacore::Int                     channelGroupSize_p;
     920             :     Channels                channels_p;
     921             :     casacore::Int                     chunkNumber_p;
     922             :     Columns                 columns_p;
     923             :     casacore::Int                     curChanGroup_p;
     924             :     casacore::rownr_t                 curEndRow_p;
     925             :     casacore::Int                     curNGroups_p;
     926             :     casacore::rownr_t                 curNumRow_p;
     927             :     casacore::rownr_t                 curStartRow_p;
     928             :     casacore::rownr_t                 curTableNumRow_p;
     929             :     casacore::Bool                    floatDataFound_p;
     930             :     VisImagingWeight        imwgt_p;    // object to calculate imaging weight
     931             :     casacore::Bool                    initialized_p;
     932             :     casacore::Bool                    isMultiMS_p;
     933             :     MeasurementSets         measurementSets_p; // [use]
     934             :     casacore::Bool                    more_p;
     935             :     MeasurementSetChannels  msChannels_p;
     936             :     casacore::Int                     msCounter_p;
     937             :     casacore::Bool                    msIterAtOrigin_p;
     938             :     casacore::MSIter                  msIter_p;
     939             :     mutable casacore::MSDerivedValues msd_p;
     940             :     casacore::Int                     nAnt_p;
     941             :     casacore::Int                     nChan_p;
     942             :     casacore::Int                     nPol_p;
     943             :     casacore::Int                     nRowBlocking_p;
     944             :     casacore::Bool                    newChanGroup_p;
     945             :     ROVisibilityIterator *  rovi_p; // [use]
     946             :     casacore::RefRows                 selRows_p; // currently selected rows from msIter_p.table ()
     947             :     casacore::Slicer                  slicer_p;
     948             :     casacore::Block<casacore::Int>              sortColumns_p;
     949             :     casacore::Bool                    stateOk_p;
     950             :     SubChunkPair            subchunk_p;
     951             :     casacore::Vector<casacore::Bool>            tileCacheIsSet_p;
     952             :     casacore::Double                  timeInterval_p;
     953             :     casacore::Vector<casacore::Double>          time_p;
     954             :     casacore::Bool                    useSlicer_p;
     955             :     std::stack<VisBuffer *>      vbStack_p;   // casacore::Stack of VisBuffer objects
     956             :     Velocity                velocity_p;
     957             :     casacore::Slicer                  weightSlicer_p;
     958             : 
     959             : 
     960             : };
     961             : 
     962       50315 : inline casacore::Bool VisibilityIteratorReadImpl::more () const
     963             : {
     964       50315 :     return more_p;
     965             : }
     966             : 
     967             : inline casacore::Vector<casacore::SquareMatrix<casacore::Complex, 2> > &
     968           0 : VisibilityIteratorReadImpl::CJones (casacore::Vector<casacore::SquareMatrix<casacore::Complex, 2> > & cjones) const
     969             : {
     970           0 :     cjones.resize (msIter_p.CJones ().nelements ());
     971           0 :     return cjones = msIter_p.CJones ();
     972             : }
     973             : 
     974        8794 : inline const casacore::Cube<casacore::Double> & VisibilityIteratorReadImpl::receptorAngles () const
     975             : {
     976        8794 :     return msIter_p.receptorAngles ();
     977             : }
     978             : 
     979           0 : inline const casacore::Vector<casacore::String> & VisibilityIteratorReadImpl::antennaMounts () const
     980             : {
     981           0 :     return msIter_p.antennaMounts ();
     982             : }
     983             : 
     984             : inline const casacore::Cube<casacore::RigidVector<casacore::Double, 2> > &
     985           0 : VisibilityIteratorReadImpl::getBeamOffsets () const
     986             : {
     987           0 :     return msIter_p.getBeamOffsets ();
     988             : }
     989             : 
     990           0 : inline casacore::Bool VisibilityIteratorReadImpl::allBeamOffsetsZero () const
     991             : {
     992           0 :     return msIter_p.allBeamOffsetsZero ();
     993             : }
     994             : 
     995       21700 : inline casacore::Int VisibilityIteratorReadImpl::channelGroupSize () const
     996             : {
     997       21700 :     return channels_p.width_p[msIter_p.spectralWindowId ()];
     998             : }
     999           0 : inline casacore::Int VisibilityIteratorReadImpl::channelIndex () const
    1000             : {
    1001           0 :     return channels_p.inc_p[msIter_p.spectralWindowId ()] * curChanGroup_p;
    1002             : }
    1003       44926 : inline casacore::Int VisibilityIteratorReadImpl::nRow () const
    1004             : {
    1005       44926 :     return curNumRow_p;
    1006             : }
    1007        1295 : inline casacore::Int VisibilityIteratorReadImpl::nRowChunk () const
    1008             : {
    1009        1295 :     return msIter_p.table ().nrow ();
    1010             : }
    1011             : //inline VisibilityIteratorReadImpl &
    1012             : //VisibilityIteratorReadImpl::velInterpolation (const casacore::String & type)
    1013             : //{
    1014             : //    vInterpolation_p = type;
    1015             : //    return *this;
    1016             : //}
    1017       21700 : inline casacore::IPosition VisibilityIteratorReadImpl::visibilityShape () const
    1018             : {
    1019       21700 :     return casacore::IPosition (3, nPol_p, channelGroupSize (), curNumRow_p);
    1020             : }
    1021             : 
    1022             : // <summary>
    1023             : // VisibilityIterator iterates through one or more writable MeasurementSets
    1024             : // </summary>
    1025             : 
    1026             : // <use visibility=export>
    1027             : 
    1028             : // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
    1029             : // </reviewed>
    1030             : 
    1031             : // <prerequisite>
    1032             : //   <li> <linkto class="VisibilityIteratorReadImpl">VisibilityIteratorReadImpl</linkto>
    1033             : // </prerequisite>
    1034             : //
    1035             : // <etymology>
    1036             : // The VisibilityIterator is a read/write iterator returning visibilities
    1037             : // </etymology>
    1038             : //
    1039             : // <synopsis>
    1040             : // VisibilityIterator provides iteration with various sort orders
    1041             : // for one or more MSs. It has member functions to retrieve the fields
    1042             : // commonly needed in synthesis calibration and imaging. It is
    1043             : // derived from the read-only iterator
    1044             : // <linkto class="VisibilityIteratorReadImpl">VisibilityIteratorReadImpl</linkto>.
    1045             : //
    1046             : // One should use <linkto class="VisBuffer">VisBuffer</linkto>
    1047             : // to access chunks of data.
    1048             : // </synopsis>
    1049             : //
    1050             : // <example>
    1051             : // <code>
    1052             : // //
    1053             : // </code>
    1054             : // </example>
    1055             : //
    1056             : // <motivation>
    1057             : // For imaging and calibration you need to access an casacore::MS in some consistent
    1058             : // order (by field, spectralwindow, time interval etc.). This class provides
    1059             : // that access.
    1060             : // </motivation>
    1061             : //
    1062             : // #<thrown>
    1063             : //
    1064             : // #</thrown>
    1065             : //
    1066             : // <todo asof="1997/05/30">
    1067             : //   <li> cleanup the currently dual interface for visibilities and flags
    1068             : //   <li> sort out what to do with weights when interpolating
    1069             : // </todo>
    1070             : 
    1071             : class VisibilityIteratorWriteImpl {
    1072             : 
    1073             :     friend class VisibilityIterator;
    1074             : 
    1075             : public:
    1076             : 
    1077             :     typedef ROVisibilityIterator::DataColumn DataColumn;
    1078             : 
    1079             :     // Constructors.
    1080             :     // Note: The VisibilityIterator is not initialized correctly by default, you
    1081             :     // need to call origin () before using it to iterate.
    1082             : 
    1083             :     VisibilityIteratorWriteImpl (VisibilityIterator * vi);
    1084             : 
    1085             :     //VisibilityIteratorWriteImpl (VisibilityIterator * vi);
    1086             : 
    1087             :     VisibilityIteratorWriteImpl (const VisibilityIteratorWriteImpl & other);
    1088             : 
    1089             :     // Destructor
    1090             : 
    1091             :     virtual ~VisibilityIteratorWriteImpl ();
    1092             : 
    1093             :     // Members
    1094             : 
    1095             :     virtual VisibilityIteratorWriteImpl * clone (VisibilityIterator * vi) const;
    1096             : 
    1097           0 :     virtual casacore::Bool isWritable () const {
    1098           0 :         return true;
    1099             :     }
    1100             : 
    1101             :     // Set/modify the flags in the data.
    1102             :     // This will flag all channels in the original data that contributed to
    1103             :     // the output channel in the case of channel averaging.
    1104             :     // All polarizations have the same flag value.
    1105             :     virtual void setFlag (const casacore::Matrix<casacore::Bool> & flag);
    1106             : 
    1107             :     // Set/modify the flags in the data.
    1108             :     // This sets the flags as found in the casacore::MS, casacore::Cube (npol,nchan,nrow),
    1109             :     // where nrow is the number of rows in the current iteration (given by
    1110             :     // nRow ()).
    1111             :     virtual void setFlag (const casacore::Cube<casacore::Bool> & flag);
    1112             : 
    1113             :     // Set/modify the flag row column; dimension casacore::Vector (nrow)
    1114             :     virtual void setFlagRow (const casacore::Vector<casacore::Bool> & rowflags);
    1115             : 
    1116             :     void setFlagCategory(const casacore::Array<casacore::Bool>& fc);
    1117             : 
    1118             :     // Set/modify the visibilities.
    1119             :     // This is possibly only for a 'reference' casacore::MS which has a new DATA column.
    1120             :     // The first axis of the matrix should equal the selected number of channels
    1121             :     // in the original MS.
    1122             :     // If the casacore::MS does not contain all polarizations, only the parallel
    1123             :     // hand polarizations are used.
    1124             :     virtual void setVis (const casacore::Matrix<CStokesVector> & vis, DataColumn whichOne);
    1125             : 
    1126             :     // Set/modify the visibilities
    1127             :     // This sets the data as found in the casacore::MS, casacore::Cube (npol,nchan,nrow).
    1128             :     virtual void setVis (const casacore::Cube<casacore::Complex> & vis, DataColumn whichOne);
    1129             : 
    1130             :     // Set the visibility and flags, and interpolate from velocities if needed
    1131             :     virtual void setVisAndFlag (const casacore::Cube<casacore::Complex> & vis, const casacore::Cube<casacore::Bool> & flag,
    1132             :                         DataColumn whichOne);
    1133             : 
    1134             :     // Set/modify the weights
    1135             :     virtual void setWeight (const casacore::Vector<casacore::Float> & wt);
    1136             : 
    1137             :     // Set/modify the weightMat
    1138             :     virtual void setWeightMat (const casacore::Matrix<casacore::Float> & wtmat);
    1139             : 
    1140             :     // Set/modify the weightSpectrum
    1141             :     virtual void setWeightSpectrum (const casacore::Cube<casacore::Float> & wtsp);
    1142             : 
    1143             :     // Set/modify the Sigma
    1144             :     virtual void setSigma (const casacore::Vector<casacore::Float> & sig);
    1145             : 
    1146             :     // Set/modify the ncorr x nrow SigmaMat.
    1147             :     virtual void setSigmaMat (const casacore::Matrix<casacore::Float> & sigmat);
    1148             : 
    1149             :     virtual void writeBack (VisBuffer *);
    1150             : 
    1151             : protected:
    1152             : 
    1153             :     // A BackWriter is a functor that will extract a piece of information out of its VisBuffer
    1154             :     // argument and write it out using a "set" method on the supplied VisibilityIterator.
    1155             :     class BackWriter {
    1156             : 
    1157             :     public:
    1158             : 
    1159           0 :         virtual ~BackWriter () {}
    1160             : 
    1161             :         virtual void operator () (VisibilityIteratorWriteImpl * vi, VisBuffer * vb) = 0;
    1162             : 
    1163             :     };
    1164             : 
    1165             :     // A simple BackWriterImpl uses a nullary accessor on a VisBuffer.
    1166             :     template <typename Setter, typename Getter>
    1167             :     class BackWriterImpl : public BackWriter {
    1168             :     public:
    1169             : 
    1170           0 :         BackWriterImpl (Setter setter, Getter getter) : getter_p (getter), setter_p (setter) {}
    1171           0 :         void operator () (VisibilityIteratorWriteImpl * vi, VisBuffer * vb) {
    1172           0 :             (vi ->* setter_p) ((vb ->* getter_p) ());
    1173           0 :         }
    1174             : 
    1175             :     private:
    1176             : 
    1177             :         Getter getter_p;
    1178             :         Setter setter_p;
    1179             :     };
    1180             : 
    1181             :     // BackWriterImpl2 is slightly more complicated in that it uses a unary accessor.  The argument
    1182             :     // to the unary accessor is a member of the ROVisibilityIterator DataColumn enumeration which
    1183             :     // specifies which visibilty or visCube type is wanted (e.g., observed, model or corrected).
    1184             :     template <typename Setter, typename Getter>
    1185             :     class BackWriterImpl2 : public BackWriter {
    1186             :     public:
    1187             : 
    1188             :         typedef VisibilityIteratorReadImpl::DataColumn DataColumn;
    1189             : 
    1190           0 :         BackWriterImpl2 (Setter setter, Getter getter, DataColumn dc)
    1191           0 :         : dataColumn_p (dc), getter_p (getter), setter_p (setter)
    1192           0 :         {}
    1193           0 :         void operator () (VisibilityIteratorWriteImpl * vi, VisBuffer * vb) {
    1194           0 :             (vi ->* setter_p) ((vb ->* getter_p) (), dataColumn_p);
    1195           0 :         }
    1196             : 
    1197             :     private:
    1198             : 
    1199             :         DataColumn dataColumn_p;
    1200             :         Getter getter_p;
    1201             :         Setter setter_p;
    1202             :     };
    1203             : 
    1204             :     // Backwriter(2) creation methods.  These methods make it fairly straightforward to create
    1205             :     // a BackWriter object.
    1206             : 
    1207             :     template <typename Ret>
    1208             :     static
    1209             :     BackWriter *
    1210           0 :     makeBackWriter (void (VisibilityIteratorWriteImpl::* setter) (Ret), Ret (VisBuffer::* getter) () const) {
    1211           0 :         return new BackWriterImpl <void (VisibilityIteratorWriteImpl:: *) (Ret),
    1212             :                                    Ret (VisBuffer:: *) () const >
    1213           0 :         (setter, getter);
    1214             :     }
    1215             : 
    1216             :     template <typename Ret>
    1217             :     static
    1218             :     BackWriter *
    1219           0 :     makeBackWriter2 (void (VisibilityIteratorWriteImpl::* setter) (Ret, VisibilityIteratorReadImpl::DataColumn),
    1220             :                      Ret (VisBuffer::* getter) () const,
    1221             :                      ROVisibilityIterator::DataColumn dc) {
    1222             : 
    1223             :         // Define the Getter and Setter types
    1224             : 
    1225             :         typedef void (VisibilityIteratorWriteImpl::* Setter) (Ret, VisibilityIteratorReadImpl::DataColumn);
    1226             :         typedef Ret (VisBuffer::* Getter) () const;
    1227             : 
    1228           0 :         return new BackWriterImpl2 < Setter, Getter> (setter, getter, dc);
    1229             :     }
    1230             : 
    1231             :     VisibilityIteratorReadImpl * getReadImpl ();
    1232             : 
    1233             :     void initializeBackWriters ();
    1234             : 
    1235             :     virtual void attachColumns (const casacore::Table & t);
    1236             : 
    1237             : //    void setInterpolatedVisFlag (const casacore::Cube<casacore::Complex> & vis,
    1238             : //                                 const casacore::Cube<casacore::Bool> & flag);
    1239             : //    void setInterpolatedWeight (const casacore::Matrix<casacore::Float> & wt);
    1240             : 
    1241             :     // Write the data column (observed, model or corrected);
    1242             :     // deals with casacore::Float or casacore::Complex observed data (DATA and FLOAT_DATA).
    1243             : 
    1244             :     void putDataColumn (DataColumn whichOne, const casacore::Slicer & slicer,
    1245             :                         const casacore::Cube<casacore::Complex> & data);
    1246             :     void putDataColumn (DataColumn whichOne, const casacore::Cube<casacore::Complex> & data);
    1247             : 
    1248             :     // column access functions, can be overridden in derived classes
    1249             :     virtual void putCol (casacore::ScalarColumn<casacore::Bool> & column, const casacore::Vector<casacore::Bool> & array);
    1250             :     virtual void putCol (casacore::ArrayColumn<casacore::Bool> & column, const casacore::Array<casacore::Bool> & array);
    1251             :     virtual void putCol (casacore::ArrayColumn<casacore::Float> & column, const casacore::Array<casacore::Float> & array);
    1252             :     virtual void putCol (casacore::ArrayColumn<casacore::Complex> & column, const casacore::Array<casacore::Complex> & array);
    1253             : 
    1254             :     virtual void putCol (casacore::ArrayColumn<casacore::Bool> & column, const casacore::Slicer & slicer, const casacore::Array<casacore::Bool> & array);
    1255             :     virtual void putCol (casacore::ArrayColumn<casacore::Float> & column, const casacore::Slicer & slicer, const casacore::Array<casacore::Float> & array);
    1256             :     virtual void putCol (casacore::ArrayColumn<casacore::Complex> & column, const casacore::Slicer & slicer, const casacore::Array<casacore::Complex> & array);
    1257             : 
    1258             :     template <class T> void setTileShape(casacore::RefRows &rowRef,casacore::ArrayColumn<T> &outputDataCol,const casacore::IPosition &arrayShape);
    1259             :     casacore::Bool useCustomTileShape();
    1260             : 
    1261             :     // non-virtual, no reason to template this function because casacore::Bool is the only type needed
    1262             :     void putColScalar (casacore::ScalarColumn<casacore::Bool> & column, const casacore::Vector<casacore::Bool> & array);
    1263             : 
    1264             :     //This puts a model into the descriptor of the actual ms
    1265             :     //Set iscomponentlist to true if the record represent a componentlist
    1266             :     //if false then it is a FTMachine casacore::Record that holds the model image
    1267             :     // a [-1] vector in validfields mean the model applies to all fields of the active ms 
    1268             :     virtual void putModel(const casacore::RecordInterface& rec, casacore::Bool iscomponentlist=true, casacore::Bool incremental=false);
    1269             : 
    1270             : 
    1271             : 
    1272             : 
    1273             : 
    1274             : private:
    1275             : 
    1276             :     class Columns {
    1277             : 
    1278             :     public:
    1279             : 
    1280             :         Columns & operator= (const Columns & other);
    1281             : 
    1282             :         casacore::ArrayColumn<casacore::Complex> corrVis_p;
    1283             :         casacore::ScalarColumn<casacore::Bool>   flagRow_p;
    1284             :         casacore::ArrayColumn<casacore::Bool>    flag_p;
    1285             :         casacore::ArrayColumn<casacore::Bool>    flagCategory_p;
    1286             :         casacore::ArrayColumn<casacore::Float>   floatVis_p;
    1287             :         casacore::ArrayColumn<casacore::Complex> modelVis_p;
    1288             :         casacore::ArrayColumn<casacore::Float>   sigma_p;
    1289             :         casacore::ArrayColumn<casacore::Complex> vis_p;
    1290             :         casacore::ArrayColumn<casacore::Float>   weightSpectrum_p;
    1291             :         casacore::ArrayColumn<casacore::Float>   weight_p;
    1292             : 
    1293             :     };
    1294             : 
    1295             :     std::map <VisBufferComponents::EnumType, BackWriter *> backWriters_p;
    1296             :     Columns columns_p;
    1297             :     VisibilityIterator * vi_p; // [use]
    1298             :     casacore::Bool useCustomTileShape_p;
    1299             : };
    1300             : 
    1301             : } //# NAMESPACE CASA - END
    1302             : 
    1303             : #endif
    1304             : 

Generated by: LCOV version 1.16