casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ConvolutionFunction.h
Go to the documentation of this file.
00001 //# ConvolutionFunction.h: Definition for ConvolutionFunction
00002 //# Copyright (C) 1996,1997,1998,1999,2000,2002
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 adressed 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 //# $Id$
00028 
00029 #ifndef SYNTHESIS_CONVOLUTIONFUNCTION_H
00030 #define SYNTHESIS_CONVOLUTIONFUNCTION_H
00031 
00032 #include <synthesis/TransformMachines/CFStore.h>
00033 #include <synthesis/TransformMachines/CFStore2.h>
00034 #include <synthesis/TransformMachines/PolOuterProduct.h>
00035 #include <synthesis/TransformMachines/Utils.h>
00036 #include <images/Images/ImageInterface.h>
00037 #include <images/Images/TempImage.h>
00038 #include <casa/Logging/LogOrigin.h>
00039 #include <casa/Logging/LogSink.h>
00040 #include <casa/Logging/LogIO.h>
00041 #include <casa/Arrays/Vector.h>
00042 #define CF_TYPE Double
00043 
00044 namespace casa{
00045   // <summary>  
00046   //  The base class to compute convolution functions for convolutional gridding. 
00047   // </summary>
00048   
00049   // <use visibility=export>
00050   // <prerequisite>
00051   // </prerequisite>
00052   // <etymology>
00053   //   Class to encapsulate the convolution function for convolutional gridding.
00054   // </etymology>
00055   //
00056   // <synopsis> Standard method of re-sampling data to or from a
00057   //
00058   //  regular grid is done by convolutional gridding.  This requires a
00059   //  convolution function which a finte support size and well behaved
00060   //  function in the Fourier domain.  For standard gridding, the
00061   //  Prolate Spheroidal function are used.  Convolution functions
00062   //  used in Projection algorithms (like W-Projection, A-Projection,
00063   //  etc. and their combinations) each require potentially different
00064   //  mechanisms to compute.  These are implemented in separate
00065   //  classes in the Synthesis module.  Since these are used in common
00066   //  framework for gridding and de-gridding, these are all derived
00067   //  from a common base class.  ConvolutionFunction (this class) is
00068   //  that base class.
00069   //
00070   //  Most of the methods in this base class are pure virtual.  I.e.,
00071   //  only surviving offsprings (derived classes) of this class will
00072   //  be those that will have the wisdom that they methods represent.
00073   //
00074   // </synopsis>
00075 
00076   class ConvolutionFunction
00077   {
00078   public:
00079     ConvolutionFunction():logIO_p(), computeCFAngleRad_p(360.0*M_PI/180.0), rotateCFOTFAngleRad_p(0.1) {};
00080     ConvolutionFunction(Int dim): computeCFAngleRad_p(360.0*M_PI/180.0), rotateCFOTFAngleRad_p(0.1) {nDim=dim;};
00081     virtual ~ConvolutionFunction();
00082     
00083     // Set the dimention of the convolution function.
00084     virtual void setDimension(Int n){nDim = n;};
00085 
00086     // Given the pixel co-ordinates and an offset values, this returns
00087     // the value of the convolution function.  This is however not
00088     // used anywhere yet (and is therefore also not a pure virtual
00089     // function).
00090     virtual CF_TYPE getValue(Vector<CF_TYPE>& , Vector<CF_TYPE>& ) {return 0.0;};
00091 
00092     // A support function which, for now, returns and integer ID
00093     // corresponding to the on-sky frequency of the supplied VisBuffer.
00094     virtual int getVisParams(const VisBuffer& vb,const CoordinateSystem& skyCoord=CoordinateSystem())=0;
00095 
00096     // This method computes the convolution function and the
00097     // convolution function used for gridding the weights (typically
00098     // these are the same) and returns them in the cfs and cfwts
00099     // parameters.  The required information about the image and
00100     // visibility parameters is dervided from the given image and
00101     // VisBuffer objects.  wConvSize is the number of w-term planes
00102     // and pa is the Parallactic Angle in radians for which the
00103     // convolution function(s) are computed.
00104     virtual void makeConvFunction(const ImageInterface<Complex>& image,
00105                                   const VisBuffer& vb,
00106                                   const Int wConvSize,
00107                                   const CountedPtr<PolOuterProduct>& pop,
00108                                   const Float pa, 
00109                                   const Float dpa, 
00110                                   const Vector<Double>& uvScale, const Vector<Double>& uvOffset,
00111                                   const Matrix<Double>& vbFreqSelection,
00112                                   CFStore2& cfs,
00113                                   CFStore2& cfwts) = 0;
00114     // This method computes the average response function.  This is
00115     // typically image-plane equivalent of the convolution functions,
00116     // averaged over various axis.  The precise averaging will be
00117     // implementation dependent in the derived classes.
00118     virtual Bool makeAverageResponse(const VisBuffer& vb, 
00119                                      const ImageInterface<Complex>& image,
00120                                      ImageInterface<Float>& theavgPB,
00121                                      Bool reset=True) = 0;
00122     virtual Bool makeAverageResponse(const VisBuffer& vb, 
00123                                      const ImageInterface<Complex>& image,
00124                                      ImageInterface<Complex>& theavgPB,
00125                                      Bool reset=True) = 0;
00126 
00127     //
00128     virtual void setPolMap(const Vector<Int>& polMap) = 0;
00129     virtual void setSpwSelection(const Cube<Int>& spwChanSelFlag) {spwChanSelFlag_p.assign(spwChanSelFlag);}
00130     virtual void setSpwFreqSelection(const Matrix<Double>& spwFreqSel) {spwFreqSelection_p.assign(spwFreqSel);}
00131     virtual void setRotateCF(const Double& computeCFAngleRad, const Double& rotateOTF) 
00132     {computeCFAngleRad_p=computeCFAngleRad; rotateCFOTFAngleRad_p = rotateOTF;};
00133 
00134     //    virtual void setFeedStokes(const Vector<Int>& feedStokes) = 0;
00135     virtual Bool findSupport(Array<Complex>& func, Float& threshold,Int& origin, Int& R)=0;
00136     virtual Vector<Double> findPointingOffset(const ImageInterface<Complex>& image,
00137                                               const VisBuffer& vb) = 0;
00138 
00139     // virtual void setParams(const Vector<Int>& polMap, const Vector<Int>& feedStokes)
00140     // {setPolMap(polMap); setFeedStokes(feedStokes);};
00141 
00142     //    virtual void prepareConvFunction(const VisBuffer& vb, CFStore2& cfs)=0;
00143     virtual void prepareConvFunction(const VisBuffer& vb, VBRow2CFBMapType& theMap)=0;
00144     virtual Matrix<Int> makeBaselineList(const Vector<Int>& antList);
00145     virtual Int mapAntIDToAntType(const Int& /*ant*/) {return 0;};
00146     virtual void setMiscInfo(const RecordInterface& /*params*/) {};
00147   private:
00148     Int nDim;
00149   protected:
00150     LogIO& logIO() {return logIO_p;}
00151     LogIO logIO_p;
00152     Cube<Int> spwChanSelFlag_p;
00153     Matrix<Double> spwFreqSelection_p;
00154     Double computeCFAngleRad_p, rotateCFOTFAngleRad_p;
00155   };
00156 
00157 };
00158 
00159 #endif