MultiTermFTNew.h

Go to the documentation of this file.
00001 //# NewMultiTermFT.h: Definition for NewMultiTermFT
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_MULTITERMFTNEW_H
00030 #define SYNTHESIS_MULTITERMFTNEW_H
00031 
00032 #include <synthesis/TransformMachines/FTMachine.h>
00033 #include <casa/Arrays/Matrix.h>
00034 #include <scimath/Mathematics/FFTServer.h>
00035 #include <msvis/MSVis/VisBuffer.h>
00036 #include <images/Images/ImageInterface.h>
00037 #include <images/Images/ImageInterface.h>
00038 #include <casa/Containers/Block.h>
00039 #include <casa/Arrays/Array.h>
00040 #include <casa/Arrays/Vector.h>
00041 #include <casa/Arrays/Matrix.h>
00042 #include <scimath/Mathematics/ConvolveGridder.h>
00043 #include <lattices/Lattices/LatticeCache.h>
00044 #include <lattices/Lattices/ArrayLattice.h>
00045 //#include <synthesis/MeasurementComponents/SynthesisPeek.h>
00046 #include <casa/OS/Timer.h>
00047 
00048 namespace casa { //# NAMESPACE CASA - BEGIN
00049 
00050 class UVWMachine;
00051 
00052 class MultiTermFTNew : public FTMachine {
00053 public:
00054 
00055   // Construct using an existing FT-Machine 
00056   MultiTermFTNew(CountedPtr<FTMachine>& subftm, Int nterms=1, Bool forward=False);
00057 
00058   // Construct from a Record containing the MultiTermFTNew state
00059   MultiTermFTNew(const RecordInterface& stateRec);
00060 
00061   // Copy constructor. 
00062   // This first calls the default "=" operator, and then instantiates objects for member pointers.
00063   MultiTermFTNew(const MultiTermFTNew &other);
00064 
00065   // Assignment operator --- leave it as the default
00066   MultiTermFTNew &operator=(const MultiTermFTNew &other);
00067 
00068   // Destructor
00069   ~MultiTermFTNew();
00070 
00071   // Called at the start of de-gridding : subftm->initializeToVis()
00072   // Note : Pre-de-gridding model-image divisions by PBs will go here.
00073   void initializeToVis(ImageInterface<Complex>& /*image*/, 
00074                        const VisBuffer& /*vb*/)
00075   {throw(AipsError("MultiTermFTNew::initializeToVis called without vectors !"));};
00076 
00077    // Vectorized InitializeToVis
00078   //  void initializeToVis(Block<CountedPtr<ImageInterface<Complex> > > & compImageVec,PtrBlock<SubImage<Float> *> & modelImageVec, PtrBlock<SubImage<Float> *>& weightImageVec, PtrBlock<SubImage<Float> *>& fluxScaleVec, Block<Matrix<Float> >& weightsVec, const VisBuffer& vb);
00079 
00080   virtual void initializeToVisNew(const VisBuffer& vb,
00081                                              CountedPtr<SIImageStore> imstore);
00082 
00083   // Called at the end of de-gridding : subftm->finalizeToVis()
00084   void finalizeToVis();
00085 
00086   // Called at the start of gridding : subftm->initializeToSky()
00087   void initializeToSky(ImageInterface<Complex>& /*image*/,  
00088                        Matrix<Float>& /*weight*/, const VisBuffer& /*vb*/) 
00089    {throw(AipsError("MultiTermFTNew::initializeToSky() called without vectors!"));};
00090 
00091   //  void initializeToSky(Block<CountedPtr<ImageInterface<Complex> > > & compImageVec, Block<Matrix<Float> >& weightsVec, const VisBuffer& vb, const Bool dopsf);
00092 
00093   virtual void initializeToSkyNew(const Bool dopsf,
00094                                   const VisBuffer& vb, 
00095                                   CountedPtr<SIImageStore> imstore);
00096 
00097 
00098   // Called at the end of gridding : subftm->finalizeToSky()
00099   void finalizeToSky(){throw(AipsError("MultiTermFTNew::finalizeToSky() called without arguments!"));};
00100 
00101   //void finalizeToSky(Block<CountedPtr<ImageInterface<Complex> > > & compImageVec, PtrBlock<SubImage<Float> *> & resImageVec, PtrBlock<SubImage<Float> *>& weightImageVec, PtrBlock<SubImage<Float> *>& fluxScaleVec, Bool dopsf, Block<Matrix<Float> >& weightsVec, const VisBuffer& vb);
00102 
00103   virtual void finalizeToSkyNew(Bool dopsf, 
00104                                            const VisBuffer& vb,
00105                                            CountedPtr<SIImageStore> imstore  );
00106 
00107   //  void normalizeToSky(ImageInterface<Complex>& compImage, ImageInterface<Float>& resImage, ImageInterface<Float>& weightImage, Bool dopsf, Matrix<Float>& weights)
00108   // {throw(AipsError("MultiTermFTNew::normalizeToSky should not get called !"));};
00109 
00110 
00111   // Do the degridding via subftm->get() and modify model-visibilities by Taylor-weights
00112   void get(VisBuffer& vb, Int row=-1);
00113 
00114   // Modify imaging weights with Taylor-weights and do gridding via subftm->put()
00115   void put(VisBuffer& vb, Int row=-1, Bool dopsf=False,
00116            FTMachine::Type type=FTMachine::OBSERVED);
00117 
00118   // Have a const version for compatibility with other FTMs.. Throw an exception if called.
00119   void put(const VisBuffer& /*vb*/, Int /*row*/=-1, Bool /*dopsf*/=False,
00120            FTMachine::Type /*type*/=FTMachine::OBSERVED)
00121   {throw(AipsError("MultiTermFTNew::put called with a const vb. This FTM needs to modify the vb."));};
00122 
00123   // Calculate residual visibilities if possible.
00124   // The purpose is to allow rGridFT to make this multi-threaded
00125   virtual void ComputeResiduals(VisBuffer&vb, Bool useCorrected); 
00126 
00127   // Make an image : subftm->makeImage()
00128   void makeImage(FTMachine::Type type,
00129                  VisSet& vs,
00130                  ImageInterface<Complex>& image,
00131                  Matrix<Float>& weight);
00132   
00133   // Get the final image: do the Fourier transform grid-correct, then 
00134   // optionally normalize by the summed weights
00135   // Note : Post-gridding residual-image divisions by PBs will go here.
00136   //           For now, it just calls subftm->getImage()
00137   //  ImageInterface<Complex>& getImage(Matrix<Float>& weights, Bool normalize=True)
00138   //{return getImage(weights,normalize,0);};
00139   //ImageInterface<Complex>& getImage(Matrix<Float>& weights, Bool normalize=True, 
00140   //                                                         const Int taylorindex=0);
00141   ImageInterface<Complex>& getImage(Matrix<Float>& /*weights*/, Bool /*normalize*/=True)
00142   {throw(AipsError("MultiTermFTNew::getImage() should not be called"));}
00143  
00144   virtual Bool useWeightImage()
00145   {AlwaysAssert(subftms_p.nelements()>0,AipsError); return subftms_p[0]->useWeightImage(); };
00146 
00147   void getWeightImage(ImageInterface<Float>& weightImage, Matrix<Float>& weights)
00148   {AlwaysAssert(subftms_p.nelements()>0,AipsError); 
00149     subftms_p[0]->getWeightImage(weightImage, weights);}
00150   //  {throw(AipsError("MultiTermFTNew::getWeightImage() should not be called"));}
00151 
00152   // Save and restore the MultiTermFTNew to and from a record
00153   virtual Bool toRecord(String& error, RecordInterface& outRec, Bool withImage=False,
00154                         const String diskimage="");
00155   virtual Bool fromRecord(String& error, const RecordInterface& inRec);
00156 
00157   // Various small inline functions
00158   virtual Bool isFourier() {return True;}
00159   virtual void setNoPadding(Bool nopad){subftms_p[0]->setNoPadding(nopad);};
00160   virtual String name()const {return machineName_p;};
00161   virtual void setMiscInfo(const Int qualifier){(void)qualifier;};
00162 
00163   void printFTTypes()
00164   {
00165     cout << "** Number of FTs : " << subftms_p.nelements() << " -- " ;
00166     for(uInt tix=0; tix<(subftms_p).nelements(); tix++)
00167       cout << tix << " : " << (subftms_p[tix])->name() << "   " ;
00168     cout << endl;
00169   };
00170 
00171   FTMachine* cloneFTM();
00172   virtual void setDryRun(Bool val) 
00173   {
00174     isDryRun=val;
00175     //cerr << "MTFTMN: " << isDryRun << endl;
00176     for (uInt i=0;i<subftms_p.nelements();i++)
00177       subftms_p[i]->setDryRun(val);
00178   };
00179   virtual Bool isUsingCFCache() {Bool v=False; if (subftms_p.nelements() > 0) v=subftms_p[0]->isUsingCFCache(); return v;};
00180 
00181 protected:
00182   // have to call the initmaps of subftm
00183   virtual void initMaps(const VisBuffer& vb);
00184   // Instantiate a new sub FTM
00185   CountedPtr<FTMachine> getNewFTM(const CountedPtr<FTMachine>& ftm);
00186 
00187   // Multiply Imaging weights by Taylor-function weights - during "put"
00188   Bool modifyVisWeights(VisBuffer& vb, uInt thisterm);
00189   // Multiply model visibilities by Taylor-function weights - during "get"
00190   Bool modifyModelVis(VisBuffer &vb, uInt thisterm);
00191   // Restore vb.imagingweights to the original
00192   void restoreImagingWeights(VisBuffer &vb);
00193 
00194   // Helper function to write ImageInterfaces to disk
00195   Bool storeAsImg(String fileName, ImageInterface<Float> & theImg);
00196 
00197 
00198   Cube<Complex> modviscube_p;
00199 
00201   uInt nterms_p, psfnterms_p;
00202   Double reffreq_p;
00203   Matrix<Float> imweights_p;
00204   String machineName_p;
00205 
00206   //  Bool donePSF_p;
00207 
00208   Block< CountedPtr<FTMachine> > subftms_p;
00209 
00210 };
00211 
00212 } //# NAMESPACE CASA - END
00213 
00214 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1