00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef SYNTHESIS_NEWMULTITERMFT_H
00030 #define SYNTHESIS_NEWMULTITERMFT_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
00046 #include <casa/OS/Timer.h>
00047
00048 namespace casa {
00049
00050 class UVWMachine;
00051
00052 class NewMultiTermFT : public FTMachine {
00053 public:
00054
00055
00056 NewMultiTermFT(FTMachine *subftm, Int nterms=1, Double reffreq=0.0);
00057
00058
00059 NewMultiTermFT(const RecordInterface& stateRec);
00060
00061
00062
00063 NewMultiTermFT(const NewMultiTermFT &other);
00064
00065
00066 NewMultiTermFT &operator=(const NewMultiTermFT &other);
00067
00068
00069 ~NewMultiTermFT();
00070
00071
00072
00073 void initializeToVis(ImageInterface<Complex>& ,
00074 const VisBuffer& )
00075 {throw(AipsError("NewMultiTermFT::initializeToVis called without vectors !"));};
00076
00077
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
00081 void finalizeToVis();
00082
00083
00084 void initializeToSky(ImageInterface<Complex>& ,
00085 Matrix<Float>& , const VisBuffer& )
00086 {throw(AipsError("NewMultiTermFT::initializeToSky() called without vectors!"));};
00087
00088 void initializeToSky(Block<CountedPtr<ImageInterface<Complex> > > & compImageVec, Block<Matrix<Float> >& weightsVec, const VisBuffer& vb, const Bool dopsf);
00089
00090
00091
00092 void finalizeToSky(){throw(AipsError("NewMultiTermFT::finalizeToSky() called without arguments!"));};
00093
00094 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);
00095
00096
00097
00098
00099
00100
00101 void get(VisBuffer& vb, Int row=-1);
00102
00103
00104 void put(VisBuffer& vb, Int row=-1, Bool dopsf=False,
00105 FTMachine::Type type=FTMachine::OBSERVED);
00106
00107
00108 void put(const VisBuffer& , Int =-1, Bool =False,
00109 FTMachine::Type =FTMachine::OBSERVED)
00110 {throw(AipsError("NewMultiTermFT::put called with a const vb. This FTM needs to modify the vb."));};
00111
00112
00113
00114 virtual void ComputeResiduals(VisBuffer&vb, Bool useCorrected);
00115
00116
00117 void makeImage(FTMachine::Type type,
00118 VisSet& vs,
00119 ImageInterface<Complex>& image,
00120 Matrix<Float>& weight);
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 ImageInterface<Complex>& getImage(Matrix<Float>& , Bool =True)
00131 {throw(AipsError("NewMultiTermFT::getImage() should not be called"));}
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 void getWeightImage(ImageInterface<Float>& weightImage, Matrix<Float>& weights)
00148 {subftms_p[0]->getWeightImage(weightImage, weights);}
00149
00150
00151
00152 virtual Bool toRecord(String& error, RecordInterface& outRec, Bool withImage=False,
00153 const String diskimage="");
00154 virtual Bool fromRecord(String& error, const RecordInterface& inRec);
00155
00156
00157 virtual Bool isFourier() {return True;}
00158 virtual void setNoPadding(Bool nopad){subftms_p[0]->setNoPadding(nopad);};
00159 virtual String name()const {return machineName_p;};
00160 virtual void setMiscInfo(const Int qualifier){(void)qualifier;};
00161
00162 void printFTTypes()
00163 {
00164 cout << "** Number of FTs : " << subftms_p.nelements() << " -- " ;
00165 for(uInt tix=0; tix<(subftms_p).nelements(); tix++)
00166 cout << tix << " : " << (subftms_p[tix])->name() << " " ;
00167 cout << endl;
00168 };
00169
00170 virtual void setDOPBCorrection(Bool doit=True) {doWideBandPBCorrection_p=doit;};
00171 virtual Bool getDOPBCorrection() {return doWideBandPBCorrection_p;};
00172 virtual void setConjBeams(Bool useit=True) {useConjBeams_p=useit;};
00173 virtual Bool getConjBeams() {return useConjBeams_p;};
00174
00175
00176 protected:
00177
00178
00179 FTMachine* getNewFTM(const FTMachine *ftm);
00180
00181
00182 Bool modifyVisWeights(VisBuffer& vb, uInt thisterm);
00183
00184 Bool modifyModelVis(VisBuffer &vb, uInt thisterm);
00185
00186 void restoreImagingWeights(VisBuffer &vb);
00187
00188
00189 void normAvgPBs(PtrBlock<SubImage<Float> *> & weightImageVec);
00190 void calculateTaylorPBs(PtrBlock<SubImage<Float> *> & weightImageVec);
00191
00192
00193
00194 void applyWideBandPB(String action, PtrBlock<SubImage<Float> *> & imageVec);
00195
00196 void multiplyHMatrix( Matrix<Double> &hmat, PtrBlock<SubImage<Float>* > &invec,
00197 PtrBlock<SubImage<Float>* > &outvec, String saveImagePrefix );
00198
00199
00200 Bool storeAsImg(String fileName, ImageInterface<Float> & theImg);
00201
00202
00203 Cube<Complex> modviscube_p;
00204
00206 uInt nterms_p;
00207 Bool donePSF_p, doingPSF_p;
00208 Double reffreq_p;
00209 Matrix<Float> imweights_p;
00210 String machineName_p;
00211 Float pblimit_p;
00212 Bool doWideBandPBCorrection_p;
00213 String cacheDir_p;
00214 Bool donePBTaylor_p;
00215 Bool useConjBeams_p;
00216
00217 Block< CountedPtr<FTMachine> > subftms_p;
00218 Block<Matrix<Float> > sumweights_p;
00219
00220 Double sumwt_p;
00221 Matrix<Double> hess_p, invhess_p;
00222
00223 Block<CountedPtr<ImageInterface<Float> > > sensitivitymaps_p;
00224 PtrBlock<SubImage<Float>* > pbcoeffs_p;
00225
00226 Bool dbg_p,dotime_p;
00227 Timer tmr_p;
00228 Double time_get, time_put, time_res;
00229 };
00230
00231 }
00232
00233 #endif