LCOV - code coverage report
Current view: top level - flagging/Flagging - RFFloatLattice.h (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 0 7 0.0 %
Date: 2023-11-06 10:06:49 Functions: 0 5 0.0 %

          Line data    Source code
       1             : //# RFFloatLattice.h: this defines RFFloatLattice
       2             : //# Copyright (C) 2000,2001
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This library is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU Library General Public License as published by
       7             : //# the Free Software Foundation; either version 2 of the License, or (at your
       8             : //# option) any later version.
       9             : //#
      10             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      11             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      13             : //# License for more details.
      14             : //#
      15             : //# You should have received a copy of the GNU Library General Public License
      16             : //# along with this library; if not, write to the Free Software Foundation,
      17             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed as follows:
      20             : //#        Internet email: aips2-request@nrao.edu.
      21             : //#        Postal address: AIPS++ Project Office
      22             : //#                        National Radio Astronomy Observatory
      23             : //#                        520 Edgemont Road
      24             : //#                        Charlottesville, VA 22903-2475 USA
      25             : //#
      26             : //# $Id$
      27             : #ifndef FLAGGING_RFFLOATLATTICE_H
      28             : #define FLAGGING_RFFLOATLATTICE_H
      29             :     
      30             : #include <casacore/casa/Arrays/Matrix.h> 
      31             : #include <casacore/lattices/Lattices/TempLattice.h> 
      32             : #include <casacore/lattices/Lattices/LatticeIterator.h> 
      33             : #include <vector>
      34             : 
      35             : namespace casa { //# NAMESPACE CASA - BEGIN
      36             : 
      37             : 
      38             : // <summary>
      39             : // RFFloatLatticeIterator: iterator over a cubic buffer
      40             : // </summary>
      41             : 
      42             : // <use visibility=local>
      43             : 
      44             : // <reviewed reviewer="" date="" tests="" demos="">
      45             : // </reviewed>
      46             : 
      47             : // <prerequisite>
      48             : //   <li> std::vector, Matrix
      49             : // </prerequisite>
      50             : //
      51             : // <synopsis>
      52             : // See RFFloatLattice, below
      53             : // </synopsis>
      54             : //
      55             : // <todo asof="2001/04/16">
      56             : //   <li> add this feature
      57             : //   <li> fix this bug
      58             : //   <li> start discussion of this possible extension
      59             : // </todo>
      60             : 
      61             : class RFFloatLattice;
      62             : 
      63             : class RFFloatLatticeIterator
      64             : {
      65             :   private:
      66             :     // vector<bool>: is a space-efficient specialization of std::vector for the type bool
      67             :     std::vector<std::vector<bool> > *lattice;
      68             : 
      69             :     casacore::Matrix<casacore::Float> curs;
      70             : 
      71             :     unsigned int iter_pos;
      72             : 
      73             :     unsigned n_chan, n_ifr, /* n_time,*/ n_bit, n_corr;
      74             : 
      75             :     void update_curs();
      76             :   
      77             :   public:
      78             :     // default constructor creates empty iterator
      79             :     RFFloatLatticeIterator();
      80             :     
      81             :     // creates and attaches to lattice
      82             :     RFFloatLatticeIterator(std::vector<std::vector<bool> > *lat, 
      83             :                           unsigned nchan, unsigned nifr, 
      84             :                           unsigned ntime, unsigned nbit, unsigned ncorr);
      85             :     
      86             :     // destructor
      87             :     ~RFFloatLatticeIterator();
      88             : 
      89             :     // resets the lattice iterator to beginning, returns cursor
      90             :     casacore::Matrix<casacore::Float> * reset();
      91             :     
      92             :     // advances internal iterator to specified slot along the Z axis, returns cursor
      93             :     casacore::Matrix<casacore::Float> * advance( casacore::uInt iz );
      94             :     
      95             :     // returns position of internal iterator
      96           0 :     casacore::uInt position ()                 
      97           0 :       { return iter_pos; }
      98             :     
      99             :     //  returns internal cursor
     100             :     casacore::Matrix<casacore::Float> * cursor();
     101             :     
     102             :     // returns element at i,j of cursor
     103             :     casacore::Float & operator () ( casacore::uInt i,casacore::uInt j );
     104             : 
     105             :     void flush_curs();
     106             : };
     107             : 
     108             : 
     109             : // <summary>
     110             : // RFFloatLatice: a cubic lattice
     111             : // </summary>
     112             : 
     113             : // <use visibility=local>
     114             : 
     115             : // <reviewed reviewer="" date="" tests="" demos="">
     116             : // </reviewed>
     117             : 
     118             : // <prerequisite>
     119             : //   <li> TempLattice
     120             : // </prerequisite>
     121             : //
     122             : // <synopsis>
     123             : // RFFloatLattice is a [NX,NY,NZ] vector of Matrices which 
     124             : // is iterated over the Z axis. 
     125             : // While a vector of Matrices may not be localized in memory, it has the
     126             : // advantage that the total amount of memory allocated can exceed
     127             : // the available RAM, which is probably not possible if allocated as a
     128             : // single giant block.
     129             : // Each element of the matrices is a few bits, therefore (in order to
     130             : // save memory), the full matrix is represented as a bitsequence, which
     131             : // is converted to casacore::Matrix<casacore::Float> on the fly.
     132             : //
     133             : // The buffer is no longer implemented using a casacore::TempLattice because the
     134             : // template parameter to casacore::TempLattice is restricted to certain types, and
     135             : // cannot be dynamic_bitset<>. Besides, casacore::TempLattice is currently(?)
     136             : // *not* well implemented: it creates casacore::TempLattice disk files although most
     137             : // of the RAM is free.
     138             : //
     139             : // If more memory than avilable RAM is requested, swapping will occur.
     140             : // The underlying OS probably knows better when to swap!
     141             : //
     142             : // </synopsis>
     143             : //
     144             : // <motivation>
     145             : // Many flagging agents make use of cubic lattices (typically, to maintain
     146             : // [NCHAN,NIFR,NTIME] cubes of something) in an identical way. This class
     147             : // provides a clean and convenient interface to the basic functions.
     148             : // </motivation>
     149             : //
     150             : // <templating arg=T>
     151             : //    <li> same as Matrix
     152             : // </templating>
     153             : //
     154             : // <todo asof="2001/04/16">
     155             : //   <li> add this feature
     156             : //   <li> fix this bug
     157             : //   <li> start discussion of this possible extension
     158             : // </todo>
     159             : 
     160             : class RFFloatLattice
     161             : {
     162             : protected:
     163             :   casacore::IPosition                              lat_shape;
     164             :   std::vector<std::vector<bool> >        lat;
     165             :   RFFloatLatticeIterator                 iter;
     166             :   unsigned n_chan, n_ifr, n_time, n_bit, n_corr;
     167             : 
     168             : public:
     169             : // default constructor creates empty cube
     170             :   RFFloatLattice();
     171             : // creates NX x NY x NZ cube
     172             :   RFFloatLattice( casacore::uInt nx,casacore::uInt ny,casacore::uInt nz, casacore::uInt ncorr, casacore::uInt nAgent, casacore::Int maxmem=-1 );
     173             : // creates NX x NY x NZ cube and fills with initial value
     174             :   RFFloatLattice( casacore::uInt nx,casacore::uInt ny,casacore::uInt nz, casacore::uInt ncorr, casacore::uInt nAgent, const casacore::Float &init_val,casacore::Int maxmem=-1 );
     175             : // destructor
     176             :   ~RFFloatLattice();
     177             : 
     178             : // creates NX x NY x NZ cube
     179             : // tile_mb is the tile size, in MB (when using paging)
     180             :   void init ( casacore::uInt nx,casacore::uInt ny,casacore::uInt nz, casacore::uInt ncorr, casacore::uInt nAgent, casacore::Int maxmem=-1,casacore::Int tile_mb=2 );
     181             : // creates NX x NY x NZ cube and fills with initial value
     182             : // tile_mb is the tile size, in MB (when using paging)
     183             :   void init ( casacore::uInt nx,casacore::uInt ny,casacore::uInt nz, casacore::uInt ncorr, casacore::uInt nAgent, const casacore::Float &init_val,casacore::Int maxmem=-1,casacore::Int tile_mb=2 );
     184             : // destroys cube
     185             :   void cleanup ();
     186             : // returns size of cube
     187           0 :   static casacore::uInt estimateMemoryUse ( casacore::uInt nx,casacore::uInt ny,casacore::uInt nz )
     188           0 :         { return nx*ny*nz*sizeof(casacore::Float)/(1024*1024) + 1; }
     189             : 
     190             : // resets the lattice iterator to beginning. 
     191             :   casacore::Matrix<casacore::Float> * reset( casacore::Bool will_read=true,
     192             :                      casacore::Bool will_write=true );  
     193             :   
     194             : // advances internal iterator to specified slot along the Z axis, returns cursor
     195           0 :   casacore::Matrix<casacore::Float> * advance( casacore::Int iz )   { return iter.advance(iz); };
     196             :   
     197             : // returns position of internal iterator
     198           0 :   casacore::Int position ()                 { return iter.position(); }
     199             :   
     200             : // returns shape
     201             :   const casacore::IPosition & shape ()      { return lat_shape; }
     202             : 
     203             : //  returns internal cursor
     204             :   casacore::Matrix<casacore::Float> * cursor()              { return iter.cursor(); }
     205             :   
     206             : // returns element at i,j of cursor
     207           0 :   casacore::Float & operator () ( casacore::uInt i,casacore::uInt j )  { return (*iter.cursor())(i,j); }
     208             :   
     209             : // provides access to lattice itself  
     210             : //  std::vector<std::vector<bool> > & lattice()    { return lat; }
     211             : 
     212             : // provides access to iterator  
     213             :   RFFloatLatticeIterator & iterator()    { return iter; }
     214             : 
     215             : // creates a new iterator for this lattice
     216             :   RFFloatLatticeIterator newIter();
     217             : };
     218             : 
     219             : 
     220             : 
     221             : } //# NAMESPACE CASA - END
     222             : 
     223             : #endif

Generated by: LCOV version 1.16