casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SimplePBConvFunc.h
Go to the documentation of this file.
00001 //# SimplePBConvFunc.h: Definition for PixelatedConvFunc
00002 //# Copyright (C) 2007
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 #ifndef SYNTHESIS_SIMPLEPBCONVFUNC_H
00029 #define SYNTHESIS_SIMPLEPBCONVFUNC_H
00030 
00031 #include <casa/Arrays/Vector.h>
00032 #include <synthesis/TransformMachines/PBMathInterface.h>
00033 #include <casa/Containers/Block.h>
00034 #include <casa/Utilities/CountedPtr.h>
00035 
00036 namespace casa{
00037 
00038   // <summary>  A class to support FTMachines get their convolution Function </summary>
00039   
00040   // <use visibility=export>
00041   // <prerequisite>
00042   //   <li> <linkto class=VisBuffer>VisBuffer</linkto> module
00043 // </prerequisite>
00044   // <etymology>
00045   // "Simple" for cases that does not need parallactic angle and or frequency 
00046   // dependence ...hence one convolution function per pointing
00047   // "PB" for primary beam based convolution function
00048   // </etymology>
00049   //
00050   // <synopsis> 
00051   // FTMachines like WProjection and MosaicFT need convolution functions to 
00052   // deal with directional dependent issues...
00053   // this class and related ones provide and cache  such functions for re-use 
00054   //</synopsis>
00055   //Forward declarations
00056   template<class T> class ImageInterface;
00057   template<class T> class Matrix;
00058   class VisBuffer;
00059   class SkyJones;
00060   class CoordinateSystem;
00061   class DirectionCoordinate;
00062 
00063   class SimplePBConvFunc 
00064     {
00065     public:
00066       SimplePBConvFunc();
00067       SimplePBConvFunc(const PBMathInterface::PBClass typeToUse);
00068       SimplePBConvFunc(const RecordInterface& rec, Bool calcFlux_needed);
00069       virtual ~SimplePBConvFunc();
00070       // Inputs are the image, visbuffer, convSampling and skyjones
00071       // findconv return a cached convvolution function appropriate for this 
00072       // visbuffer and skyjones ...this one should be superseded 
00073       // by the one below and call setSkyJones when necessary
00074       virtual void findConvFunction(const ImageInterface<Complex>& , 
00075                             const VisBuffer& ,const Int& ,
00076                             SkyJones& ,
00077                             Matrix<Complex>& , 
00078                             Matrix<Complex>& , Int& ,
00079                                     Int& ){};
00080       
00082       // the vb.row and channel 
00083       //to the plane of the convfunc appropriate 
00084       virtual void findConvFunction(const ImageInterface<Complex>& iimage, 
00085                                     const VisBuffer& vb,
00086                                     const Int& convSampling,
00087                                     Cube<Complex>& convFunc, 
00088                                     Cube<Complex>& weightConvFunc, 
00089                                     Vector<Int>& convsize,
00090                                     Vector<Int>& convSupport,
00091                                     Vector<Int>& rowChanMap);
00092       virtual ImageInterface<Float>&  getFluxScaleImage();
00093       // slice fluxscale image by npol 
00094       virtual void sliceFluxScale(Int npol);
00095       //This is a function to just store the final weight image
00096       //as FT machines will share this object ...they can get share this too
00097       virtual void setWeightImage(CountedPtr<TempImage<Float> >& wgtimage);
00098 
00099       virtual void setSkyJones(SkyJones* sj);
00100 
00101       Bool findSupport(Array<Complex>& /*func*/, Float& /*threshold*/,Int& /*origin*/, Int& /*R*/) 
00102       {throw(AipsError("SimplePBConvFunc::findSupport() not implemented"));};
00103       virtual Bool makeAverageResponse(const VisBuffer& /*vb*/, 
00104                                        const ImageInterface<Complex>& /*image*/,
00105                                        ImageInterface<Float>& /*theavgPB*/,
00106                                        Bool /*reset=True*/)
00107       {throw(AipsError("SimplePBConvFunc::makeAverageRes() called"));};
00108 
00109       //Serialization
00110      virtual  Bool toRecord(RecordInterface& outRec);
00111       //From record 
00112       //set calcfluxneeded to True if flux scale need to be computed
00113       virtual Bool fromRecord(String& err, const RecordInterface& rec, Bool calcFluxneeded=False);
00114       //give possibility to erase history
00115       virtual void reset();
00116     protected:
00117       SkyJones* sj_p;
00118       TempImage<Float> fluxScale_p;
00119       Int nx_p; 
00120       Int ny_p;
00121       Int nchan_p;
00122       Int npol_p;
00123       CoordinateSystem csys_p;
00124       DirectionCoordinate dc_p;
00125       MDirection::Convert pointToPix_p;
00126       MeasFrame pointFrame_p;
00127       MEpoch::Types timeMType_p;
00128       Unit timeUnit_p;
00129       Int directionIndex_p;
00130       MDirection direction1_p;
00131       MDirection direction2_p;
00132       Vector<Double> thePix_p;
00133       Bool filledFluxScale_p;
00134       Bool doneMainConv_p;
00135       Bool calcFluxScale_p;
00136       virtual void storeImageParams(const ImageInterface<Complex>& iimage, const VisBuffer& vb);
00137       //return the direction pixel corresponding to a direction
00138       virtual void toPix(const VisBuffer& vb);
00139       CountedPtr<TempImage<Float> > convWeightImage_p;
00140     private:
00141       Bool checkPBOfField(const VisBuffer& vb);
00142       void addPBToFlux(const VisBuffer& vb);
00143       SimpleOrderedMap <String, Int> convFunctionMap_p;
00144       Int actualConvIndex_p;
00145       PBMathInterface::PBClass pbClass_p;
00146 
00147       Matrix<Complex> convFunc_p;
00148       Matrix<Complex> weightConvFunc_p;
00149       Matrix<Complex> convSave_p;
00150       Matrix<Complex> weightSave_p;
00151       Int convSize_p; 
00152       Int convSupport_p;
00153       //These are cubes for multiple PA
00154       //May need a per antenna one if each antenna has its own.
00155       Block <CountedPtr<Cube<Complex> > > convFunctions_p;
00156       Block <CountedPtr<Cube<Complex> > > convWeights_p;
00157       Block<CountedPtr<Vector<Int> > > convSizes_p;
00158       Block <CountedPtr<Vector<Int> > > convSupportBlock_p;
00159       Matrix<Bool> pointingPix_p;
00160 
00161       
00162     };
00163 };// end of namespace
00164 #endif