casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ConvFuncDiskCache.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //# ConvFuncDiskCache.cc: Definition of the ConvFuncDiskCache class
00003 //# Copyright (C) 1997,1998,1999,2000,2001,2002,2003
00004 //# Associated Universities, Inc. Washington DC, USA.
00005 //#
00006 //# This library is free software; you can redistribute it and/or modify it
00007 //# under the terms of the GNU Library General Public License as published by
00008 //# the Free Software Foundation; either version 2 of the License, or (at your
00009 //# option) any later version.
00010 //#
00011 //# This library is distributed in the hope that it will be useful, but WITHOUT
00012 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014 //# License for more details.
00015 //#
00016 //# You should have received a copy of the GNU Library General Public License
00017 //# along with this library; if not, write to the Free Software Foundation,
00018 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00019 //#
00020 //# Correspondence concerning AIPS++ should be addressed as follows:
00021 //#        Internet email: aips2-request@nrao.edu.
00022 //#        Postal address: AIPS++ Project Office
00023 //#                        National Radio Astronomy Observatory
00024 //#                        520 Edgemont Road
00025 //#                        Charlottesville, VA 22903-2475 USA
00026 //#
00027 //# $Id$
00028 #ifndef SYNTHESIS_CONVFUNCDISKCACHE_H
00029 #define SYNTHESIS_CONVFUNCDISKCACHE_H
00030 
00031 #include <casa/Arrays/Matrix.h>
00032 #include <synthesis/MSVis/VisBuffer.h>
00033 #include <images/Images/ImageInterface.h>
00034 #include <images/Images/PagedImage.h>
00035 #include <casa/Arrays/Array.h>
00036 #include <casa/Arrays/Vector.h>
00037 #include <lattices/Lattices/LatticeCache.h>
00038 #include <lattices/Lattices/ArrayLattice.h>
00039 #include <coordinates/Coordinates/DirectionCoordinate.h>
00040 #include <synthesis/TransformMachines/VPSkyJones.h>
00041 // Apparently not required here? (gmoellen 06Nov20)
00042 //#include <synthesis/MeasurementComponents/EPTimeVarVisJones.h>
00043 #include <synthesis/TransformMachines/Utils.h>
00044 namespace casa { //# NAMESPACE CASA - BEGIN
00045   // <summary> 
00046   //
00047   // An object to manage the caches of pre-computed convolution
00048   // functions on the disk and in the memory.
00049   //
00050   // </summary>
00051   
00052   // <use visibility=export>
00053   
00054   // <reviewed reviewer="" date="" tests="" demos="">
00055   
00056   // <prerequisite>
00057   //  No pre-requisites.  
00058   // </prerequisite>
00059   //
00060   // <etymology> 
00061   //
00062   // ConvFuncDiskCache is an object, to write convolution
00063   // functions from the memory cache to the disk cache, and
00064   // search/load the disk cache for convolution functions for a give
00065   // Parallactic Angle.  
00066   //
00067   //</etymology>
00068   //
00069   // <synopsis> 
00070   //
00071   // FTMachines uses pre-computed convolution functions for gridding
00072   // (FTMachine::put()) and prediction (FTMachine::get()).  For
00073   // <linkto class=PBWProjectFT>PBWProjectFT</linkto>, the convolution
00074   // function computation is expensive.  Once computed, it is
00075   // efficient to cache these functions as a function of Parallactic
00076   // Angle and the value of the w-term (if significant). 
00077   //
00078   // ConvFuncDiskCache class provides interface to the disk cache and
00079   // is used in <linkto class=PBWProjectFT>PBWProjectFT</linkto> to
00080   // search and load convolution functions from the disk.  If a new
00081   // convolution function is computed in <linkto
00082   // class=PBWProjectFT>PBWProjectFT</linkto>, the disk cache is
00083   // updated using the services of this class as well.
00084   //
00085   // </synopsis> 
00086   //
00087   // <example>
00088   // </example>
00089   //
00090   // <motivation>
00091   //
00092   // Factor out the code for managing convolution function caches
00093   // (memory and disk caches) from the FTMachine code.  This is a
00094   // specialized service, and has nothing to do with the details of
00095   // gridding and prediction of visibilities (which is the function of
00096   // FTMachines).
00097   //
00098   // </motivation>
00099   //
00100   // <todo asof="2005/07/21">
00101   //
00102   // <ul> Generalize to handle convolution functions for inhomogeneous
00103   // arrays and multi-feed antennas.
00104   //
00105   // </todo>
00106 
00107   class ConvFuncDiskCache
00108   {
00109   public:
00110     ConvFuncDiskCache():paList(),XSup(),YSup(), cfPrefix("CF"), aux("aux.dat") {};
00111     ConvFuncDiskCache& operator=(const ConvFuncDiskCache& other);
00112     ~ConvFuncDiskCache() {};
00113     void setCacheDir(const char *dir) {Dir = dir;}
00114     void initCache();
00115     void cacheConvFunction(Int which, Float pa, Array<Complex>& cf, CoordinateSystem& coords,
00116                            CoordinateSystem& ftcoords, Int& convSize, Cube<Int>& convSupport, 
00117                            Float convSampling, String nameQualifier="",Bool savePA=True);
00118     void cacheWeightsFunction(Int which, Float pa, Array<Complex>& cfWt, CoordinateSystem& coords,
00119                               Int& convSize, Cube<Int>& convSupport, Float convSampling);
00120     Bool searchConvFunction(const VisBuffer& vb, VPSkyJones& vpSJ, Int& which, Float &pa);
00121     Bool searchConvFunction(const VisBuffer& vb, ParAngleChangeDetector& vpSJ, 
00122                             Int& which, Float &pa);
00123     Bool loadConvFunction(Int where, Int Nx, PtrBlock < Array<Complex> *> & convFuncCache,
00124                           Cube<Int> &convSupport, Vector<Float>& convSampling,
00125                           Double& cfRefFreq,CoordinateSystem& coordys, String prefix="/CF");
00126     void finalize();
00127     void finalize(ImageInterface<Float>& avgPB);
00128     void loadAvgPB(ImageInterface<Float>& avgPB);
00129   private:
00130     Vector<Float> paList, Sampling;
00131     Cube<Int> XSup, YSup;
00132     String Dir, cfPrefix, aux;
00133   };
00134 }
00135 
00136 #endif