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