CFStore2.h
Go to the documentation of this file.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_CFSTORE2_H
00029 #define SYNTHESIS_CFSTORE2_H
00030 #include <synthesis/TransformMachines/CFDefs.h>
00031 #include <synthesis/TransformMachines/CFBuffer.h>
00032 #include <synthesis/TransformMachines/CFCell.h>
00033 #include <synthesis/TransformMachines/VBStore.h>
00034 #include <synthesis/TransformMachines/SynthesisError.h>
00035 #include <coordinates/Coordinates/CoordinateSystem.h>
00036 #include <casa/Logging/LogIO.h>
00037 #include <casa/Logging/LogSink.h>
00038 #include <casa/Logging/LogOrigin.h>
00039 #include <casa/Containers/OrderedMap.h>
00040 #include <casa/Utilities/CountedPtr.h>
00041 #include <images/Images/ImageInterface.h>
00042 #include <msvis/MSVis/VisBuffer.h>
00043 namespace casa {
00044 using namespace CFDefs;
00045 typedef Cube<CountedPtr<CFCell > > VBRow2CFMapType;
00046 typedef Vector<CountedPtr<CFBuffer > > VBRow2CFBMapType;
00047 class CFStore2
00048 {
00049 public:
00050 CFStore2():storage_p(), pa_p(), mosPointingPos_p(0) {};
00051
00052
00053
00054
00055
00056 virtual ~CFStore2() {};
00057
00058 CFStore2& operator=(const CFStore2& other);
00059
00060 void show(const char *Mesg=NULL,ostream &os=cerr, const Bool verbose=False);
00061
00062
00063 void makePersistent(const char *dir,const char *name="", const char *qualifier="");
00064
00065
00066
00067 void makePersistent(const char *dir,
00068 const char *cfName,
00069 const char *qualifier,
00070 const Quantity &pa, const Quantity& dPA,
00071 const Int& ant1, const Int& ant2);
00072
00073 void primeTheCFB();
00074
00075 void initMaps(const VisBuffer& vb, const Matrix<Double>& freqSelection,
00076 const Double& imRefFreq);
00077
00078 void initPolMaps(PolMapType& polMap, PolMapType& conjPolMap);
00079
00080 Bool null() {return (storage_p.size() == 0);};
00081
00082 Double memUsage();
00083
00084 void set(const CFStore2& other)
00085 {
00086 pa_p.assign(other.pa_p);
00087 ant1_p.assign(other.ant1_p);
00088 ant2_p.assign(other.ant2_p);
00089 }
00090
00091 void setCFBuffer(CFBuffer *dataPtr, Quantity pa,
00092 const Int& ant1, const Int& ant2);
00093
00094 CountedPtr<CFBuffer>& getCFBuffer(const Quantity& pa,
00095 const Quantity& paTol,
00096 const Int& ant1, const Int& ant2);
00097
00098
00099 CountedPtr<CFBuffer>& getCFBuffer(const Int& paNdx, const Int& antNdx);
00100 CFBuffer& operator()(const Int& paNdx, const Int& antNdx) {return *storage_p(paNdx, antNdx);}
00101 void getParams(Quantity& pa,
00102 Int& ant1, Int& ant2,
00103 const Int& paNdx, const Int& antNdx);
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 Vector<Int> resize(const Quantity& pa, const Quantity& paTol,
00119 const Int& ant1,const Int& ant2, Bool retainValues=True);
00120
00121
00122
00123 Matrix<CountedPtr<CFBuffer> >& getStorage() {return storage_p;}
00124 Vector<Int>& getAnt1List() {return ant1_p;};
00125 Vector<Int>& getAnt2List() {return ant2_p;};
00126 Vector<Quantity> getPAList() {return pa_p;};
00127 IPosition getShape() {return storage_p.shape();}
00128
00129
00130 protected:
00131
00132 Matrix<CountedPtr<CFBuffer > > storage_p;
00133 Vector<Int> ant1_p, ant2_p;
00134 Vector<Quantity> pa_p;
00135 Int mosPointingPos_p;
00136
00137 virtual void getIndex(const Quantity& pa,
00138 const Quantity& paTol,
00139 const Int& ant1, const Int& ant2,
00140 Int& paNdx, Int& antNdx)
00141 {
00142 paNdx = paHashFunction(pa,paTol);
00143 antNdx = antHashFunction(ant1,ant2);
00144 }
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 virtual Int antHashFunction(const Int& ant1, const Int& ant2)
00155 {
00156 Int ndx=-1;
00157 for (uInt i=0;i<ant1_p.nelements(); i++)
00158 if ((ant1_p[i]==ant1) && (ant2_p[i]==ant2))
00159 {ndx=i;break;}
00160 return ndx;
00161 };
00162
00163 virtual Int paHashFunction(const Quantity& pa,const Quantity& paTol)
00164 {
00165
00166
00167
00168 return nearestPA(pa, paTol);
00169 }
00170
00171 virtual Int nearestPA(const Quantity& pa, const Quantity& paTol);
00172 };
00173 }
00174
00175 #endif