casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
AWProjectWBFT.h
Go to the documentation of this file.
00001 //# AWProjectWBFT.h: Definition for AWProjectWBFT
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_AWPROJECTWBFT_H
00030 #define SYNTHESIS_AWPROJECTWBFT_H
00031 #define DELTAPA 1.0
00032 #define MAGICPAVALUE -999.0
00033 
00034 
00035 #include <synthesis/TransformMachines/AWProjectFT.h>
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038   
00039   class EPJones;
00040 
00041   class AWProjectWBFT : public AWProjectFT {
00042 
00043   public:
00044     //
00045     // Constructor: cachesize is the size of the cache in words
00046     // (e.g. a few million is a good number), tilesize is the size of
00047     // the tile used in gridding (cannot be less than 12, 16 works in
00048     // most cases).  
00049     // <group>
00050     //
00051     AWProjectWBFT(Int nFacets, Long cachesize,
00052                   CountedPtr<CFCache>& cfcache,
00053                   CountedPtr<ConvolutionFunction>& cf,
00054                   CountedPtr<VisibilityResamplerBase>& visResampler,
00055                   Bool applyPointingOffset=True,
00056                   Bool doPBCorr=True,
00057                   Int tilesize=16, 
00058                   Float paSteps=5.0, 
00059                   Float pbLimit=5e-4,
00060                   Bool usezero=False,
00061                   Bool conjBeams_p=True,
00062                   Bool doublePrecGrid=False);
00063     // </group>
00064     
00065     // Construct from a Record containing the AWProjectWBFT state
00066     AWProjectWBFT(const RecordInterface& stateRec);
00067     
00068     // Copy constructor
00069     AWProjectWBFT(const AWProjectWBFT &other):AWProjectFT() {operator=(other);};
00070 
00071     // Assignment operator
00072     AWProjectWBFT &operator=(const AWProjectWBFT &other);
00073     
00074     ~AWProjectWBFT() {};
00075 
00076     virtual String name() const {return "AWProjectWBFT";};
00077 
00078 
00079     Int findPointingOffsets(const VisBuffer& vb, Array<Float> &l_off, Array<Float> &m_off,
00080                             Bool Evaluate);
00081     void normalizeAvgPB();
00082     void normalizeAvgPB(ImageInterface<Complex>& /*inImage*/, ImageInterface<Float>& /*outImage*/) 
00083     {throw(AipsError("AWPWBFT::normalizeAvgPB(Complex,Float)"));}
00084 
00085     //
00086     // This method is called from AWProjectFT to compute the
00087     // sensitivity image by accumulating in the image domain
00088     // (i.e. directly accumulate the Primay Beam functions).  This is
00089     // called from findConvFunction() so that sensitivity pattern is
00090     // also pre-computed along with the convolution functions.  This
00091     // in-turn calls the ATerm::makeAverageResponse().
00092     //
00093     // For AWProjectWBFT class of FTMachines, this just issues a log
00094     // message indicating that this is only setting up things for
00095     // accumulation of weight images in the first gridding cycle.  The
00096     // actual sensitivity patterns are computed by overloaded function
00097     // below.
00098     //
00099     virtual void makeSensitivityImage(const VisBuffer& vb, 
00100                                       const ImageInterface<Complex>& imageTemplate,
00101                                       ImageInterface<Float>& sensitivityImage);
00102     //
00103     // In AWProjectWBFT and its derivatives, sensitivity image is
00104     // computed by accumulating weight functions (images) during the
00105     // first gridding cycle.  AWProjectFT::makeSensitivityImage() is
00106     // overloaded in AWProjectWBFT and only issues a log message.
00107     //
00108     // The following method is used to Fourier transform normalize the
00109     // accumulated weight images.  doFFTNorm when True, the FFT
00110     // normalization (by pixel volume) is also done.
00111     //
00112     virtual void makeSensitivityImage(Lattice<Complex>& wtImage,
00113                                       ImageInterface<Float>& sensitivityImage,
00114                                       const Matrix<Float>& sumWt=Matrix<Float>(),
00115                                       const Bool& doFFTNorm=True);
00116     virtual void makeSensitivitySqImage(Lattice<Complex>& wtImage,
00117                                         ImageInterface<Complex>& sensitivitySqImage,
00118                                         const Matrix<Float>& sumWt=Matrix<Float>(),
00119                                         const Bool& doFFTNorm=True);
00120 
00121     //
00122     // Method used to make normalized image from gridded visibilites.
00123     // This calls makeSensitivityImage() to make the sensitivity image
00124     // and AWProjectFT::getImage() to make the image from gridded
00125     // visibilites.  AWProjectFT::getImage() internally calls
00126     // normalizeImage() which uses the sensitivty image computed by
00127     // makeSensitivtyImage().
00128     //
00129     virtual ImageInterface<Complex>& getImage(Matrix<Float>&, Bool normalize=True);
00130     //
00131     // Method used to convert the pixel value of the PB image, passed
00132     // as pbPixValue, to a value used for PB-normalization.
00133     // Typically, this will depend on the units of the "PB image"
00134     // constructed by the makeSensitivtyImage() methods. pbLimit is
00135     // the fractional pb-gain below which imaging is not required
00136     // (this value is typically the user-defined parameter in the
00137     // private member variable pbLimit_p).
00138     //
00139     inline virtual Float pbFunc(const Float& /*pbPixValue*/, const Float& /*pbLimit*/) 
00140     {return  1.0;};
00141     //   {Float tt=(pbPixValue);return  (abs(tt) >= pbLimit)?tt:1.0;};
00142  
00143 
00144    //    {Float tt=sqrt(pbPixValue);return  (abs(tt) >= pbLimit)?tt:1.0;};
00145 
00146     virtual void finalizeToSky();
00147     virtual void initializeToSky(ImageInterface<Complex>& image,  Matrix<Float>& weight,
00148                                  const VisBuffer& vb);
00149 
00150     void setObservatoryLocation(const MPosition& mLocation) {mLocation_p=mLocation;};
00151 
00152     virtual Bool verifyShapes(IPosition shape0, IPosition shape1)
00153     {(void)shape0; (void)shape1;return False;};
00154 
00155     //
00156     // Returns True if accumulation during gridding to compute the
00157     // average PB must be done.
00158     //
00159     virtual Bool computeAvgPB(const Double& /*actualPA*/, const Double& /*lastPAUsedForWtImg*/) 
00160     {return (avgPBReady_p==False);};
00161 
00162     // virtual void setMiscInfo(const Int qualifier)
00163     // {sensitivityPatternQualifier_p=qualifier;}
00164     //    {qualifier_p = qualifier;taylorQualifier_p = "_MFS_"+String::toString(qualifier_p)+"_";};
00165 
00166     //  virtual void ComputeResiduals(VisBuffer&vb, Bool useCorrected) {};
00167   protected:
00168     void ftWeightImage(Lattice<Complex>& wtImage, 
00169                        const Matrix<Float>& sumWt,
00170                        const Bool& doFFTNorm);
00171 
00172     virtual void resampleDataToGrid(Array<Complex>& griddedData,VBStore& vbs, 
00173                                     const VisBuffer& vb, Bool& dopsf);
00174     virtual void resampleDataToGrid(Array<DComplex>& griddedData,VBStore& vbs, 
00175                                     const VisBuffer& vb, Bool& dopsf);
00176     //    virtual void resampleGridToData(VBStore& vbs, const VisBuffer& vb);
00177     void resampleCFToGrid(Array<Complex>& wtsGrid, 
00178                           VBStore& vbs, const VisBuffer& vb);
00179 
00180     Bool avgPBReady_p,resetPBs_p, wtImageFTDone_p;
00181 
00182   private:
00183     String tt_pp;
00184     Vector<Int> fieldIds_p;
00185     TempImage<Complex> griddedWeights, griddedConjWeights;
00186     CFStore rotatedCFWts_p;
00187     Float pbNorm;
00188     CountedPtr<VisibilityResamplerBase> visResamplerWt_p;
00189     // //
00190     // // These ugly methods (ugly due to their flirtation with FORTRAN) should go!
00191     // //
00192     // virtual void runFortranGet(Matrix<Double>& uvw,Vector<Double>& dphase,
00193     //                         Cube<Complex>& visdata,
00194     //                         IPosition& s,
00195     //                         Int& Conj,
00196     //                         Cube<Int>& flags,Vector<Int>& rowFlags,
00197     //                         Int& rownr,Vector<Double>& actualOffset,
00198     //                         Array<Complex>* dataPtr,
00199     //                         Int& aNx, Int& aNy, Int& npol, Int& nchan,
00200     //                         VisBuffer& vb,Int& Nant_p, Int& scanNo,
00201     //                         Double& sigma,
00202     //                         Array<Float>& raoffsets,
00203     //                         Array<Float>& decoffsets,
00204     //                         Double area,
00205     //                         Int& doGrad,Int paIndex);
00206     // virtual void runFortranPut(Matrix<Double>& uvw,Vector<Double>& dphase,
00207     //                         const Complex& visdata_p,
00208     //                         IPosition& s,
00209     //                         Int& Conj,
00210     //                         Cube<Int>& flags,Vector<Int>& rowFlags,
00211     //                         const Matrix<Float>& weight,
00212     //                         Int& rownr,Vector<Double>& actualOffset,
00213     //                         Array<Complex>& dataPtr,
00214     //                         Int& aNx, Int& aNy, Int& npol, Int& nchan,
00215     //                         const VisBuffer& vb,Int& Nant_p, Int& scanNo,
00216     //                         Double& sigma,
00217     //                         Array<Float>& raoffsets,
00218     //                         Array<Float>& decoffsets,
00219     //                         Matrix<Double>& sumWeight,
00220     //                         Double& area,
00221     //                         Int& doGrad,
00222     //                         Int& doPSF,Int paIndex);
00223     // virtual void runFortranGetGrad(Matrix<Double>& uvw,Vector<Double>& dphase,
00224     //                             Cube<Complex>& visdata,
00225     //                             IPosition& s,
00226     //                             Cube<Complex>& gradVisAzData,
00227     //                             Cube<Complex>& gradVisElData,
00228     //                             Int& Conj,
00229     //                             Cube<Int>& flags,Vector<Int>& rowFlags,
00230     //                             Int& rownr,Vector<Double>& actualOffset,
00231     //                             Array<Complex>* dataPtr,
00232     //                             Int& aNx, Int& aNy, Int& npol, Int& nchan,
00233     //                             VisBuffer& vb,Int& Nant_p, Int& scanNo,
00234     //                             Double& sigma,
00235     //                             Array<Float>& l_off,
00236     //                             Array<Float>& m_off,
00237     //                             Double area,
00238     //                             Int& doGrad,
00239     //                             Int paIndex);
00240   };
00241 } //# NAMESPACE CASA - END
00242 
00243 #endif