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 #ifndef SYNTHESIS_CFCACHE_H
00029 #define SYNTHESIS_CFCACHE_H
00030
00031 #include <casa/Arrays/Matrix.h>
00032 #include <msvis/MSVis/VisBuffer.h>
00033 #include <images/Images/ImageInterface.h>
00034 #include <images/Images/TempImage.h>
00035 #include <images/Images/PagedImage.h>
00036 #include <casa/Arrays/Array.h>
00037 #include <casa/Arrays/Vector.h>
00038 #include <casa/Logging/LogIO.h>
00039 #include <casa/OS/Directory.h>
00040 #include <casa/Logging/LogSink.h>
00041 #include <casa/Logging/LogMessage.h>
00042 #include <lattices/Lattices/LatticeCache.h>
00043 #include <lattices/Lattices/ArrayLattice.h>
00044 #include <coordinates/Coordinates/DirectionCoordinate.h>
00045 #include <synthesis/TransformMachines/VPSkyJones.h>
00046 #include <synthesis/TransformMachines/CFStore.h>
00047 #include <synthesis/TransformMachines/CFStore2.h>
00048 #include <synthesis/TransformMachines/CFDefs.h>
00049 #include <synthesis/TransformMachines/Utils.h>
00050
00051
00052 namespace casa {
00053 using namespace CFDefs;
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 class CFCacheTable
00118 {
00119 public:
00120 CFCacheTable(): freqList(), wList(), muellerList(), cfNameList() {};
00121 ~CFCacheTable() {};
00122
00123 CFCacheTable& operator=(const CFCacheTable& other)
00124 {
00125
00126 {
00127 freqList = other.freqList;
00128 wList = other.wList;
00129 muellerList = other.muellerList;
00130 cfNameList = other.cfNameList;
00131 }
00132 return *this;
00133 }
00134
00135 void init()
00136 {freqList.resize(0); wList.resize(0); muellerList.resize(0); cfNameList.resize(0);}
00137
00138 vector<Double> freqList, wList;
00139 vector<Int> muellerList;
00140 vector<String> cfNameList;
00141 };
00142
00143
00144
00145 class CFCache
00146 {
00147 public:
00148 typedef Vector< CFStore > CFStoreCacheType;
00149 typedef Vector< CFStore2 > CFStoreCacheType2;
00150 typedef vector<CFCacheTable> CFCacheTableType;
00151 CFCache(const char *cfDir="CF"):
00152 memCache2_p(), memCacheWt2_p(),memCache_p(), memCacheWt_p(),
00153 cfCacheTable_p(), XSup(), YSup(), paList(),
00154 paList_p(), key2IndexMap(),
00155 Dir(""), WtImagePrefix(""), cfPrefix(cfDir), aux("aux.dat"), paCD_p(), avgPBReady_p(False),
00156 avgPBReadyQualifier_p(""), OTODone_p(False)
00157 {};
00158 CFCache& operator=(const CFCache& other);
00159 ~CFCache();
00160
00161
00162
00163 void setCacheDir(const char *dir) {Dir = String(dir);}
00164 String getCacheDir() {return Dir;};
00165
00166 void setWtImagePrefix(const char *prefix) {WtImagePrefix = prefix;}
00167 String getWtImagePrefix() {return WtImagePrefix;};
00168
00169
00170
00171 void initCache();
00172 void initCache2(Bool verbose=False, Float selectedPA=400.0, Float dPA=-1.0);
00173 void initCacheFromList2(const String& path,
00174 const Vector<String>& cfFileNames,
00175 const Vector<String>& cfWtFileNames,
00176 Float selectedPA, Float dPA,
00177 const Int verbose=1);
00178 void initPolMaps(PolMapType& polMap, PolMapType& conjPolMap);
00179 inline Bool OTODone() {return OTODone_p;}
00180
00181
00182
00183 Long size();
00184
00185
00186
00187
00188
00189 void setPAChangeDetector(const ParAngleChangeDetector& paCD) {paCD_p = paCD;};
00190
00191
00192
00193
00194
00195 void cacheConvFunction(CFStore& cfs,
00196 String nameQualifier="",Bool savePA=True)
00197 {cacheConvFunction(cfs.pa, cfs,nameQualifier,savePA);}
00198
00199
00200
00201 void cacheConvFunction(const Quantity pa, CFStore& cfs,
00202 String nameQualifier="",Bool savePA=True)
00203 {cacheConvFunction(pa.getValue("rad"), cfs, nameQualifier,savePA);}
00204
00205
00206 void cacheConvFunction(const Float pa, CFStore& cfs,
00207 String nameQualifier="",Bool savePA=True);
00208
00209
00210
00211 Int cacheConvFunction(Int which, const Float& pa, CFType& cf,
00212 CoordinateSystem& coords, CoordinateSystem& ftcoords,
00213 Int& convSize,
00214 Vector<Int>& xConvSupport, Vector<Int>& yConvSupport,
00215 Float convSampling, String nameQualifier="",Bool savePA=True);
00216
00217
00218
00219
00220 Bool searchConvFunction(Int& which, const Quantity pa, const Quantity dPA )
00221 {return searchConvFunction(which, pa.getValue("rad"), dPA.getValue("rad"));};
00222
00223 Bool searchConvFunction(Int& which, const Float pa, const Float dPA );
00224
00225
00226
00227 Int loadFromDisk(Int where, Float pa, Float dPA,
00228 Int Nx, CFStoreCacheType & convFuncCache,
00229 CFStore& cfs, String nameQualifier="");
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 Int locateConvFunction(CFStore& cfs, CFStore& cftws, const Int Nw,
00242 const Quantity pa, const Quantity dPA,
00243 const Int mosXPos=0, const Int mosYPos=0)
00244 {return locateConvFunction(cfs, cftws, Nw,pa.getValue("rad"), dPA.getValue("rad"),mosXPos,mosYPos);};
00245
00246 Int locateConvFunction(CFStore& cfs, const Int Nw,
00247 const Quantity pa, const Quantity dPA,
00248 const String& nameQualifier="",
00249 const Int mosXPos=0, const Int mosYPos=0)
00250 {return locateConvFunction(cfs, Nw,pa.getValue("rad"), dPA.getValue("rad"),nameQualifier, mosXPos,mosYPos);};
00251
00252 Int locateConvFunction(CFStore& cfs, CFStore& cfwts,
00253 const Int Nw, const Float pa, const Float dPA,
00254 const Int mosXPos=0, const Int mosYPos=0);
00255
00256 Int locateConvFunction(CFStore& cfs, const Int Nw, const Float pa, const Float dPA,
00257 const String& nameQualifier="",
00258 const Int mosXPos=0, const Int mosYPos=0);
00259
00260 TableRecord getCFParams(const String& fileName,
00261 Array<Complex>& pixelBuffer,
00262 CoordinateSystem& coordSys,
00263 Double& sampling,
00264 Double& paVal,
00265 Int& xSupport, Int& ySupport,
00266 Double& fVal, Double& wVal, Int& mVal,
00267 Double& conjFreq, Int& conjPoln,
00268 Bool loadPixels=True);
00269
00270
00271
00272
00273
00274
00275 void flush();
00276 void flush(ImageInterface<Float>& avgPB, String qualifier=String(""));
00277 Int loadAvgPB(ImageInterface<Float>& avgPB, String qualifier=String(""));
00278 Int loadAvgPB(CountedPtr<ImageInterface<Float> > & avgPB, String qualifier=String(""))
00279 {if (avgPB.null()) avgPB = new TempImage<Float>(); return loadAvgPB(*avgPB,qualifier);};
00280
00281
00282 Int loadWtImage(ImageInterface<Float>& avgPB, String qualifier);
00283
00284 Bool avgPBReady(const String& qualifier=String(""))
00285 {return (avgPBReady_p && (avgPBReadyQualifier_p == qualifier));};
00286
00287 void summarize(CFStoreCacheType2& memCache, const String& message, const Bool cfsInfo=True);
00288
00289 CFStoreCacheType2 memCache2_p, memCacheWt2_p;
00290
00291 private:
00292 CFStoreCacheType memCache_p, memCacheWt_p;
00293 CFCacheTableType cfCacheTable_p;
00294
00295 Matrix<Int> XSup, YSup;
00296 Vector<Float> paList, Sampling;
00297 vector<Float> paList_p;
00298 Matrix<Float> key2IndexMap;
00299 String Dir, WtImagePrefix, cfPrefix, aux;
00300 ParAngleChangeDetector paCD_p;
00301
00302
00303
00304
00305 void makeFTCoordSys(const CoordinateSystem& coords,
00306 const Int& convSize,
00307 const Vector<Double>& ftRef,
00308 CoordinateSystem& ftCoords);
00309
00310
00311
00312
00313 Int addToMemCache(CFStoreCacheType& cfCache,
00314 Float pa, CFType* cf, CoordinateSystem& coords,
00315 Vector<Int>& xConvSupport,
00316 Vector<Int>& yConvSupport,
00317 Float convSampling);
00318 CFStoreCacheType& getMEMCacheObj(const String& nameQualifier);
00319
00320 void fillCFSFromDisk(const Directory dirObj, const String& pattern,
00321 CFStoreCacheType2& memStore, Bool showInfo=False,
00322 Float selectPAVal=400.0, Float dPA=-1.0,
00323 const Int verbose=1);
00324 void fillCFListFromDisk(const Vector<String>& fileNames, const String& CFCDir,
00325 CFStoreCacheType2& memStore,
00326 Bool showInfo, Float selectPAVal, Float dPA,
00327 const Int verbose=1);
00328
00329 Bool avgPBReady_p;
00330 String avgPBReadyQualifier_p;
00331 Bool OTODone_p;
00332 };
00333 }
00334
00335 #endif