casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
VisBuffGroup.h
Go to the documentation of this file.
00001 //# VisBuffGroup.h: class to store a group of VisBuffers
00002 //# Copyright (C) 2011
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 
00027 #ifndef MSVIS_VISBUFFGROUP_H
00028 #define MSVIS_VISBUFFGROUP_H
00029 
00030 #include <casa/aips.h>
00031 #include <synthesis/MSVis/VisBuffer.h>
00032 #include <casa/Arrays/Vector.h>
00033 
00034 namespace casa { //# NAMESPACE CASA - BEGIN
00035 
00036 // <summary>
00037 // A class to store a group of VisBuffers.
00038 // </summary>
00039 //
00040 // <use visibility=export>
00041 //
00042 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00043 // </reviewed>
00044 
00045 // <prerequisite>
00046 //   <li> VisBuffer
00047 // </prerequisite>
00048 //
00049 // <etymology>
00050 //   It is a group of VisBuffers
00051 // </etymology>
00052 //
00053 // <synopsis>
00054 // This class stores a group of VisBuffers.  Unlike VisBuffGroupAcc or
00055 // VisBuffAccumulator, the VisBuffers are copied and stored in a nearly
00056 // pristine state so that their individual contents can be accessed later
00057 // (i.e. without any averaging).  The only difference between a normal (or
00058 // "fresh") VisBuffer and one retrieved from a VisBuffGroup is that
00059 // VisBuffGroup detaches its VisBuffers from any underlying VisIter.
00060 // </synopsis>
00061 //
00062 // <example>
00063 // </example>
00064 //
00065 // <motivation>
00066 // Some calculations or applications need more than one VisBuffer.  For
00067 // example, one might want to estimate and subtract the continuum from the
00068 // visibilities of an MS that has a broad line completely spanning spw 1, but
00069 // spws 0 and 2 line-free, so the spws should be combined (combine='spw') for
00070 // the continuum estimation.
00071 //
00072 // It is much more efficient if the group of necessary data can be read only
00073 // once, worked on, and then written.  The CalTable approach is more flexible
00074 // in that a CalTable can be applied to an MS with a different number or
00075 // arrangement of rows from the input MS, but per chunk it requires two more
00076 // reads (the CalTable and the _output_ MS) and an extra write (the CalTable).
00077 // </motivation>
00078 //
00079 // <todo asof="2011/11/07">
00080 //   <li> Allow retrieval by timestamp.
00081 // </todo>
00082 
00083 class VisBuffGroup
00084 {
00085 public:
00086   VisBuffGroup();
00087 
00088   // Null destructor
00089   ~VisBuffGroup();
00090 
00091   // Add a VisBuffer.  Returns True on success and False on failure.
00092   Bool store(const VisBuffer& vb);
00093 
00094   // Record the end of a chunk.
00095   // Doing so marks that if "playing back" a VisIter vi matching the order that
00096   // the VBs were stored in, vi.nextChunk() will be needed at this point
00097   // instead of ++vi.
00098   void endChunk();
00099 
00100   // (See endChunk())  Returns whether or not vi.nextChunk() should be used
00101   // when advancing past buffer number buf.
00102   Bool chunkEnd(const Int buf) const {return endChunk_p[buf];}
00103 
00104   // Replace the VisBuffer in slot buf with vb.
00105   // Returns True on success and False on failure.
00106   // Bool replace(const VisBuffer& vb, const uInt buf);
00107 
00108   // How many VisBuffers are contained herein?
00109   uInt nBuf() const {return nBuf_p;}
00110 
00111   // uInt nDDID() const {return nDDID_p;}
00112   // uInt nFld()  const {return nFld_p;}
00113 
00114   // Return a reference to the indexed VisBuffer.
00115   // Throws an exception if buf > nBuf().
00116   VisBuffer& operator()(const Int buf);
00117 
00118   // // Returns the buffer index corresponding to data description ID ddid and
00119   // // field ID fld.
00120   // //
00121   // // Returns -1 if there is no such buffer.
00122   // //
00123   // // Returns -(# of matching buffers) if there is > 1 match (use bufInds).
00124   // Int bufInd(const Int ddid, const Int fld);
00125 
00126   // // Returns the buffer indices corresponding to data description ID ddid and
00127   // // field ID fld.
00128   // Vector<Int> bufInds(const Int ddid, const Int fld)
00129 
00130   // The flagging approach to channel selection.
00131   // Sets chanmaskedflags to True wherever the channels in chanmask or flags in
00132   // vb.flagCube() are True, resizing if necessary.
00133   // Returns True/False on success/error (i.e. chanmask having a different # of
00134   // channels from vb.flagCube()).
00135   static Bool applyChanMask(Cube<Bool>& chanmaskedflags,
00136                             const Vector<Bool> *chanmask, const VisBuffer& vb);
00137 
00138 private:
00139   // Prohibit public copying and assignment.
00140   VisBuffGroup(const VisBuffGroup&);
00141   VisBuffGroup& operator=(const VisBuffGroup&);
00142 
00143   // // Numbers of data description ids and fields
00144   // uInt nDDID_p, nFld_p, nBuf_p;
00145 
00146   // Number of buffers.
00147   uInt nBuf_p;
00148 
00149   // The list of buffers.
00150   PtrBlock<VisBuffer*> VB_p;
00151   
00152   Vector<Bool> endChunk_p;
00153 
00154   // // Map spw,fld to the buffer id
00155   // Matrix<Int> spwfldids_p;
00156 };
00157 
00158 
00159 } //# NAMESPACE CASA - END
00160 
00161 #endif
00162 
00163