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_TRANSFORM2_AWVISRESAMPLER_H
00030 #define SYNTHESIS_TRANSFORM2_AWVISRESAMPLER_H
00031
00032 #include <synthesis/TransformMachines2/CFStore.h>
00033 #include <synthesis/TransformMachines2/VBStore.h>
00034 #include <synthesis/TransformMachines2/VisibilityResampler.h>
00035 #include <msvis/MSVis/VisBuffer2.h>
00036 #include <casa/Arrays/Array.h>
00037 #include <casa/Arrays/Vector.h>
00038
00039 #include <casa/Logging/LogIO.h>
00040 #include <casa/Logging/LogSink.h>
00041 #include <casa/Logging/LogMessage.h>
00042
00043 namespace casa {
00044 namespace refim{
00045 class AWVisResampler: public VisibilityResampler
00046 {
00047 public:
00048 AWVisResampler(): VisibilityResampler(),
00049 cached_phaseGrad_p(),
00050 cached_PointingOffset_p()
00051 {cached_PointingOffset_p.resize(2);cached_PointingOffset_p=-1000.0;runTimeG_p=runTimeDG_p=0.0;};
00052
00053 virtual ~AWVisResampler() {};
00054
00055 virtual VisibilityResamplerBase* clone()
00056 {return new AWVisResampler(*this);}
00057
00058
00059
00060
00061 virtual void copyMaps(const AWVisResampler& other)
00062 {setCFMaps(other.cfMap_p, other.conjCFMap_p);}
00063 virtual void copy(const VisibilityResamplerBase& other)
00064 {
00065 VisibilityResampler::copy(other);
00066
00067
00068
00069
00070 }
00071
00072 virtual void copy(const AWVisResampler& other)
00073 {
00074 VisibilityResampler::copy(other);
00075 SynthesisUtils::SETVEC(cached_phaseGrad_p, other.cached_phaseGrad_p);
00076 SynthesisUtils::SETVEC(cached_PointingOffset_p, other.cached_PointingOffset_p);
00077 }
00078
00079 AWVisResampler& operator=(const AWVisResampler& other)
00080 {
00081 copy(other);
00082 SynthesisUtils::SETVEC(cached_phaseGrad_p, other.cached_phaseGrad_p);
00083 SynthesisUtils::SETVEC(cached_PointingOffset_p, other.cached_PointingOffset_p);
00084 return *this;
00085 }
00086
00087 virtual void setCFMaps(const Vector<Int>& cfMap, const Vector<Int>& conjCFMap)
00088 {SETVEC(cfMap_p,cfMap);SETVEC(conjCFMap_p,conjCFMap);}
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 virtual void DataToGrid(Array<DComplex>& griddedData, VBStore& vbs, Matrix<Double>& sumwt,
00117 const Bool& dopsf,Bool useConjFreqCF=False)
00118 {DataToGridImpl_p(griddedData, vbs, sumwt,dopsf,useConjFreqCF);}
00119
00120 virtual void DataToGrid(Array<Complex>& griddedData, VBStore& vbs, Matrix<Double>& sumwt,
00121 const Bool& dopsf,Bool useConjFreqCF=False)
00122 {DataToGridImpl_p(griddedData, vbs, sumwt,dopsf,useConjFreqCF);}
00123
00124
00125
00126
00127
00128
00129 virtual void GridToData(VBStore& vbs,const Array<Complex>& griddedData);
00130
00131 protected:
00132 virtual Complex getConvFuncVal(const Cube<Double>& convFunc, const Matrix<Double>& uvw,
00133 const Int& irow, const Vector<Int>& pixel)
00134 {
00135 (void)uvw; (void)irow;return convFunc(pixel[0],pixel[1],pixel[2]);
00136 }
00137 Complex getCFArea(Complex* __restrict__& convFuncV, Double& wVal,
00138 Vector<Int>& scaledSupport, Vector<Float>& scaledSampling,
00139 Vector<Double>& off,
00140 Vector<Int>& convOrigin, Vector<Int>& cfShape,
00141 Double& sinDPA, Double& cosDPA);
00142
00143 template <class T>
00144 Complex accumulateOnGrid(Array<T>& grid, Complex* __restrict__& convFuncV,
00145 Complex& nvalue,
00146 Double& wVal, Vector<Int>& scaledSupport,
00147 Vector<Float>& scaledSampling, Vector<Double>& off,
00148 Vector<Int>& convOrigin, Vector<Int>& ,
00149 Vector<Int>& loc, Vector<Int>& igrdpos,
00150 Double& , Double& ,
00151 Bool& finitePointingOffset, Bool dopsf);
00152 template <class T>
00153 void XInnerLoop(const Int *scaleSupport, const Float* scaledSampling,
00154 const Double* off,
00155 const Int* loc, Complex& cfArea,
00156 const Int * __restrict__ iGrdPosPtr,
00157 Complex *__restrict__& convFuncV,
00158 const Int* convOrigin,
00159 Complex& nvalue,
00160 Double& wVal,
00161 Bool& ,
00162 Bool& ,
00163 T* __restrict__ gridStore,
00164 Int* iloc,
00165 Complex& norm,
00166 Int* igrdpos);
00167
00168 template <class T>
00169 void accumulateFromGrid(T& nvalue, const T* __restrict__& grid,
00170 Vector<Int>& iGrdPos,
00171 Complex* __restrict__& convFuncV,
00172 Double& wVal, Vector<Int>& scaledSupport,
00173 Vector<Float>& scaledSampling, Vector<Double>& off,
00174 Vector<Int>& convOrigin, Vector<Int>& cfShape,
00175 Vector<Int>& loc,
00176 Complex& phasor,
00177 Double& sinDPA, Double& cosDPA,
00178 Bool& finitePointingOffset,
00179 Matrix<Complex>& cached_phaseGrad_p);
00180
00181
00182
00183
00184
00185
00186 private:
00187
00188
00189
00190
00191
00192
00193 Vector<Int> gridInc_p, cfInc_p;
00194 Matrix<Complex> cached_phaseGrad_p;
00195 Vector<Double> cached_PointingOffset_p;
00196
00197
00198
00199 template <class T>
00200 void DataToGridImpl_p(Array<T>& griddedData, VBStore& vb,
00201 Matrix<Double>& sumwt,const Bool& dopsf,
00202 Bool );
00203
00204 void sgrid(Vector<Double>& pos, Vector<Int>& loc, Vector<Double>& off,
00205 Complex& phasor, const Int& irow, const Matrix<Double>& uvw,
00206 const Double& dphase, const Double& freq,
00207 const Vector<Double>& scale, const Vector<Double>& offset,
00208 const Vector<Float>& sampling);
00209
00210 inline Bool onGrid (const Int& nx, const Int& ny, const Int& nw,
00211 const Vector<Int>& loc,
00212 const Vector<Int>& support)
00213 {
00214 return (((loc(0)-support[0]) >= 0 ) && ((loc(0)+support[0]) < nx) &&
00215 ((loc(1)-support[1]) >= 0 ) && ((loc(1)+support[1]) < ny) &&
00216 (loc(2) >= 0) && (loc(2) <= nw));
00217 };
00218
00219
00220
00221 template <class T>
00222 inline void SETVEC(Vector<T>& lhs, const Vector<T>& rhs)
00223 {lhs.resize(rhs.shape()); lhs = rhs;};
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239 inline Complex getFrom4DArray(const Complex *__restrict__& store,
00240 const Int* iPos, const Int* inc)
00241 {
00242 return *(store+(iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]));
00243
00244 };
00245
00246
00247 inline Complex getFrom4DArray(const Complex *__restrict__& store,
00248 const Vector<Int>& iPos, const Vector<Int>& inc)
00249 {
00250 return *(store+(iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]));
00251
00252 };
00253 inline DComplex getFrom4DArray(const DComplex *__restrict__& store,
00254 const Vector<Int>& iPos, const Vector<Int>& inc)
00255 {
00256 return *(store+(iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]));
00257
00258 };
00259
00260 template <class T>
00261 void addTo4DArray(T *__restrict__& store,
00262 const Int *__restrict__& iPos, const Vector<Int>& inc,
00263 Complex& nvalue, Complex& wt) __restrict__
00264 {
00265
00266
00267 store[iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]] += (nvalue*wt);
00268 }
00269
00270
00271
00272
00273
00274
00275 Bool reindex(const Vector<Int>& in, Vector<Int>& out,
00276 const Double& sinDPA, const Double& cosDPA,
00277 const Vector<Int>& Origin, const Vector<Int>& size);
00278
00279 Complex* getConvFunc_p(Vector<Int>& cfShape,
00280 CFBuffer& cfb,
00281 Double& wVal, Int& fndx,
00282 Int& wndx,
00283 PolMapType& mNdx, PolMapType& conjMNdx,
00284 Int& ipol, uInt& mRow);
00285 void cachePhaseGrad_p(const Vector<Double>& pointingOffset,
00286 const Vector<Int>&cfShape,
00287 const Vector<Int>& convOrigin,
00288 const Double& cfRefFreq,
00289 const Double& imRefFreq,
00290 const Int& spwID=0, const Int& fieldId=0);
00291 };
00292 };
00293 };
00294 #endif //