LCOV - code coverage report
Current view: top level - msvis/MSVis - VisBufferAsyncWrapper.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 50 0.0 %
Date: 2024-10-10 19:51:30 Functions: 0 50 0.0 %

          Line data    Source code
       1             : //# VisBuffer.h: buffer for iterating through casacore::MS in large blocks
       2             : //# Copyright (C) 1996,1997,1998,1999,2000,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: VisBuffer.h,v 19.14 2006/02/28 04:48:58 mvoronko Exp $
      27             : 
      28             : #ifndef VISBUFFER_ASYNC_WRAPPER_H
      29             : #define VISBUFFER_ASYNC_WRAPPER_H
      30             : 
      31             : #include <casacore/casa/aips.h>
      32             : #include <casacore/casa/Arrays/Cube.h>
      33             : #include <casacore/casa/Arrays/Vector.h>
      34             : #include <casacore/casa/Arrays/Matrix.h>
      35             : #include <casacore/casa/BasicSL/Complex.h>
      36             : #include <casacore/measures/Measures/MDirection.h>
      37             : #include <casacore/measures/Measures/MEpoch.h>
      38             : #include <msvis/MSVis/StokesVector.h>
      39             : #include <msvis/MSVis/VisBuffer.h>
      40             : #include <msvis/MSVis/VisBufferAsync.h>
      41             : #include <msvis/MSVis/VisibilityIterator.h>
      42             : #include <msvis/MSVis/MSCalEnums.h>
      43             : 
      44             : namespace casa { //# NAMESPACE CASA - BEGIN
      45             : 
      46             : //#forward
      47             : 
      48             : //<summary>VisBuffers encapulsate one chunk of visibility data for processing.</summary>
      49             : //
      50             : // <use visibility=export>
      51             : //
      52             : // <reviewed reviewer="" date="" tests="" demos="">
      53             : 
      54             : // <prerequisite>
      55             : //   <li> <linkto class="VisSet">VisSet</linkto>
      56             : //   <li> <linkto class="VisibilityIterator">VisibilityIterator</linkto>
      57             : // </prerequisite>
      58             : //
      59             : // <etymology>
      60             : // VisBuffer is a buffer for visibility data
      61             : // </etymology>
      62             : //
      63             : //<synopsis>
      64             : // This class contains 'one iteration' of the
      65             : // <linkto class="VisibilityIterator">VisibilityIterator</linkto>
      66             : // It is a modifiable
      67             : // buffer of values to which calibration and averaging can be applied.
      68             : // This allows processing of the data in larger blocks, avoiding some
      69             : // overheads for processing per visibility point or spectrum.
      70             : //
      71             : // See <linkto module="MeasurementEquations">MeasurementEquations</linkto>
      72             : // for more details on how the VisBuffer is to be used.
      73             : //</synopsis>
      74             : 
      75             : //<todo>
      76             : // <li> reconcile vis/visCube usage: visCube, flagCube and weightMatrix
      77             : // are currently only correct when this VisBuffer got them from a
      78             : // VisIter, operations like -=, freqAverage() are only done for
      79             : // visibility() and flag().
      80             : //</todo>
      81             : class VisBufferAsyncWrapper : public VisBufferAsync {
      82             : 
      83             :     friend class ViReadImplAsync;
      84             : 
      85             : public:
      86             :     // Create empty VisBuffer you can assign to or attach.
      87             :     VisBufferAsyncWrapper();
      88             : //    // Construct VisBuffer for a particular VisibilityIterator
      89             : //    // The buffer will remain synchronized with the iterator.
      90             :     VisBufferAsyncWrapper (ROVisibilityIterator & iter);
      91             : //
      92             : //    // Copy construct, looses synchronization with iterator: only use buffer for
      93             : //    // current iteration (or reattach).
      94             :     VisBufferAsyncWrapper (const VisBufferAsync & vb);
      95             : 
      96             :     // Destructor (detaches from VisIter)
      97             :     virtual ~VisBufferAsyncWrapper();
      98             : 
      99             :     // Assignment, loses synchronization with iterator: only use buffer for
     100             :     // current iteration (or reattach)
     101             : 
     102             :     virtual VisBufferAsyncWrapper & operator=(const VisBufferAsyncWrapper & vb);
     103             : 
     104             :     // Assignment, optionally without copying the data across; with copy=true
     105             :     // this is identical to normal assignment operator
     106             : 
     107             :     virtual VisBufferAsyncWrapper & assign(const VisBuffer & vb, casacore::Bool copy = true);
     108             : 
     109             :     // subtraction: return the difference of the visibilities, flags of
     110             :     // this and other are or-ed. An exception is thrown if the number of
     111             :     // rows or channels differs, but no further checks are done.
     112             :     VisBufferAsyncWrapper & operator-=(const VisBuffer & vb);
     113             : 
     114             :     // Attach to a VisIter. Detaches itself first if already attached
     115             :     // to a VisIter. Will remain synchronized with iterator.
     116             :     virtual void attachToVisIter(ROVisibilityIterator & iter);
     117             :     void attachToVisIterAsync (ROVisibilityIterator & iter);
     118             :     virtual VisBuffer * clone ();
     119             :     virtual void detachFromVisIter ();
     120             : 
     121             :     // Invalidate the cache
     122             :     virtual void invalidate();
     123             : 
     124             :     // <group>
     125             :     // Access functions
     126             :     //
     127             :     virtual casacore::Int & nCorr();
     128             :     casacore::Int nCorr() const;
     129             : 
     130             :     casacore::Int & nChannel();
     131             :     casacore::Int nChannel() const;
     132             : 
     133             :     casacore::Vector<casacore::Int>& channel();
     134             :     const casacore::Vector<casacore::Int>& channel() const;
     135             : 
     136             :     casacore::Bool newArrayId () const;
     137             :     casacore::Bool newFieldId () const;
     138             :     casacore::Bool newSpectralWindow () const;
     139             : 
     140             :     casacore::Int & nRow();
     141             :     casacore::Int nRow() const;
     142             : 
     143             :     casacore::Vector<casacore::Int>& antenna1();
     144             :     const casacore::Vector<casacore::Int>& antenna1() const;
     145             : 
     146             :     casacore::Vector<casacore::Int>& antenna2();
     147             :     const casacore::Vector<casacore::Int>& antenna2() const;
     148             : 
     149             :     casacore::Vector<casacore::Int>& feed1();
     150             :     const casacore::Vector<casacore::Int>& feed1() const;
     151             : 
     152             :     casacore::Vector<casacore::Int>& feed2();
     153             :     const casacore::Vector<casacore::Int>& feed2() const;
     154             : 
     155             :     // feed1_pa() and feed2_pa() return an array of parallactic angles
     156             :     // (each corresponds to the first receptor of the feed) one for each
     157             :     // row in the current buffer. In contrast, feed_pa() calculates
     158             :     // the angles for each antenna. These methods are implemented for
     159             :     // VisBuffer only to benefit from caching of the feed and antenna IDs.
     160             :     casacore::Vector<casacore::Float>& feed1_pa();
     161             :     const casacore::Vector<casacore::Float>& feed1_pa() const;
     162             : 
     163             :     casacore::Vector<casacore::Float>& feed2_pa();
     164             :     const casacore::Vector<casacore::Float>& feed2_pa() const;
     165             : 
     166             :     casacore::Vector<casacore::SquareMatrix<casacore::Complex, 2> >& CJones();
     167             :     const casacore::Vector<casacore::SquareMatrix<casacore::Complex, 2> >& CJones() const;
     168             : 
     169             :     // Note that feed_pa is a function instead of a cached value
     170             :     virtual casacore::Vector<casacore::Float> feed_pa(casacore::Double time) const;
     171             : 
     172             :     // direction1() and direction2() return arrays of directions where
     173             :     // the first and the second antenna/feed are pointed to. One value for
     174             :     // each row in the current buffer.
     175             :     casacore::Vector<casacore::MDirection>& direction1();
     176             :     const casacore::Vector<casacore::MDirection>& direction1()  const;
     177             : 
     178             :     casacore::Vector<casacore::MDirection>& direction2();
     179             :     const casacore::Vector<casacore::MDirection>& direction2()  const;
     180             : 
     181             : 
     182             :     // NOMINAL parallactic angle (feed p.a. offset NOT included)
     183             :     virtual casacore::Float parang0(casacore::Double time) const;
     184             :     virtual casacore::Vector<casacore::Float> parang(casacore::Double time) const;
     185             : 
     186             :     // Note that azel is a function instead of a cached value
     187             :     virtual casacore::MDirection azel0(casacore::Double time) const;
     188             :     casacore::Vector<casacore::Double>& azel0Vec(casacore::Double time, casacore::Vector<casacore::Double>& azelVec) const;
     189             :     virtual casacore::Vector<casacore::MDirection> azel(casacore::Double time) const;
     190             :     casacore::Matrix<casacore::Double>& azelMat(casacore::Double time, casacore::Matrix<casacore::Double>& azelMat) const;
     191             : 
     192             :     // Hour angle for specified time
     193             :     virtual casacore::Double hourang(casacore::Double time) const;
     194             : 
     195             :     casacore::Int fieldId() const;
     196             : 
     197             :     casacore::Int arrayId() const;
     198             : 
     199             :     casacore::Int polarizationId() const;
     200             : 
     201             :     // Return flag for each channel & row
     202             :     casacore::Matrix<casacore::Bool>& flag();
     203             :     const casacore::Matrix<casacore::Bool>& flag() const;
     204             : 
     205             :     // Return flag for each polarization, channel and row
     206             :     casacore::Cube<casacore::Bool>& flagCube();
     207             :     const casacore::Cube<casacore::Bool>& flagCube() const;
     208             : 
     209             :     casacore::Vector<casacore::Bool>& flagRow();
     210             :     const casacore::Vector<casacore::Bool>& flagRow() const;
     211             : 
     212             :     // Return flags for each polarization, channel, category, and row.
     213             :     casacore::Array<casacore::Bool>& flagCategory();
     214             :     const casacore::Array<casacore::Bool>& flagCategory() const;
     215             : 
     216             :     casacore::Vector<casacore::Int>& scan();
     217             :     const casacore::Vector<casacore::Int>& scan() const;
     218             : 
     219             :     // scalar version for convenience, when scan known constant for
     220             :     // entire iteration/buffer.
     221             :     casacore::Int scan0();
     222             : 
     223             :     casacore::Vector<casacore::Int>& processorId();
     224             :     const casacore::Vector<casacore::Int>& processorId() const;
     225             : 
     226             :     casacore::Vector<casacore::Int>& observationId();
     227             :     const casacore::Vector<casacore::Int>& observationId() const;
     228             : 
     229             :     casacore::Vector<casacore::Int>& stateId();
     230             :     const casacore::Vector<casacore::Int>& stateId() const;
     231             : 
     232             :     // Gets SPECTRAL_WINDOW/CHAN_FREQ (in Hz, acc. to the casacore::MS def'n v.2).
     233             :     casacore::Vector<casacore::Double>& frequency();
     234             :     const casacore::Vector<casacore::Double>& frequency() const;
     235             : 
     236             : //    casacore::Vector<casacore::Double>& lsrFrequency();
     237             : //    const casacore::Vector<casacore::Double>& lsrFrequency() const;
     238             : 
     239             : 
     240             :     //the following method is to convert the observed frequencies
     241             :     // This conversion may not be accurate for some frame
     242             :     // conversion like topo to lsr except if the spw is in the actual buffer
     243             : 
     244             :     virtual void lsrFrequency(const casacore::Int & spw, casacore::Vector<casacore::Double>& freq, casacore::Bool & convert) const;
     245             : 
     246             :     virtual casacore::Int numberCoh () const;
     247             : 
     248             :     casacore::MDirection & phaseCenter();
     249             :     casacore::MDirection phaseCenter() const;
     250             : 
     251             :     casacore::Int polFrame() const;
     252             : 
     253             :     casacore::Vector<casacore::Int>& corrType();
     254             :     const casacore::Vector<casacore::Int>& corrType() const;
     255             : 
     256             :     casacore::Vector<casacore::Float>& sigma();
     257             :     const casacore::Vector<casacore::Float>& sigma() const;
     258             : 
     259             :     casacore::Matrix<casacore::Float>& sigmaMat();
     260             :     const casacore::Matrix<casacore::Float>& sigmaMat() const;
     261             : 
     262             :     casacore::Int & spectralWindow();
     263             :     casacore::Int spectralWindow() const;
     264             :     virtual casacore::Int dataDescriptionId() const;
     265             :     casacore::Vector<casacore::Double>& time();
     266             :     const casacore::Vector<casacore::Double>& time() const;
     267             : 
     268             :     casacore::Vector<casacore::Double>& timeCentroid();
     269             :     const casacore::Vector<casacore::Double>& timeCentroid() const;
     270             : 
     271             :     casacore::Vector<casacore::Double>& timeInterval();
     272             :     const casacore::Vector<casacore::Double>& timeInterval() const;
     273             : 
     274             :     casacore::Vector<casacore::Double>& exposure();
     275             :     const casacore::Vector<casacore::Double>& exposure() const;
     276             : 
     277             :     casacore::Vector<casacore::RigidVector<casacore::Double, 3> >& uvw();
     278             :     const casacore::Vector<casacore::RigidVector<casacore::Double, 3> >& uvw() const;
     279             : 
     280             :     casacore::Matrix<casacore::Double>& uvwMat();
     281             :     const casacore::Matrix<casacore::Double>& uvwMat() const;
     282             : 
     283             :     casacore::Matrix<CStokesVector>& visibility();
     284             :     const casacore::Matrix<CStokesVector>& visibility() const;
     285             : 
     286             :     casacore::Matrix<CStokesVector>& modelVisibility();
     287             :     const casacore::Matrix<CStokesVector>& modelVisibility() const;
     288             : 
     289             :     casacore::Matrix<CStokesVector>& correctedVisibility();
     290             :     const casacore::Matrix<CStokesVector>& correctedVisibility() const;
     291             : 
     292             :     casacore::Cube<casacore::Complex>& visCube();
     293             :     const casacore::Cube<casacore::Complex>& visCube() const;
     294             : 
     295             :     casacore::Cube<casacore::Complex>& modelVisCube();
     296             : 
     297             :     casacore::Cube<casacore::Complex>& modelVisCube(const casacore::Bool & matchVisCubeShape);
     298             : 
     299             :     const casacore::Cube<casacore::Complex>& modelVisCube() const;
     300             : 
     301             :     casacore::Cube<casacore::Complex>& correctedVisCube();
     302             :     const casacore::Cube<casacore::Complex>& correctedVisCube() const;
     303             : 
     304             :     // Return visCube(), modelVisCube(), or correctedVisCube(),
     305             :     // according to whichcol.  They throw an exception if whichcol is
     306             :     // unsupported, but note the encouraged default.
     307             :     // TODO: Optionally return DATA if whichcol is unavailable.
     308             :     casacore::Cube<casacore::Complex>& dataCube(const casacore::MS::PredefinedColumns whichcol=casacore::MS::DATA);
     309             :     const casacore::Cube<casacore::Complex>& dataCube(const casacore::MS::PredefinedColumns
     310             :                                   whichcol=casacore::MS::DATA) const;
     311             : 
     312             :     casacore::Cube<casacore::Float>& floatDataCube();
     313             :     const casacore::Cube<casacore::Float>& floatDataCube() const;
     314             : 
     315             :     // Returns the weights for each row averaged over the parallel hand correlations.
     316             :     casacore::Vector<casacore::Float>& weight();
     317             :     const casacore::Vector<casacore::Float>& weight() const;
     318             : 
     319             :     // Returns the nPol_p x curNumRow_p weight matrix.
     320             :     casacore::Matrix<casacore::Float>& weightMat();
     321             :     const casacore::Matrix<casacore::Float>& weightMat() const;
     322             : 
     323             :     // Is a valid WEIGHT_SPECTRUM available?
     324             :     casacore::Bool existsWeightSpectrum() const;
     325             : 
     326             :     casacore::Cube<casacore::Float>& weightSpectrum();
     327             :     const casacore::Cube<casacore::Float>& weightSpectrum() const;
     328             : 
     329             :     const casacore::Matrix<casacore::Float>& imagingWeight() const;
     330             :     casacore::Matrix<casacore::Float> & imagingWeight ();
     331             : 
     332             :     casacore::Cube<casacore::Float>& weightCube();
     333             :     //</group>
     334             : 
     335             :     //<group>
     336             :     // Utility functions to provide coordinate or column ranges of the
     337             :     // data in the VisBuffer. Flagging is applied before computing the ranges.
     338             :     //
     339             :     // Generic accessor to column ranges of integer type, as specified by
     340             :     // enumerations defined in class MSCalEnums. Throws an exception
     341             :     // if the enum is not for a recognized integer column.
     342             :     casacore::Vector<casacore::Int> vecIntRange(const MSCalEnums::colDef & calEnum) const;
     343             : 
     344             :     // Antenna id. range (includes both ANTENNA1 and ANTENNA2 columns)
     345             :     casacore::Vector<casacore::Int> antIdRange() const;
     346             : 
     347             :     // casacore::Time range
     348             :     casacore::Bool timeRange(casacore::MEpoch & rTime, casacore::MVEpoch & rTimeEP, casacore::MVEpoch & rInterval) const;
     349             : 
     350             :     // Return the row Ids from the original ms. If the ms used is a subset of
     351             :     // another ms then rowIds() return the row ids of the original ms.
     352             :     virtual casacore::Vector<casacore::rownr_t>& rowIds();
     353             : 
     354             :     virtual const casacore::Vector<casacore::rownr_t>& rowIds() const;;
     355             : 
     356             :     //</group>
     357             : 
     358             :     // Frequency average the buffer (visibility() column only)
     359             :     void freqAverage();
     360             : 
     361             :     // Frequency average the buffer (visCube and [if present] modelVisCube)
     362             :     void freqAveCubes();
     363             : 
     364             :     // Average channel axis according to chanavebounds, for whichever of DATA,
     365             :     // MODEL_DATA, CORRECTED_DATA, FLOAT_DATA, FLAG, and WEIGHT_SPECTRUM are
     366             :     // present.  It will only treat the first 5 as present if they have already
     367             :     // been loaded into the buffer!
     368             :     void channelAve(const casacore::Matrix<casacore::Int>& chanavebounds);
     369             : 
     370             :     // Average channel axis by factor.
     371             :     template<class T> void chanAveVisCube(casacore::Cube<T>& data, casacore::Int nChanOut);
     372             : 
     373             :     // Accumulate channel axis by factor, without applying WEIGHT_SPECTRUM even
     374             :     // if it is present.
     375             :     // It is primarily intended for averaging WEIGHT_SPECTRUM itself.
     376             :     template<class T> void chanAccCube(casacore::Cube<T>& data, casacore::Int nChanOut);
     377             : 
     378             :     // This defaults to no conceptual side effects, but usually it is more
     379             :     // efficient to let it leave weightSpectrum() in a channel averaged state.
     380             :     // restoreWeightSpectrum has no effect if !existsWeightSpectrum().
     381             :     void chanAveFlagCube(casacore::Cube<casacore::Bool>& flagcube, const casacore::Int nChanOut,
     382             :                          const casacore::Bool restoreWeightSpectrum = true);
     383             : 
     384             :     // Form casacore::Stokes parameters from correlations
     385             :     //  (these are preliminary versions)
     386             :     void formStokes();
     387             :     void formStokesWeightandFlag();
     388             :     void formStokes(casacore::Cube<casacore::Complex>& vis);
     389             :     void formStokes(casacore::Cube<casacore::Float>& fcube);    // Will throw up if asked to do all 4.
     390             : 
     391             :     // casacore::Sort/unsort the correlations, if necessary
     392             :     //  (Rudimentary handling of non-canonically sorted correlations--use with care!)
     393             :     void sortCorr();
     394             :     void unSortCorr();
     395             : 
     396             :     // Normalize the visCube by the modelVisCube
     397             :     //   (and optionally also divide visCube_p by its normalized amp)
     398             :     void normalize(const casacore::Bool & phaseOnly = false);
     399             : 
     400             :     // Fill weightMat according to sigma column
     401             :     void resetWeightMat();
     402             : 
     403             :     // Rotate visibility phase for phase center offsets
     404             :     void phaseCenterShift(casacore::Double dx, casacore::Double dy);
     405             : 
     406             :     // Update coordinate info - useful for copied VisBuffers that need
     407             :     // to retain some state for later reference.
     408             :     // Presently this fills antenna, array, field and spectralWindow ids, time,
     409             :     // frequency and number of rows. Add more as needed.
     410             :     virtual void updateCoordInfo(const VisBuffer * vb = NULL);
     411             : 
     412             :     // Set the visibility to a constant, note that this only changes the buffer,
     413             :     // no values are written back to tables from here.
     414             :     virtual void setVisCube(casacore::Complex c);
     415             :     virtual void setModelVisCube(casacore::Complex c);
     416             :     virtual void setCorrectedVisCube(casacore::Complex c);
     417             : 
     418             :     // Set the visibility, note that this only changes the buffer,
     419             :     // no values are written back to tables from here.
     420             :     void setVisCube(const casacore::Cube<casacore::Complex>& vis);
     421             :     void setModelVisCube(const casacore::Cube<casacore::Complex>& vis);
     422             :     void setCorrectedVisCube(const casacore::Cube<casacore::Complex>& vis);
     423             : 
     424             :     // Like the above, but for FLOAT_DATA, keeping it as real floats.
     425             :     void setFloatDataCube(const casacore::Cube<casacore::Float>& fcube);
     426             : 
     427             :     // Set model according to a casacore::Stokes vector
     428             :     void setModelVisCube(const casacore::Vector<casacore::Float>& stokes);
     429             : 
     430             :     // Reference external model visibilities
     431             :     void refModelVis(const casacore::Matrix<CStokesVector>& mvis);
     432             : 
     433             :     // Remove scratch cols data from vb
     434             :     void removeScratchCols();
     435             : 
     436             :     // Access the current casacore::MSColumns object via VisIter
     437             :     virtual const casacore::MSColumns & msColumns() const;
     438             : 
     439             :     virtual  casacore::Int numberAnt () const;
     440             : 
     441             : 
     442             : 
     443             :     // Get all selected spectral windows not just the one in the actual buffer
     444             :     virtual void allSelectedSpectralWindows(casacore::Vector<casacore::Int>& spws, casacore::Vector<casacore::Int>& nvischan);
     445             : 
     446             :     void allSelectedSpectralWindows(casacore::Vector<casacore::Int>& spws, casacore::Vector<casacore::Int>& nvischan) const;
     447             : 
     448             :     // Return the actual msid, useful if using multiple ms to monitor which
     449             :     // ms in the  list is being dealt with
     450             :     virtual casacore::Int msId() const;
     451             : 
     452             :     //checked if the ms has changed since the last chunk processed
     453             :     virtual casacore::Bool newMS() const;
     454             : 
     455             :     void wrap (VisBufferAsync * vba);
     456             : 
     457             : protected:
     458             : 
     459             :     virtual casacore::Bool checkMSId();
     460             :     virtual void checkVisIter (const char * func, const char * file, int line) const;
     461             :     void copyCache (const VisBuffer & other, casacore::Bool force);
     462             :     const VisImagingWeight & getImagingWeightGenerator () const;
     463             :     casacore::Int getOldMsId () const;
     464             :     ROVisibilityIterator * getVisibilityIterator () const;
     465             :     VisBufferAsync * releaseVba ();
     466             : 
     467             :     // Create cache status accessors which relay the request to the wrapped
     468             :     // VBA.
     469             : 
     470             : #undef CacheStatus
     471             : #define CacheStatus(item)\
     472             : bool item ## OK () const\
     473             : {\
     474             :     if (wrappedVba_p == NULL){\
     475             :         throw casacore::AipsError ("VisBufferAsyncWrapper: No attached VBA", __FILE__, __LINE__);\
     476             :     }\
     477             :     return wrappedVba_p->item ## OK_p;\
     478             : }
     479             : 
     480           0 :     CacheStatus (antenna1);
     481           0 :     CacheStatus (antenna2);
     482           0 :     CacheStatus (arrayId);
     483           0 :     CacheStatus (channel);
     484           0 :     CacheStatus (cjones);
     485           0 :     CacheStatus (correctedVisCube);
     486           0 :     CacheStatus (correctedVisibility);
     487           0 :     CacheStatus (corrType);
     488           0 :     CacheStatus (dataDescriptionId);
     489           0 :     CacheStatus (direction1);
     490           0 :     CacheStatus (direction2);
     491           0 :     CacheStatus (exposure);
     492           0 :     CacheStatus (feed1_pa);
     493           0 :     CacheStatus (feed1);
     494           0 :     CacheStatus (feed2_pa);
     495           0 :     CacheStatus (feed2);
     496           0 :     CacheStatus (fieldId);
     497           0 :     CacheStatus (flagCategory);
     498           0 :     CacheStatus (flagCube);
     499           0 :     CacheStatus (flag);
     500           0 :     CacheStatus (flagRow);
     501           0 :     CacheStatus (floatDataCube);
     502           0 :     CacheStatus (frequency);
     503           0 :     CacheStatus (imagingWeight);
     504           0 :     CacheStatus (modelVisCube);
     505           0 :     CacheStatus (modelVisibility);
     506           0 :     CacheStatus (ms);
     507           0 :     CacheStatus (nChannel);
     508           0 :     CacheStatus (nCorr);
     509           0 :     CacheStatus (nRow);
     510           0 :     CacheStatus (observationId);
     511           0 :     CacheStatus (phaseCenter);
     512           0 :     CacheStatus (polFrame);
     513           0 :     CacheStatus (processorId);
     514           0 :     CacheStatus (rowIds);
     515           0 :     CacheStatus (scan);
     516           0 :     CacheStatus (sigmaMat);
     517           0 :     CacheStatus (sigma);
     518           0 :     CacheStatus (spectralWindow);
     519           0 :     CacheStatus (stateId);
     520           0 :     CacheStatus (timeCentroid);
     521           0 :     CacheStatus (timeInterval);
     522           0 :     CacheStatus (time);
     523           0 :     CacheStatus (uvwMat);
     524           0 :     CacheStatus (uvw);
     525           0 :     CacheStatus (visCube);
     526           0 :     CacheStatus (visibility);
     527           0 :     CacheStatus (weightMat);
     528           0 :     CacheStatus (weight);
     529           0 :     CacheStatus (weightSpectrum);
     530             : 
     531             : private:
     532             : 
     533             :     VisBufferAsync * wrappedVba_p;
     534             :     ROVisibilityIterator * wrappedVisIterAsync_p;
     535             : 
     536             :     // validate the cache
     537             :     void validate();
     538             :     void attachWrappedVb (ROVisibilityIterator * iter);
     539             : 
     540             :     void setAllCacheStatuses (bool status);
     541             : 
     542             : 
     543             :     casacore::Bool nonCanonCorr(); // Are correlations in non-canonical order?
     544             : 
     545             :     // Filter index arrays for unique elements
     546             :     casacore::Vector<casacore::Int> unique(const casacore::Vector<casacore::Int>& indices) const;
     547             : 
     548             :     // +-------------------------------------------------+
     549             :     // | Cache Declarations (fillers, statuses and data) |
     550             :     // +-------------------------------------------------+
     551             :     //
     552             :     // Preferred naming convention:
     553             :     //
     554             :     // T thing () --- returns the value of thing (public method)
     555             :     // T fillThing () --- fills thing cache variable and sets thingOK_p to true (private)
     556             :     // casacore::Bool thingOK_p --- true if the value of thing is currently cached  (private)
     557             :     // T thing_p --- holds cached value of thing (if thingOK_p is true)  (private)
     558             :     //
     559             :     // Example: casacore::Vector<casacore::Int>& feed1(); casacore::Vector<casacore::Int>& fillFeed1();
     560             :     //          casacore::Bool feed1OK_P; casacore::Vector<casacore::Int> feed1_p;
     561             : 
     562             :     // Cache filling routines in alphabetical order
     563             :     //
     564             :     // The first line in a fill routine should be the macro CheckVisIter.  This
     565             :     // will cause an casacore::AipsError to be throw when there is no visibilty iterator
     566             :     // associated with the VisBuffer.  This is especially important because the
     567             :     // fillers may be called on a VisBufferAsync in two contexts: filling
     568             :     // where there will be a VI attached and in normal use where there is no VI
     569             :     // attached.  The filler must also set the cache status variable to true during
     570             :     // its execution.
     571             : 
     572             :     casacore::Vector<casacore::Int>& fillAnt1();
     573             :     casacore::Vector<casacore::Int>& fillAnt2();
     574             :     casacore::Int & fillArrayId();
     575             :     //casacore::Matrix<casacore::Int>& fillChanAveBounds();
     576             :     casacore::Vector<casacore::Int>& fillChannel();
     577             :     casacore::Vector<casacore::SquareMatrix<casacore::Complex, 2> >& fillCjones();
     578             :     casacore::Vector<casacore::Int>& fillCorrType();
     579             :     virtual casacore::Vector<casacore::MDirection>& fillDirection1();
     580             :     virtual casacore::Vector<casacore::MDirection>& fillDirection2();
     581             :     casacore::Vector<casacore::Double>& fillExposure();
     582             :     casacore::Vector<casacore::Int>& fillFeed1();
     583             :     casacore::Vector<casacore::Float>& fillFeed1_pa();
     584             :     casacore::Vector<casacore::Int>& fillFeed2();
     585             :     casacore::Vector<casacore::Float>& fillFeed2_pa();
     586             :     casacore::Int & fillFieldId();
     587             :     casacore::Matrix<casacore::Bool>& fillFlag();
     588             :     casacore::Array<casacore::Bool>& fillFlagCategory();
     589             :     casacore::Cube<casacore::Bool>& fillFlagCube();
     590             :     casacore::Vector<casacore::Bool> & fillFlagRow();
     591             :     casacore::Cube<casacore::Float>& fillFloatDataCube();
     592             :     casacore::Vector<casacore::Double>& fillFreq();         // Puts SPECTRAL_WINDOW/CHAN_FREQ in frequency_p.
     593             :     //casacore::Matrix<casacore::Float>& fillImagingWeight();
     594             :     //casacore::Vector<casacore::Double>& fillLSRFreq();
     595             :     casacore::Int & fillnChannel();
     596             :     casacore::Int & fillnCorr();
     597             :     casacore::Int & fillnRow();
     598             :     casacore::Vector<casacore::Int> & fillObservationId();
     599             :     virtual casacore::MDirection & fillPhaseCenter();
     600             :     casacore::Int & fillPolFrame();
     601             :     casacore::Vector<casacore::Int> & fillProcessorId();
     602             :     casacore::Vector<casacore::Int> & fillScan();
     603             :     casacore::Vector<casacore::Float>& fillSigma();
     604             :     casacore::Matrix<casacore::Float>& fillSigmaMat();
     605             :     casacore::Int & fillSpW();
     606             :     casacore::Vector<casacore::Int> & fillStateId();
     607             :     casacore::Vector<casacore::Double>& fillTime();
     608             :     casacore::Vector<casacore::Double>& fillTimeCentroid();
     609             :     casacore::Vector<casacore::Double>& fillTimeInterval();
     610             :     casacore::Vector<casacore::RigidVector<casacore::Double, 3> >& filluvw();
     611             :     casacore::Matrix<casacore::Double>& filluvwMat();
     612             :     casacore::Matrix<CStokesVector>& fillVis(VisibilityIterator::DataColumn whichOne);
     613             :     casacore::Cube<casacore::Complex>& fillVisCube(VisibilityIterator::DataColumn whichOne);
     614             :     casacore::Vector<casacore::Float>& fillWeight();
     615             :     casacore::Matrix<casacore::Float>& fillWeightMat();
     616             :     casacore::Cube<casacore::Float>& fillWeightSpectrum();
     617             : 
     618             : };
     619             : 
     620             : } //# NAMESPACE CASA - END
     621             : 
     622             : #endif

Generated by: LCOV version 1.16