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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1