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