casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VisibilityResampler.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 //# VisibilityResampler.h: Definition of the VisibilityResampler 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_VISIBILITYRESAMPLER_H
30 #define SYNTHESIS_VISIBILITYRESAMPLER_H
31 
36 #include <msvis/MSVis/VisBuffer.h>
37 #include <casa/Arrays/Array.h>
38 #include <casa/Arrays/Vector.h>
39 //#include <msvis/MSVis/AsynchronousTools.h>
40 
41 #include <casa/Logging/LogIO.h>
42 #include <casa/Logging/LogSink.h>
44 
45 namespace casa { //# NAMESPACE CASA - BEGIN
47  {
48  public:
50  // VisibilityResampler(const CFStore& cfs): VisibilityResamplerBase(cfs) {};
52  {copy(other);}
53 
54  // {setConvFunc(cfs);};
55  virtual ~VisibilityResampler() {};
56 
57  // VisibilityResampler& operator=(const VisibilityResampler& other);
58 
59  void copy(const VisibilityResamplerBase& other)
61 
63  {return new VisibilityResampler(*this);}
64 
66  {uvwScale.assign(uvwScale_p); offset.assign(offset_p); dphase.assign(dphase_p);};
69  {
70  // SynthesisUtils::SETVEC(uvwScale_p, uvwScale);
71  // SynthesisUtils::SETVEC(offset_p, offset);
72  // SynthesisUtils::SETVEC(dphase_p, dphase);
73  uvwScale_p.reference(uvwScale);
74  offset_p.reference(offset);
75  dphase_p.reference(dphase);
76  };
77 
78  virtual void setMaps(const casacore::Vector<casacore::Int>& chanMap, const casacore::Vector<casacore::Int>& polMap)
79  {
80  // SynthesisUtils::SETVEC(chanMap_p,chanMap);
81  // SynthesisUtils::SETVEC(polMap_p,polMap);
82  chanMap_p.reference(chanMap);
83  polMap_p.reference(polMap);
84  }
85 
86  virtual void setFreqMaps(const casacore::Matrix<casacore::Double>& spwChanFreqs, const casacore::Matrix<casacore::Double>& spwChanConjFreqs)
87  {
88  spwChanFreq_p.assign(spwChanFreqs);
89  spwChanConjFreq_p.assign(spwChanConjFreqs);
90  }
91 
92  virtual void setConvFunc(const CFStore& cfs)
93  {
94  convFuncStore_p = cfs;
95  };
96  virtual void setCFMaps(const casacore::Vector<casacore::Int>& cfMap, const casacore::Vector<casacore::Int>& conjCFMap) {(void)cfMap;(void)conjCFMap;};
97 
98  virtual void setPATolerance(const double& dPA) {paTolerance_p = dPA;};
99  //
100  //------------------------------------------------------------------------------
101  //
102  // Re-sample the griddedData on the VisBuffer (a.k.a gridding).
103  //
104  // In this class, these just call the private templated version.
105  // The first variant grids onto a double precision grid while the
106  // second one does it on a single precision grid.
107  //
108  virtual void DataToGrid(casacore::Array<casacore::DComplex>& griddedData, VBStore& vbs,
110  casacore::Bool /*useConjFreqCF*/=false)
111  {DataToGridImpl_p(griddedData, vbs, dopsf, sumwt);}
112 
113  virtual void DataToGrid(casacore::Array<casacore::Complex>& griddedData, VBStore& vbs,
115  casacore::Bool /*useConjFreqCF*/=false)
116  {DataToGridImpl_p(griddedData, vbs, dopsf, sumwt);}
117 
118  //
119  //------------------------------------------------------------------------------
120  //
121  // Re-sample VisBuffer to a regular grid (griddedData) (a.k.a. de-gridding)
122  //
123  virtual void GridToData(VBStore& vbs,const casacore::Array<casacore::Complex>& griddedData);
124  // virtual void GridToData(VBStore& vbs, casacore::Array<casacore::Complex>& griddedData);
125 
126  virtual void ComputeResiduals(VBStore& vbs);
127  virtual void setMutex(async::Mutex *mu) {myMutex_p = mu;};
128 
129  // Genealogical baggage -- required for the
130  // MultiThreadedVisibilityResampler -- that everyone else has to
131  // carray around.
132  //
133  // These are no-ops for unithreaded samplers.
134  //
135  virtual void init(const casacore::Bool& doublePrecision) {(void)doublePrecision;};
136  virtual void GatherGrids(casacore::Array<casacore::DComplex>& griddedData, casacore::Matrix<casacore::Double>& sumwt) {(void)griddedData;(void)sumwt;};
137  virtual void GatherGrids(casacore::Array<casacore::Complex>& griddedData, casacore::Matrix<casacore::Double>& sumwt) {(void)griddedData;(void)sumwt;};
139  const casacore::Matrix<casacore::Double>& sumwt) {(void)griddedData;(void)sumwt;};
141  const casacore::Matrix<casacore::Double>& sumwt) {(void)griddedData;(void)sumwt;};
142  virtual void initializeDataBuffers(VBStore& vbs) {(void)vbs;};
143 
144 
145  virtual void releaseBuffers() {};
146  //
147  //------------------------------------------------------------------------------
148  //----------------------------Private parts-------------------------------------
149  //------------------------------------------------------------------------------
150  //
151  protected:
153  // casacore::Vector<casacore::Double> uvwScale_p, offset_p, dphase_p;
154  // casacore::Vector<casacore::Int> chanMap_p, polMap_p;
155  // CFStore convFuncStore_p;
156  // casacore::Int inc0_p, inc1_p, inc2_p, inc3_p;
157  //
158  // Re-sample the griddedData on the VisBuffer (a.k.a de-gridding).
159  //
160  template <class T>
161  void DataToGridImpl_p(casacore::Array<T>& griddedData, VBStore& vb,
162  const casacore::Bool& dopsf, casacore::Matrix<casacore::Double>& sumwt,casacore::Bool useConjFreqCF=false);
163 
164  // void sgrid(casacore::Vector<casacore::Double>& pos, casacore::Vector<casacore::Int>& loc, casacore::Vector<casacore::Int>& off,
165  // casacore::Complex& phasor, const casacore::Int& irow, const casacore::Matrix<casacore::Double>& uvw,
166  // const casacore::Double& dphase, const casacore::Double& freq,
167  // const casacore::Vector<casacore::Double>& scale, const casacore::Vector<casacore::Double>& offset,
168  // const casacore::Vector<casacore::Float>& sampling);
169 
170  /*
171  void sgrid(casacore::Int& ndim, casacore::Double* pos, casacore::Int* loc, casacore::Int* off,
172  casacore::Complex& phasor, const casacore::Int& irow, const casacore::Double* uvw,
173  const casacore::Double& dphase, const casacore::Double& freq,
174  const casacore::Double* scale, const casacore::Double* offset,
175  const casacore::Float* sampling);
176 
177  inline casacore::Bool onGrid (const casacore::Int& nx, const casacore::Int& ny,
178  const casacore::Vector<casacore::Int>& __restrict__ loc,
179  const casacore::Vector<casacore::Int>& __restrict__ support) __restrict__
180  {
181  return (((loc(0)-support[0]) >= 0 ) && ((loc(0)+support[0]) < nx) &&
182  ((loc(1)-support[1]) >= 0 ) && ((loc(1)+support[1]) < ny));
183  };
184  inline casacore::Bool onGrid (const casacore::Int& nx, const casacore::Int& ny,
185  const casacore::Int& loc0, const casacore::Int& loc1,
186  const casacore::Int& support) __restrict__
187  {
188  return (((loc0-support) >= 0 ) && ((loc0+support) < nx) &&
189  ((loc1-support) >= 0 ) && ((loc1+support) < ny));
190  };
191 
192  // casacore::Array assignment operator in CASACore requires lhs.nelements()
193  // == 0 or lhs.nelements()=rhs.nelements()
194  // template <class T>
195  // inline void SETVEC(casacore::Vector<T>& lhs, const casacore::Vector<T>& rhs)
196  // {lhs.resize(rhs.shape()); lhs = rhs;};
197 
198 
199  //
200  // Internal methods to address a 4D array. These should ulimately
201  // moved to a Array4D class in CASACore
202  //
203 
204  // This is called less frequently. Currently once per VisBuffer
205  inline void cacheAxisIncrements(casacore::Int& n0, casacore::Int& n1, casacore::Int& n2, casacore::Int& n3)
206  {inc0_p=1, inc1_p=inc0_p*n0, inc2_p=inc1_p*n1, inc3_p=inc2_p*n2;(void)n3;}
207 
208 
209  // The following two methods are called in the innermost loop.
210  inline casacore::Complex getFrom4DArray(const casacore::Complex* __restrict__ store,
211  const casacore::Int* __restrict__ iPos) __restrict__
212  {return store[iPos[0] + iPos[1]*inc1_p + iPos[2]*inc2_p +iPos[3]*inc3_p];};
213 
214  template <class T>
215  void addTo4DArray(T* __restrict__ store,
216  const casacore::Int* __restrict__ iPos,
217  casacore::Complex& nvalue, casacore::Double& wt) __restrict__
218  {store[iPos[0] + iPos[1]*inc1_p + iPos[2]*inc2_p +iPos[3]*inc3_p] += (nvalue*wt);}
219  */
220  };
221 }; //# NAMESPACE CASA - END
222 
223 #endif //
virtual VisibilityResamplerBase * clone()
casacore::Matrix< casacore::Double > spwChanFreq_p
virtual void GatherGrids(casacore::Array< casacore::Complex > &griddedData, casacore::Matrix< casacore::Double > &sumwt)
void copy(const VisibilityResamplerBase &other)
VisibilityResampler&amp; operator=(const VisibilityResampler&amp; other);.
virtual void setConvFunc(const CFStore &cfs)
virtual ~VisibilityResampler()
{setConvFunc(cfs);};
static const double mu
Definition: ATMConstants.h:65
virtual void setMaps(const casacore::Vector< casacore::Int > &chanMap, const casacore::Vector< casacore::Int > &polMap)
virtual void setPATolerance(const double &dPA)
virtual void DataToGrid(casacore::Array< casacore::Complex > &griddedData, VBStore &vbs, casacore::Matrix< casacore::Double > &sumwt, const casacore::Bool &dopsf, casacore::Bool=false)
virtual void assign(const Array< T > &other)
Assign the other array (which must be dimension 2) to this matrix.
async::Mutex * myMutex_p
-------------------------—Private parts----------------------------------—
virtual void DataToGrid(casacore::Array< casacore::DComplex > &griddedData, VBStore &vbs, casacore::Matrix< casacore::Double > &sumwt, const casacore::Bool &dopsf, casacore::Bool=false)
virtual void initializePutBuffers(const casacore::Array< casacore::Complex > &griddedData, const casacore::Matrix< casacore::Double > &sumwt)
virtual void assign(const Array< T > &other)
Assign the other array (which must be of dimension one) to this vector.
virtual void setFreqMaps(const casacore::Matrix< casacore::Double > &spwChanFreqs, const casacore::Matrix< casacore::Double > &spwChanConjFreqs)
casacore::Matrix< casacore::Double > spwChanConjFreq_p
casacore::Vector< casacore::Int > chanMap_p
casacore::Vector< casacore::Double > uvwScale_p
-------------------------—Private parts----------------------------------—
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void ComputeResiduals(VBStore &vbs)
virtual void GridToData(VBStore&amp; vbs, casacore::Array&lt;casacore::Complex&gt;&amp; griddedData); ...
virtual void setParams(const casacore::Vector< casacore::Double > &uvwScale, const casacore::Vector< casacore::Double > &offset, const casacore::Vector< casacore::Double > &dphase)
casacore::Vector< casacore::Int > polMap_p
virtual void setCFMaps(const casacore::Vector< casacore::Int > &cfMap, const casacore::Vector< casacore::Int > &conjCFMap)
casacore::Vector< casacore::Double > dphase_p
casacore::Vector< casacore::Double > offset_p
virtual void GridToData(VBStore &vbs, const casacore::Array< casacore::Complex > &griddedData)
VisibilityResampler(const VisibilityResampler &other)
VisibilityResampler(const CFStore&amp; cfs): VisibilityResamplerBase(cfs) {};.
virtual void initializePutBuffers(const casacore::Array< casacore::DComplex > &griddedData, const casacore::Matrix< casacore::Double > &sumwt)
virtual void reference(const Array< T > &other)
Create a reference to &quot;other&quot;, which must be of dimension one.
virtual void copy(const VisibilityResamplerBase &other)
virtual void getParams(casacore::Vector< casacore::Double > &uvwScale, casacore::Vector< casacore::Double > &offset, casacore::Vector< casacore::Double > &dphase)
virtual void init(const casacore::Bool &doublePrecision)
Genealogical baggage – required for the MultiThreadedVisibilityResampler – that everyone else has to ...
void DataToGridImpl_p(casacore::Array< T > &griddedData, VBStore &vb, const casacore::Bool &dopsf, casacore::Matrix< casacore::Double > &sumwt, casacore::Bool useConjFreqCF=false)
casacore::Vector&lt;casacore::Double&gt; uvwScale_p, offset_p, dphase_p; casacore::Vector&lt;casacore::Int&gt; ch...
virtual void setMutex(async::Mutex *mu)
virtual void initializeDataBuffers(VBStore &vbs)
virtual void GatherGrids(casacore::Array< casacore::DComplex > &griddedData, casacore::Matrix< casacore::Double > &sumwt)