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