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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1