casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VisibilityResamplerBase.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 //# VisibilityResamplerBase.h: Definition of the VisibilityResamplerBase class
3 //# Copyright (C) 1997,1998,1999,2000,2001,2002,2003
4 //# Associated Universities, Inc. Washington DC, USA.
5 //#
6 //# This library is free software; you can redistribute it and/or modify it
7 //# under the terms of the GNU Library General Public License as published by
8 //# the Free Software Foundation; either version 2 of the License, or (at your
9 //# option) any later version.
10 //#
11 //# This library is distributed in the hope that it will be useful, but WITHOUT
12 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 //# License for more details.
15 //#
16 //# You should have received a copy of the GNU Library General Public License
17 //# along with this library; if not, write to the Free Software Foundation,
18 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19 //#
20 //# Correspondence concerning AIPS++ should be addressed as follows:
21 //# Internet email: aips2-request@nrao.edu.
22 //# Postal address: AIPS++ Project Office
23 //# National Radio Astronomy Observatory
24 //# 520 Edgemont Road
25 //# Charlottesville, VA 22903-2475 USA
26 //#
27 //# $Id$
28 
29 #ifndef SYNTHESIS_VISIBILITYRESAMPLERBASE_H
30 #define SYNTHESIS_VISIBILITYRESAMPLERBASE_H
31 
37 #include <msvis/MSVis/VisBuffer.h>
38 #include <casa/Arrays/Array.h>
39 #include <casa/Arrays/Vector.h>
41 
42 #include <casa/Logging/LogIO.h>
43 #include <casa/Logging/LogSink.h>
45 #include <casa/OS/Timer.h>
46 
47 namespace casa { //# NAMESPACE CASA - BEGIN
49  {
50  public:
52  runTimeG_p(0.0), runTimeDG_p(0.0),runTimeG1_p(0.0), runTimeG2_p(0.0), runTimeG3_p(0.0), runTimeG4_p(0.0), runTimeG5_p(0.0), runTimeG6_p(0.0), runTimeG7_p(0.0),
53  timer_p(),
55  cfMap_p(), conjCFMap_p(), paTolerance_p(360.0)
56 
57  {};
58  // VisibilityResamplerBase(const CFStore& cfs):
59  // uvwScale_p(), offset_p(), chanMap_p(), polMap_p(), convFuncStore_p(), inc_p(),
60  // cfMap_p(), conjCFMap_p()
61  // {setConvFunc(cfs);};
62 
65  cfMap_p(), conjCFMap_p(), paTolerance_p(360.0)
66  {copy(other);}
67 
69 
71 
72  virtual VisibilityResamplerBase* clone() = 0;
73 
74  virtual void copy(const VisibilityResamplerBase& other);
75  virtual void setParams(const casacore::Vector<casacore::Double>& uvwScale,
77  const casacore::Vector<casacore::Double>& dphase) = 0;
78 
79  virtual void setMaps(const casacore::Vector<casacore::Int>& chanMap, const casacore::Vector<casacore::Int>& polMap) = 0;
80  virtual void setCFMaps(const casacore::Vector<casacore::Int>& cfMap, const casacore::Vector<casacore::Int>& conjCFMap)=0;
81  virtual void setFreqMaps(const casacore::Matrix<casacore::Double>& spwChanFreqs, const casacore::Matrix<casacore::Double>& spwnChanConjFreqs) = 0;
82 
83  virtual void setConvFunc(const CFStore& cfs) = 0;
84  virtual void setPATolerance(const double& dPA) = 0;
85  //
86  //------------------------------------------------------------------------------
87  //
88  // Re-sample the griddedData on the VisBuffer (a.k.a gridding).
89  //
90  // In this class, these just call the private templated version.
91  // The first variant grids onto a double precision grid while the
92  // second one does it on a single precision grid.
93  //
94  virtual void DataToGrid(casacore::Array<casacore::DComplex>& griddedData, VBStore& vbs,
96  casacore::Bool useConjFreqCF=false) = 0;
97 
98  virtual void DataToGrid(casacore::Array<casacore::Complex>& griddedData, VBStore& vbs,
100  casacore::Bool useConjFreqCF=false) = 0;
101  //
102  //------------------------------------------------------------------------------
103  //
104  // Re-sample VisBuffer to a regular grid (griddedData) (a.k.a. de-gridding)
105  //
106  virtual void GridToData(VBStore& vbs,const casacore::Array<casacore::Complex>& griddedData) = 0;
107  // virtual void GridToData(VBStore& vbs, casacore::Array<casacore::Complex>& griddedData);
108 
109  virtual void ComputeResiduals(VBStore& vbs) = 0;
110 
111  // Forward looking genealogical baggage -- required for the
112  // MultiThreadedVisibilityResampler
113  virtual void init(const casacore::Bool& doublePrecision) = 0;
116  virtual void initializePutBuffers(const casacore::Array<casacore::DComplex>& griddedData,
117  const casacore::Matrix<casacore::Double>& sumwt) = 0;
118  virtual void initializePutBuffers(const casacore::Array<casacore::Complex>& griddedData,
119  const casacore::Matrix<casacore::Double>& sumwt) = 0;
120  virtual void initializeDataBuffers(VBStore& vbs)=0;
121  //
122  // Aliases for more readable code at the FTMachine layer.
123  //
125  {GatherGrids(griddedData, sumwt);};
127  {GatherGrids(griddedData, sumwt);};
129  {initializePutBuffers(griddedData, sumwt);};
131  {initializePutBuffers(griddedData, sumwt);};
134 
135 
136  virtual void releaseBuffers() = 0;
141  const VisBuffer& vb, const casacore::Quantity& dPA,
142  const casacore::Vector<casacore::Int>& dataChan2ImChanMap,
143  const casacore::Vector<casacore::Int>& dataPol2ImPolMap,
144  const casacore::Vector<casacore::Double>& pointingOffset);
145 
148  //
149  //------------------------------------------------------------------------------
150  //----------------------------Private parts-------------------------------------
151  //------------------------------------------------------------------------------
152  //
153  // private:
154  protected:
159  // casacore::Int inc0_p, inc1_p, inc2_p, inc3_p;
161  casacore::Int* __restrict__ incPtr_p;
166 
167  void sgrid(casacore::Int& ndim,
168  casacore::Double* __restrict__ pos,
169  casacore::Int* __restrict__ loc,
170  casacore::Int* __restrict__ off,
171  casacore::Complex& phasor, const casacore::Int& irow,
172  const casacore::Double* __restrict__ uvw,
173  const casacore::Double& dphase, const casacore::Double& freq,
174  const casacore::Double* __restrict__ scale,
175  const casacore::Double* __restrict__ offset,
176  const casacore::Float* __restrict__ sampling);
177 
178  inline casacore::Bool onGrid (const casacore::Int& nx, const casacore::Int& ny,
179  const casacore::Vector<casacore::Int>& __restrict__ loc,
180  const casacore::Vector<casacore::Int>& __restrict__ support) __restrict__
181  {
182  return (((loc(0)-support[0]) >= 0 ) && ((loc(0)+support[0]) < nx) &&
183  ((loc(1)-support[1]) >= 0 ) && ((loc(1)+support[1]) < ny));
184  };
185  inline casacore::Bool onGrid (const casacore::Int& nx, const casacore::Int& ny,
186  const casacore::Int& loc0, const casacore::Int& loc1,
187  const casacore::Int& support) __restrict__
188  {
189  return (((loc0-support) >= 0 ) && ((loc0+support) < nx) &&
190  ((loc1-support) >= 0 ) && ((loc1+support) < ny));
191  };
192 
193  // casacore::Array assignment operator in CASACore requires lhs.nelements()
194  // == 0 or lhs.nelements()=rhs.nelements()
195  // template <class T>
196  // inline void SETVEC(casacore::Vector<T>& lhs, const casacore::Vector<T>& rhs)
197  // {lhs.resize(rhs.shape()); lhs = rhs;};
198 
199 
200  //===============================================================================
201  // CASACORE-LEVEL MATERIAL
202  //===============================================================================
203  // Internal methods to address a 4D array. These should ulimately
204  // moved to a Array4D class in CASACore
205  //
206 
207  // This is called less frequently. Currently once per VisBuffer
208  inline void cacheAxisIncrements(const casacore::Int& n0, const casacore::Int& n1, const casacore::Int& n2, const casacore::Int& n3)
209  {
210  // inc0_p=1, inc1_p=inc0_p*n0, inc2_p=inc1_p*n1, inc3_p=inc2_p*n2;(void)n3;
211  inc_p.resize(4);
212  inc_p[0]=1; inc_p[1]=inc_p[0]*n0; inc_p[2]=inc_p[1]*n1; inc_p[3]=inc_p[2]*n2;(void)n3;
213  casacore::Bool D;
215  }
217  {cacheAxisIncrements(n[0],n[1],n[2],n[3]);}
218 
220  {inc.resize(4);inc[0]=1; inc[1]=inc[0]*n[0]; inc[2]=inc[1]*n[1]; inc[3]=inc[2]*n[2];(void)n[3];}
221 
222  inline void cacheAxisIncrements(const casacore::Int n[4], casacore::Int inc[4])
223  {inc[0]=1; inc[1]=inc[0]*n[0]; inc[2]=inc[1]*n[1]; inc[3]=inc[2]*n[2];(void)n[3];}
224 
225  // Version that use internally cached inc_p
226  // template <class T>
227  inline void addTo4DArray(casacore::DComplex* __restrict__& store, casacore::Int* __restrict__& iPos,
228  casacore::Complex& nvalue, casacore::Double& wt) __restrict__
229  {addTo4DArray(store, iPos, incPtr_p, nvalue, wt);}
230 
231  inline void addTo4DArray(casacore::Complex* __restrict__& store, casacore::Int* __restrict__& iPos,
232  casacore::Complex& nvalue, casacore::Double& wt) __restrict__
233  {addTo4DArray(store, iPos, incPtr_p, nvalue, wt);}
234 
235 
236  // Version where inc_p is supplied from outside
237  inline void addTo4DArray(casacore::DComplex* __restrict__& store, casacore::Int* __restrict__& iPos,
238  casacore::Int* __restrict__ inc, casacore::Complex& nvalue, casacore::Double& wt) __restrict__
239  {store[iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]] += (nvalue*casacore::Complex(wt));}
240 
241  inline void addTo4DArray(casacore::Complex* __restrict__& store, casacore::Int* __restrict__& iPos,
242  casacore::Int* __restrict__ inc, casacore::Complex& nvalue, casacore::Double& wt) __restrict__
243  {store[iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]] += (nvalue*casacore::Complex(wt));}
244 
245 
246  inline casacore::Complex getFrom4DArray(const casacore::Complex* __restrict__& store,
247  const casacore::Int* __restrict__& iPos,
249  // __restrict__
250  {return store[iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]];};
251 
252  inline casacore::Complex getFrom4DArray(const casacore::Complex* __restrict__& store,
254  // __restrict__
255  {return store[iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]];};
256 
257  inline casacore::DComplex getFrom4DArray(const casacore::DComplex* __restrict__& store,
258  const casacore::Int* __restrict__& iPos,
260  // __restrict__
261  {return store[iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]];};
262 
263  inline casacore::DComplex getFrom4DArray(const casacore::DComplex* __restrict__& store,
265  // __restrict__
266  {return store[iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]];};
267 
268 
269  // The following two methods are called in the innermost loop.
270  inline casacore::Complex getFrom4DArray(const casacore::Complex* __restrict__& store, const casacore::Int* __restrict__& iPos)
271  // __restrict__
272  {return getFrom4DArray(store, iPos, inc_p);}
273 
274  inline casacore::DComplex getFrom4DArray(const casacore::DComplex* __restrict__& store, const casacore::Int* __restrict__& iPos)
275  // __restrict__
276  {return getFrom4DArray(store, iPos, inc_p);}
277 
278  };
279 }; //# NAMESPACE CASA - END
280 
281 #endif //
void cacheAxisIncrements(const casacore::Vector< casacore::Int > &n, casacore::Vector< casacore::Int > &inc)
void initializeToSky(const casacore::Array< casacore::Complex > &griddedData, const casacore::Matrix< casacore::Double > &sumwt)
int Int
Definition: aipstype.h:50
casacore::Matrix< casacore::Double > spwChanFreq_p
casacore::Vector< casacore::Int > cfMap_p
void sgrid(casacore::Int &ndim, casacore::Double *__restrict__ pos, casacore::Int *__restrict__ loc, casacore::Int *__restrict__ off, casacore::Complex &phasor, const casacore::Int &irow, const casacore::Double *__restrict__ uvw, const casacore::Double &dphase, const casacore::Double &freq, const casacore::Double *__restrict__ scale, const casacore::Double *__restrict__ offset, const casacore::Float *__restrict__ sampling)
casacore::Int *__restrict__ incPtr_p
casacore::Vector< casacore::Int > inc_p
casacore::Int inc0_p, inc1_p, inc2_p, inc3_p;
void finalizeToSky(casacore::Array< casacore::DComplex > &griddedData, casacore::Matrix< casacore::Double > &sumwt)
Aliases for more readable code at the FTMachine layer.
void addTo4DArray(casacore::DComplex *__restrict__ &store, casacore::Int *__restrict__ &iPos, casacore::Complex &nvalue, casacore::Double &wt) __restrict__
Version that use internally cached inc_p template &lt;class t&gt;=&quot;&quot;&gt;
virtual void setConvFunc(const CFStore &cfs)=0
const casacore::Vector< casacore::Int > getCFMap()
virtual void init(const casacore::Bool &doublePrecision)=0
Forward looking genealogical baggage – required for the MultiThreadedVisibilityResampler.
casacore::Vector< casacore::Int > conjCFMap_p
VisibilityResamplerBase(const VisibilityResamplerBase &other)
VisibilityResamplerBase(const CFStore&amp; cfs): uvwScale_p(), offset_p(), chanMap_p(), polMap_p(), convFuncStore_p(), inc_p(), cfMap_p(), conjCFMap_p() {setConvFunc(cfs);};.
The base class to compute convolution functions for convolutional gridding.
casacore::DComplex getFrom4DArray(const casacore::DComplex *__restrict__ &store, const casacore::Vector< casacore::Int > iPos, const casacore::Vector< casacore::Int > &inc)
restrict
casacore::Bool onGrid(const casacore::Int &nx, const casacore::Int &ny, const casacore::Vector< casacore::Int > &__restrict__ loc, const casacore::Vector< casacore::Int > &__restrict__ support) __restrict__
virtual void GatherGrids(casacore::Array< casacore::DComplex > &griddedData, casacore::Matrix< casacore::Double > &sumwt)=0
T * getStorage(Bool &deleteIt)
Generally use of this should be shunned, except to use a FORTRAN routine or something similar...
void cacheAxisIncrements(const casacore::Int n[4], casacore::Int inc[4])
casacore::Complex getFrom4DArray(const casacore::Complex *__restrict__ &store, const casacore::Vector< casacore::Int > iPos, const casacore::Vector< casacore::Int > &inc)
restrict
const casacore::Vector< casacore::Int > getConjCFMap()
casacore::DComplex getFrom4DArray(const casacore::DComplex *__restrict__ &store, const casacore::Int *__restrict__ &iPos, const casacore::Vector< casacore::Int > &inc)
restrict
virtual void ComputeResiduals(VBStore &vbs)=0
virtual void GridToData(VBStore&amp; vbs, casacore::Array&lt;casacore::Complex&gt;&amp; griddedData); ...
casacore::Matrix< casacore::Double > spwChanConjFreq_p
casacore::Vector< casacore::Int > chanMap_p
double Double
Definition: aipstype.h:55
LatticeExprNode ndim(const LatticeExprNode &expr)
1-argument function to get the dimensionality of a lattice.
casacore::Bool onGrid(const casacore::Int &nx, const casacore::Int &ny, const casacore::Int &loc0, const casacore::Int &loc1, const casacore::Int &support) __restrict__
virtual void setParams(const casacore::Vector< casacore::Double > &uvwScale, const casacore::Vector< casacore::Double > &offset, const casacore::Vector< casacore::Double > &dphase)=0
casacore::Vector< casacore::Double > uvwScale_p
-------------------------—Private parts----------------------------------—
virtual void setFreqMaps(const casacore::Matrix< casacore::Double > &spwChanFreqs, const casacore::Matrix< casacore::Double > &spwnChanConjFreqs)=0
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void addTo4DArray(casacore::Complex *__restrict__ &store, casacore::Int *__restrict__ &iPos, casacore::Int *__restrict__ inc, casacore::Complex &nvalue, casacore::Double &wt) __restrict__
virtual void initializeDataBuffers(VBStore &vbs)=0
VisibilityResamplerBase & operator=(const VisibilityResamplerBase &other)
measure the time it takes to execute parts of a program
Definition: Timer.h:127
virtual void setPATolerance(const double &dPA)=0
float Float
Definition: aipstype.h:54
void initializeToSky(const casacore::Array< casacore::DComplex > &griddedData, const casacore::Matrix< casacore::Double > &sumwt)
virtual void GridToData(VBStore &vbs, const casacore::Array< casacore::Complex > &griddedData)=0
void finalizeToSky(casacore::Array< casacore::Complex > &griddedData, casacore::Matrix< casacore::Double > &sumwt)
casacore::Vector< casacore::Int > polMap_p
casacore::Complex getFrom4DArray(const casacore::Complex *__restrict__ &store, const casacore::Int *__restrict__ &iPos)
The following two methods are called in the innermost loop.
casacore::Vector< casacore::Double > dphase_p
casacore::Vector< casacore::Double > offset_p
virtual void releaseBuffers()=0
casacore::DComplex getFrom4DArray(const casacore::DComplex *__restrict__ &store, const casacore::Int *__restrict__ &iPos)
restrict
virtual void initializePutBuffers(const casacore::Array< casacore::DComplex > &griddedData, const casacore::Matrix< casacore::Double > &sumwt)=0
virtual casacore::Int makeVBRow2CFMap(CFStore2 &cfs, ConvolutionFunction &cf, const VisBuffer &vb, const casacore::Quantity &dPA, const casacore::Vector< casacore::Int > &dataChan2ImChanMap, const casacore::Vector< casacore::Int > &dataPol2ImPolMap, const casacore::Vector< casacore::Double > &pointingOffset)
void cacheAxisIncrements(const casacore::Int &n0, const casacore::Int &n1, const casacore::Int &n2, const casacore::Int &n3)
casacore::Array assignment operator in CASACore requires lhs.nelements() == 0 or lhs.nelements()=rhs.nelements() template &lt;class t&gt;=&quot;&quot;&gt; inline void SETVEC(casacore::Vector&lt;T&gt;&amp; lhs, const casacore::Vector&lt;T&gt;&amp; rhs) {lhs.resize(rhs.shape()); lhs = rhs;};
VisBuffers encapsulate one chunk of visibility data for processing.
Definition: VisBuffer.h:153
void addTo4DArray(casacore::Complex *__restrict__ &store, casacore::Int *__restrict__ &iPos, casacore::Complex &nvalue, casacore::Double &wt) __restrict__
virtual void setMaps(const casacore::Vector< casacore::Int > &chanMap, const casacore::Vector< casacore::Int > &polMap)=0
void resize(size_t len, Bool copyValues=False)
Definition: Vector.h:167
virtual void copy(const VisibilityResamplerBase &other)
virtual void setCFMaps(const casacore::Vector< casacore::Int > &cfMap, const casacore::Vector< casacore::Int > &conjCFMap)=0
virtual VisibilityResamplerBase * clone()=0
void cacheAxisIncrements(const casacore::Vector< casacore::Int > &n)
void addTo4DArray(casacore::DComplex *__restrict__ &store, casacore::Int *__restrict__ &iPos, casacore::Int *__restrict__ inc, casacore::Complex &nvalue, casacore::Double &wt) __restrict__
Version where inc_p is supplied from outside.
virtual void DataToGrid(casacore::Array< casacore::DComplex > &griddedData, VBStore &vbs, casacore::Matrix< casacore::Double > &sumwt, const casacore::Bool &dopsf, casacore::Bool useConjFreqCF=false)=0
casacore::Complex getFrom4DArray(const casacore::Complex *__restrict__ &store, const casacore::Int *__restrict__ &iPos, const casacore::Vector< casacore::Int > &inc)
restrict