casa
$Rev:20696$
|
00001 //# MultiTermFT.h: Definition for MultiTermFT 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_MULTITERMFT_H 00030 #define SYNTHESIS_MULTITERMFT_H 00031 00032 #include <synthesis/TransformMachines/FTMachine.h> 00033 #include <casa/Arrays/Matrix.h> 00034 #include <scimath/Mathematics/FFTServer.h> 00035 #include <synthesis/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 MultiTermFT : public FTMachine { 00053 public: 00054 00055 // Construct using an existing FT-Machine 00056 MultiTermFT(FTMachine *subftm, String subFTMname, Int nterms=1, Double reffreq=0.0); 00057 00058 // Construct from a Record containing the MultiTermFT state 00059 MultiTermFT(const RecordInterface& stateRec); 00060 00061 // Copy constructor. 00062 // This first calls the default "=" operator, and then instantiates objects for member pointers. 00063 MultiTermFT(const MultiTermFT &other); 00064 00065 // Assignment operator --- leave it as the default 00066 MultiTermFT &operator=(const MultiTermFT &other); 00067 00068 // Destructor 00069 ~MultiTermFT(); 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, const VisBuffer& vb); 00074 00075 // Called at the end of de-gridding : subftm->finalizeToVis() 00076 void finalizeToVis(); 00077 00078 // Called at the start of gridding : subftm->initializeToSky() 00079 void initializeToSky(ImageInterface<Complex>& image, Matrix<Float>& weight, const VisBuffer& vb); 00080 00081 // Called at the end of gridding : subftm->finalizeToSky() 00082 void finalizeToSky(); 00083 00084 // Do the degridding via subftm->get() and modify model-visibilities by Taylor-weights 00085 void get(VisBuffer& vb, Int row=-1); 00086 00087 // Modify imaging weights with Taylor-weights and do gridding via subftm->put() 00088 void put(VisBuffer& vb, Int row=-1, Bool dopsf=False, 00089 FTMachine::Type type=FTMachine::OBSERVED); 00090 00091 // Have a const version for compatibility with other FTMs.. Throw an exception if called. 00092 void put(const VisBuffer& /*vb*/, Int /*row=-1*/, Bool /*dopsf=False*/, 00093 FTMachine::Type /*type=FTMachine::OBSERVED*/) 00094 {throw(AipsError("MultiTermFT::put called with a const vb. This FTM needs to modify the vb."));}; 00095 00096 // Calculate residual visibilities if possible. 00097 // The purpose is to allow rGridFT to make this multi-threaded 00098 virtual void ComputeResiduals(VisBuffer&vb, Bool useCorrected); 00099 00100 // Make an image : subftm->makeImage() 00101 void makeImage(FTMachine::Type type, 00102 VisSet& vs, 00103 ImageInterface<Complex>& image, 00104 Matrix<Float>& weight); 00105 00106 // Get the final image: do the Fourier transform grid-correct, then 00107 // optionally normalize by the summed weights 00108 // Note : Post-gridding residual-image divisions by PBs will go here. 00109 // For now, it just calls subftm->getImage() 00110 ImageInterface<Complex>& getImage(Matrix<Float>&, Bool normalize=True); 00111 00112 // Place-holder for possible use with AWProject and AWProjectWB FTMs 00113 virtual void normalizeImage(Lattice<Complex>& /*skyImage*/, 00114 const Matrix<Double>& /*sumOfWts*/, 00115 Lattice<Float>& /*sensitivityImage*/, 00116 Bool /*fftNorm*/) 00117 {throw(AipsError("MultiTermFT::normalizeImage() is not implemented"));} 00118 00119 // Get the final weights image - this will hold PB2 00120 void getWeightImage(ImageInterface<Float>&, Matrix<Float>&); 00121 00122 // Save and restore the MultiTermFT to and from a record 00123 virtual Bool toRecord(String& error, RecordInterface& outRec, Bool withImage=False); 00124 virtual Bool fromRecord(String& error, const RecordInterface& inRec); 00125 00126 // Various small inline functions 00127 virtual Bool isFourier() {return True;} 00128 virtual void setNoPadding(Bool nopad){subftm_p->setNoPadding(nopad);}; 00129 virtual String name() const {return machineName_p;}; 00130 virtual void setMiscInfo(const Int qualifier){thisterm_p=qualifier;}; 00131 00132 protected: 00133 00134 // Multiply Imaging weights by Taylor-function weights - during "put" 00135 Bool modifyVisWeights(VisBuffer& vb); 00136 // Multiply model visibilities by Taylor-function weights - during "get" 00137 Bool modifyModelVis(VisBuffer &vb); 00138 // Restore vb.imagingweights to the original 00139 Bool restoreImagingWeights(VisBuffer &vb); 00140 // have to call the initmaps of subftm 00141 virtual void initMaps(const VisBuffer& vb); 00143 CountedPtr<FTMachine> subftm_p; 00144 String subFTMname_p; 00145 Int nterms_p; 00146 Int thisterm_p; 00147 Double reffreq_p; 00148 00149 Matrix<Float> imweights_p; 00150 Double sumwt_p; 00151 String machineName_p; 00152 00153 Bool dbg_p,dotime_p; 00154 Timer tmr_p; 00155 Double time_get, time_put, time_res; 00156 }; 00157 00158 } //# NAMESPACE CASA - END 00159 00160 #endif