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_CUAWVISRESAMPLER_H
00030 #define SYNTHESIS_CUAWVISRESAMPLER_H
00031
00032 #include <synthesis/TransformMachines/CFStore.h>
00033 #include <synthesis/TransformMachines/VBStore.h>
00034 #include <synthesis/TransformMachines/VisibilityResampler.h>
00035 #include <msvis/MSVis/VisBuffer.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 class ProtoVR: public VisibilityResampler
00045 {
00046 public:
00047 ProtoVR(): VisibilityResampler(),
00048 cached_phaseGrad_p(),
00049 cached_PointingOffset_p()
00050 {cached_PointingOffset_p.resize(2);cached_PointingOffset_p=-1000.0;runTimeG_p=runTimeDG_p=0.0;};
00051
00052 virtual ~ProtoVR() {};
00053
00054 virtual VisibilityResamplerBase* clone()
00055 {return new ProtoVR(*this);}
00056
00057
00058
00059
00060 virtual void copyMaps(const ProtoVR& other)
00061 {setCFMaps(other.cfMap_p, other.conjCFMap_p);}
00062 virtual void copy(const VisibilityResamplerBase& other)
00063 {
00064 VisibilityResampler::copy(other);
00065
00066
00067
00068
00069 }
00070
00071 virtual void copy(const ProtoVR& other)
00072 {
00073 VisibilityResampler::copy(other);
00074 SynthesisUtils::SETVEC(cached_phaseGrad_p, other.cached_phaseGrad_p);
00075 SynthesisUtils::SETVEC(cached_PointingOffset_p, other.cached_PointingOffset_p);
00076 }
00077
00078 ProtoVR& operator=(const ProtoVR& other)
00079 {
00080 copy(other);
00081 SynthesisUtils::SETVEC(cached_phaseGrad_p, other.cached_phaseGrad_p);
00082 SynthesisUtils::SETVEC(cached_PointingOffset_p, other.cached_PointingOffset_p);
00083 return *this;
00084 }
00085
00086 virtual void setCFMaps(const Vector<Int>& cfMap, const Vector<Int>& conjCFMap)
00087 {SETVEC(cfMap_p,cfMap);SETVEC(conjCFMap_p,conjCFMap);}
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 virtual void DataToGrid(Array<DComplex>& griddedData, VBStore& vbs, Matrix<Double>& sumwt,
00116 const Bool& dopsf
00117
00118
00119
00120
00121 )
00122 {
00123 Vector<Int> gridShape=griddedData.shape().asVector();
00124 Bool Dummy;
00125 DComplex *store=griddedData.getStorage(Dummy);
00126 Int* shp=gridShape.getStorage(Dummy);
00127 DataToGridImpl_p(store, shp, vbs, sumwt,dopsf
00128
00129
00130 );}
00131
00132 virtual void DataToGrid(Array<Complex>& griddedData, VBStore& vbs, Matrix<Double>& sumwt,
00133 const Bool& dopsf
00134
00135
00136
00137
00138 )
00139 {
00140 Vector<Int> gridShape=griddedData.shape().asVector();
00141 Bool Dummy;
00142 Complex *store=griddedData.getStorage(Dummy);
00143 Int* shp=gridShape.getStorage(Dummy);
00144 DataToGridImpl_p(store, shp,vbs, sumwt,dopsf
00145
00146
00147 );}
00148
00149
00150
00151
00152
00153
00154 virtual void GridToData(VBStore& vbs,const Array<Complex>& griddedData);
00155
00156 protected:
00157 virtual Complex getConvFuncVal(const Cube<Double>& convFunc, const Matrix<Double>& uvw,
00158 const Int& irow, const Vector<Int>& pixel)
00159 {
00160 (void)uvw; (void)irow;return convFunc(pixel[0],pixel[1],pixel[2]);
00161 }
00162 Complex getCFArea(Complex* __restrict__& convFuncV, Double& wVal,
00163 Vector<Int>& scaledSupport, Vector<Float>& scaledSampling,
00164 Vector<Double>& off,
00165 Vector<Int>& convOrigin, Vector<Int>& cfShape,
00166 Double& sinDPA, Double& cosDPA);
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 template <class T>
00178 void XInnerLoop(const Int *scaleSupport, const Float* scaledSampling,
00179 const Double* off,
00180 const Int* loc, Complex& cfArea,
00181 const Int * __restrict__ iGrdPosPtr,
00182 Complex *__restrict__& convFuncV,
00183 const Int* convOrigin,
00184 Complex& nvalue,
00185 Double& wVal,
00186 Bool& ,
00187 Bool& ,
00188 T* __restrict__ gridStore,
00189 Int* iloc,
00190 Complex& norm,
00191 Int* igrdpos);
00192
00193 template <class T>
00194 Complex accumulateOnGrid(T* gridStore,
00195 const Int* gridInc_p,
00196 const Complex *cached_phaseGrad_p,
00197 const Int cachedPhaseGradNX, const Int cachedPhaseGradNY,
00198 const Complex* convFuncV,
00199 const Int *cfInc_p,
00200 Complex nvalue,Double wVal,
00201 Int* scaledSupport_ptr, Float* scaledSampling_ptr,
00202 Double* off_ptr, Int* convOrigin_ptr,
00203 Int* cfShape, Int* loc_ptr, Int* iGrdpos_ptr,
00204 Bool finitePointingOffset,
00205 Bool doPSFOnly);
00206 template <class T>
00207 void accumulateFromGrid(T& nvalue, const T* __restrict__& grid,
00208 Vector<Int>& iGrdPos,
00209 Complex* __restrict__& convFuncV,
00210 Double& wVal, Vector<Int>& scaledSupport,
00211 Vector<Float>& scaledSampling, Vector<Double>& off,
00212 Vector<Int>& convOrigin, Vector<Int>& cfShape,
00213 Vector<Int>& loc,
00214 Complex& phasor,
00215 Double& sinDPA, Double& cosDPA,
00216 Bool& finitePointingOffset,
00217 Matrix<Complex>& cached_phaseGrad_p);
00218
00219 virtual void DataToGrid(Array<DComplex>& griddedData, VBStore& vbs, Matrix<Double>& sumwt,
00220 const Bool& dopsf,Bool useConjFreqCF=False);
00221 virtual void DataToGrid(Array<Complex>& griddedData, VBStore& vbs, Matrix<Double>& sumwt,
00222 const Bool& dopsf,Bool useConjFreqCF=False);
00223
00224
00225
00226
00227
00228 private:
00229
00230
00231
00232
00233
00234
00235 Int gridInc_p[4], cfInc_p[4];
00236 Matrix<Complex> cached_phaseGrad_p;
00237 Vector<Double> cached_PointingOffset_p;
00238
00239
00240
00241
00242 template <class T>
00243 void DataToGridImpl_p(T* gridStore, Int* gridShape ,
00244 VBStore& vbs,
00245 Matrix<Double>& sumwt,
00246 const Bool& dopsf
00247
00248
00249
00250
00251
00252 );
00253
00254
00255
00256
00257 void sgrid(Double pos[2], Int loc[3], Double off[3],
00258 Complex& phasor, const Int& irow, const Matrix<Double>& uvw,
00259 const Double& dphase, const Double& freq,
00260 const Double* scale, const Double* offset,
00261 const Float sampling[2]);
00262
00263 inline Bool onGrid (const Int& nx, const Int& ny, const Int& nw,
00264 const Int loc[3],
00265 const Int support[2])
00266 {
00267 return (((loc[0]-support[0]) >= 0 ) && ((loc[0]+support[0]) < nx) &&
00268 ((loc[1]-support[1]) >= 0 ) && ((loc[1]+support[1]) < ny) &&
00269 (loc[2] >= 0) && (loc[2] <= nw));
00270 };
00271
00272
00273
00274 template <class T>
00275 inline void SETVEC(Vector<T>& lhs, const Vector<T>& rhs)
00276 {lhs.resize(rhs.shape()); lhs = rhs;};
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299 inline Complex getFrom4DArray(const Complex * store,
00300 const Int* iPos, const Int inc[4])
00301 {
00302 return *(store+(iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]));
00303
00304 };
00305
00306
00307 inline Complex getFrom4DArray(const Complex *__restrict__& store,
00308 const Vector<Int>& iPos, const Vector<Int>& inc)
00309 {
00310 return *(store+(iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]));
00311
00312 };
00313 inline DComplex getFrom4DArray(const DComplex *__restrict__& store,
00314 const Vector<Int>& iPos, const Vector<Int>& inc)
00315 {
00316 return *(store+(iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]));
00317
00318 };
00319
00320 template <class T>
00321 void addTo4DArray(T *store,
00322 const Int *iPos, const Int* inc,
00323 Complex& nvalue, Complex& wt)
00324 {
00325
00326
00327 store[iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]] += (nvalue*wt);
00328 }
00329
00330
00331
00332
00333
00334
00335 Bool reindex(const Vector<Int>& in, Vector<Int>& out,
00336 const Double& sinDPA, const Double& cosDPA,
00337 const Vector<Int>& Origin, const Vector<Int>& size);
00338
00339 Complex* getConvFunc_p(Int cfShape[4], VBStore& vbs,
00340 Double& wVal, Int& fndx, Int& wndx,
00341 Int **mNdx, Int **conjMNdx,
00342 Int& ipol, uInt& mRow);
00343
00344
00345
00346
00347
00348
00349
00350
00351 void cachePhaseGrad_g(Complex *cached_phaseGrad_p,
00352 Int phaseGradNX, Int phaseGradNY,
00353 Double* cached_PointingOffset_p,
00354 Double* pointingOffset,
00355 Int cfShape[4],
00356 Int convOrigin[4]);
00357
00358
00359
00360
00361
00362 };
00363 };
00364
00365 #endif //