casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GridFT.h
Go to the documentation of this file.
1 //# GridFT.h: Definition for GridFT
2 //# Copyright (C) 1996-2012
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be adressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 //# $Id$
28 
29 #ifndef SYNTHESIS_TRANSFORM2_GRIDFT_H
30 #define SYNTHESIS_TRANSFORM2_GRIDFT_H
31 
33 #include <casa/Arrays/Matrix.h>
35 #include <msvis/MSVis/VisBuffer2.h>
38 #include <casa/Containers/Block.h>
39 #include <casa/Arrays/Array.h>
40 #include <casa/Arrays/Vector.h>
41 #include <casa/Arrays/Matrix.h>
45 
46 
47 namespace casacore{
48 
49 class UVWMachine;
50 }
51 
52 namespace casa { //# NAMESPACE CASA - BEGIN
53 
54 namespace vi { class VisBuffer2;}
55 namespace refim { //#namespace for imaging refactor
56 // <summary> An FTMachine for Gridded Fourier transforms </summary>
57 
58 // <use visibility=export>
59 
60 // <reviewed reviewer="" date="" tests="" demos="">
61 
62 // <prerequisite>
63 // <li> <linkto class=FTMachine>FTMachine</linkto> module
64 // <li> <linkto class=SkyEquation>SkyEquation</linkto> module
65 // <li> <linkto class=VisBuffer>VisBuffer</linkto> module
66 // </prerequisite>
67 //
68 // <etymology>
69 // FTMachine is a Machine for Fourier Transforms. GridFT does
70 // Grid-based Fourier transforms.
71 // </etymology>
72 //
73 // <synopsis>
74 // The <linkto class=SkyEquation>SkyEquation</linkto> needs to be able
75 // to perform Fourier transforms on visibility data. GridFT
76 // allows efficient Fourier Transform processing using a
77 // <linkto class=VisBuffer>VisBuffer</linkto> which encapsulates
78 // a chunk of visibility (typically all baselines for one time)
79 // together with all the information needed for processing
80 // (e.g. UVW coordinates).
81 //
82 // Gridding and degridding in GridFT are performed using a
83 // novel sort-less algorithm. In this approach, the gridded plane is
84 // divided into small patches, a cache of which is maintained in memory
85 // using a general-purpose <linkto class=casacore::LatticeCache>LatticeCache</linkto> class. As the (time-sorted)
86 // visibility data move around slowly in the Fourier plane, patches are
87 // swapped in and out as necessary. Thus, optimally, one would keep at
88 // least one patch per baseline.
89 //
90 // A grid cache is defined on construction. If the gridded uv plane is smaller
91 // than this, it is kept entirely in memory and all gridding and
92 // degridding is done entirely in memory. Otherwise a cache of tiles is
93 // kept an paged in and out as necessary. Optimally the cache should be
94 // big enough to hold all polarizations and frequencies for all
95 // baselines. The paging rate will then be small. As the cache size is
96 // reduced below this critical value, paging increases. The algorithm will
97 // work for only one patch but it will be very slow!
98 //
99 // This scheme works well for arrays having a moderate number of
100 // antennas since the saving in space goes as the ratio of
101 // baselines to image size. For the ATCA, VLBA and WSRT, this ratio is
102 // quite favorable. For the VLA, one requires images of greater than
103 // about 200 pixels on a side to make it worthwhile.
104 //
105 // The FFT step is done plane by plane for images having less than
106 // 1024 * 1024 pixels on each plane, and line by line otherwise.
107 //
108 // The gridding and degridding steps are implemented in Fortran
109 // for speed. In gridding, the visibilities are added onto the
110 // grid points in the neighborhood using a weighting function.
111 // In degridding, the value is derived by a weight summ of the
112 // same points, using the same weighting function.
113 // </synopsis>
114 //
115 // <example>
116 // See the example for <linkto class=SkyModel>SkyModel</linkto>.
117 // </example>
118 //
119 // <motivation>
120 // Define an interface to allow efficient processing of chunks of
121 // visibility data
122 // </motivation>
123 //
124 // <todo asof="97/10/01">
125 // <ul> Deal with large VLA spectral line case
126 // </todo>
127 
128 class GridFT : public FTMachine {
129 public:
130 
131  // Constructor: cachesize is the size of the cache in words
132  // (e.g. a few million is a good number), tilesize is the
133  // size of the tile used in gridding (cannot be less than
134  // 12, 16 works in most cases), and convType is the type of
135  // gridding used (SF is prolate spheriodal wavefunction,
136  // and BOX is plain box-car summation). mLocation is
137  // the position to be used in some phase rotations. If
138  // mTangent is specified then the uvw rotation is done for
139  // that location iso the image center.
140  // <group>
141  GridFT();
143  casacore::Float padding=1.0, casacore::Bool usezero=true, casacore::Bool useDoublePrec=false);
145  casacore::MPosition mLocation, casacore::Float padding=1.0, casacore::Bool usezero=true,
146  casacore::Bool useDoublePrec=false);
147  GridFT(casacore::Long cachesize, casacore::Int tilesize, casacore::String convType,
148  casacore::MDirection mTangent, casacore::Float padding=1.0, casacore::Bool usezero=true,
149  casacore::Bool useDoublePrec=false);
150  GridFT(casacore::Long cachesize, casacore::Int tilesize, casacore::String convType,
151  casacore::MPosition mLocation, casacore::MDirection mTangent, casacore::Float passing=1.0,
152  casacore::Bool usezero=true, casacore::Bool useDoublePrec=false);
153  // </group>
154 
155  // Construct from a casacore::Record containing the GridFT state
156  GridFT(const casacore::RecordInterface& stateRec);
157 
158  // Copy constructor
159  GridFT(const GridFT &other);
160 
161  // Assignment operator
162  virtual GridFT &operator=(const GridFT &other);
163 
164  virtual ~GridFT();
165 
166  virtual FTMachine* cloneFTM();
167 
168  // Initialize transform to Visibility plane using the image
169  // as a template. The image is loaded and Fourier transformed.
170 
172  const vi::VisBuffer2& vb);
173 
174  // Finalize transform to Visibility plane: flushes the image
175  // cache and shows statistics if it is being used.
176  virtual void finalizeToVis();
177 
178  // Initialize transform to Sky plane: initializes the image
179 
181  const vi::VisBuffer2& vb);
182 
183  // Finalize transform to Sky plane: flushes the image
184  // cache and shows statistics if it is being used. DOES NOT
185  // DO THE FINAL TRANSFORM!
186  virtual void finalizeToSky();
187 
188 
189  // Get actual coherence from grid by degridding
190 
191  virtual void get(vi::VisBuffer2& vb, casacore::Int row=-1);
192 
193  // Put coherence to grid by gridding.
194 
195  virtual void put(const vi::VisBuffer2& vb, casacore::Int row=-1, casacore::Bool dopsf=false,
197 
198  // Make the entire image
203 
204  // Get the final image: do the Fourier transform and
205  // grid-correct, then optionally normalize by the summed weights
208  const casacore::Matrix<casacore::Double>& /*sumOfWts*/,
209  casacore::Lattice<casacore::Float>& /*sensitivityImage*/,
210  casacore::Bool /*fftNorm*/)
211  {throw(casacore::AipsError("GridFT::normalizeImage() called"));}
212 
213  // Get the final weights image
215 
216  // Save and restore the GridFT to and from a record
218  casacore::Bool withImage=false, const casacore::String diskimage="");
220 
221  // Can this FTMachine be represented by Fourier convolutions?
222  virtual casacore::Bool isFourier() {return true;}
223 
224  virtual void setNoPadding(casacore::Bool nopad){noPadding_p=nopad;};
225  virtual void modifyConvFunc(const casacore::Vector<casacore::Double>& convFunc, casacore::Int convSupport, casacore::Int convSampling);
226  virtual casacore::String name() const;
227  virtual void setMiscInfo(const casacore::Int qualifier){(void)qualifier;};
228  virtual void ComputeResiduals(vi::VisBuffer2&/*vb*/, casacore::Bool /*useCorrected*/) {};
231 
232 protected:
233 
234 
235  // Padding in FFT
237 
238  // Get the appropriate data pointer
240 
241  virtual void ok();
242 
243  virtual void init();
244 
245  //Prepare the grid for degridding
246  virtual void prepGridForDegrid();
247 
248  // Is this record on Grid? check both ends. This assumes that the
249  // ends bracket the middle
250  // casacore::Bool recordOnGrid(const VisBuffer& vb, casacore::Int rownr) const;
251 
252 
253  // Image cache
255 
256  // Sizes
259 
260  // Gridder
262 
263  // Is this tiled?
265 
266  // casacore::Array lattice
267  std::shared_ptr<casacore::Lattice<casacore::Complex> > arrayLattice;
268 
269  // Lattice. For non-tiled gridding, this will point to arrayLattice,
270  // whereas for tiled gridding, this points to the image
271  std::shared_ptr<casacore::Lattice<casacore::Complex> > lattice;
272 
274 
276 
277  // Useful IPositions
279 
280  // Image Scaling and offset
282 
283 
285 
286  // Grid/degrid zero spacing points?
287 
289 
290  //force no padding
292 
293  //Check if using put that avoids non-necessary reads
295 
296  //machine name
298 
302  // casa::async::SynthesisAsyncPeek *peek;
303 
304 };
305 
306 }//# end of namespace refim
307 } //# NAMESPACE CASA - END
308 
309 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
A Measure: astronomical direction.
Definition: MDirection.h:174
A Measure: position on Earth.
Definition: MPosition.h:79
casacore::Double timegrid_p
Definition: GridFT.h:299
int Int
Definition: aipstype.h:50
casacore::String convType
Definition: GridFT.h:273
casacore::Bool noPadding_p
force no padding
Definition: GridFT.h:291
defines interface for the Fourier Transform Machine
Definition: FTMachine.h:122
virtual void init()
VisibilityIterator2 iterates through one or more readonly MeasurementSets.
casacore::IPosition offsetLoc
Definition: GridFT.h:278
virtual void setNoPadding(casacore::Bool nopad)
To make sure no padding is used in certain gridders.
Definition: GridFT.h:224
void makeImage(FTMachine::Type type, vi::VisibilityIterator2 &vi, casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight)
Make the entire image.
casacore::Int tilesize
Definition: GridFT.h:258
casacore::Double timedegrid_p
Definition: GridFT.h:299
virtual FTMachine * cloneFTM()
clone copy should make it pure virtual forcing every ftm to have a cloner
virtual void normalizeImage(casacore::Lattice< casacore::Complex > &, const casacore::Matrix< casacore::Double > &, casacore::Lattice< casacore::Float > &, casacore::Bool)
Definition: GridFT.h:207
virtual Type type()
Return the type enum.
virtual casacore::Bool toRecord(casacore::String &error, casacore::RecordInterface &outRec, casacore::Bool withImage=false, const casacore::String diskimage="")
Save and restore the GridFT to and from a record.
casacore::Int convSupport_p
Definition: GridFT.h:301
virtual void finalizeToVis()
Finalize transform to Visibility plane: flushes the image cache and shows statistics if it is being u...
casacore::String machineName_p
machine name
Definition: GridFT.h:297
virtual casacore::Bool fromRecord(casacore::String &error, const casacore::RecordInterface &inRec)
virtual casacore::String name() const
Return the name of the machine.
casacore::IPosition centerLoc
Useful IPositions.
Definition: GridFT.h:278
virtual casacore::Long estimateRAM(const casacore::CountedPtr< SIImageStore > &imstore)
estimate of memory necessary in kB
casacore::Vector< casacore::Double > convFunc_p
Definition: GridFT.h:300
virtual void initializeToVis(casacore::ImageInterface< casacore::Complex > &image, const vi::VisBuffer2 &vb)
Initialize transform to Visibility plane using the image as a template.
casacore::Vector< casacore::Double > uvOffset
Definition: GridFT.h:281
virtual void put(const vi::VisBuffer2 &vb, casacore::Int row=-1, casacore::Bool dopsf=false, FTMachine::Type type=FTMachine::OBSERVED)
Put coherence to grid by gridding.
long Long
Definition: aipstype.h:52
casacore::Vector< casacore::Double > uvScale
Image Scaling and offset.
Definition: GridFT.h:281
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
casacore::Long cachesize
Sizes.
Definition: GridFT.h:257
An FTMachine for Gridded Fourier transforms.
Definition: GridFT.h:128
casacore::Int convSampling_p
Definition: GridFT.h:301
casacore::ImageInterface< casacore::Complex > & getImage(casacore::Matrix< casacore::Float > &, casacore::Bool normalize=true)
Get the final image: do the Fourier transform and grid-correct, then optionally normalize by the summ...
virtual void ComputeResiduals(vi::VisBuffer2 &, casacore::Bool)
Make the VB and VBStore interefaces for the interim re-factoring work.
Definition: GridFT.h:228
double Double
Definition: aipstype.h:55
Type
Types of known Images that may be made using the makeImage method.
Definition: FTMachine.h:127
casacore::LatticeCache< casacore::Complex > * imageCache
Is this record on Grid? check both ends.
Definition: GridFT.h:254
Converts UVW coordinates between coordinate systems.
Definition: UVWMachine.h:160
virtual void modifyConvFunc(const casacore::Vector< casacore::Double > &convFunc, casacore::Int convSupport, casacore::Int convSampling)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
float Float
Definition: aipstype.h:54
casacore::Bool usezero_p
Grid/degrid zero spacing points?
Definition: GridFT.h:288
virtual void setMiscInfo(const casacore::Int qualifier)
set the order of the Taylor term for MFS this is to tell A-casacore::Projection to qualify the accumu...
Definition: GridFT.h:227
virtual void prepGridForDegrid()
Prepare the grid for degridding.
std::shared_ptr< casacore::Lattice< casacore::Complex > > arrayLattice
casacore::Array lattice
Definition: GridFT.h:267
casacore::ConvolveGridder< casacore::Double, casacore::Complex > * gridder
Gridder.
Definition: GridFT.h:261
std::shared_ptr< casacore::Lattice< casacore::Complex > > lattice
Lattice.
Definition: GridFT.h:271
casacore::Array< casacore::Complex > * getDataPointer(const casacore::IPosition &, casacore::Bool)
Get the appropriate data pointer.
casacore::Float maxAbsData
Definition: GridFT.h:275
VisBuffer2s encapsulate one chunk of visibility data for processing.
Definition: VisBuffer2.h:141
Base class for all Casacore library errors.
Definition: Error.h:134
virtual casacore::Bool isFourier()
Can this FTMachine be represented by Fourier convolutions?
Definition: GridFT.h:222
virtual GridFT & operator=(const GridFT &other)
Assignment operator.
casacore::Float padding_p
Padding in FFT.
Definition: GridFT.h:236
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Int priorCacheSize
Definition: GridFT.h:284
GridFT()
Constructor: cachesize is the size of the cache in words (e.g.
virtual void ok()
casacore::Bool isTiled
Is this tiled?
Definition: GridFT.h:264
Abstract base class for Record classes.
void getWeightImage(casacore::ImageInterface< casacore::Float > &, casacore::Matrix< casacore::Float > &)
Get the final weights image.
virtual void initializeToSky(casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight, const vi::VisBuffer2 &vb)
Initialize transform to Sky plane: initializes the image.
casacore::ImageInterface< casacore::Complex > * image
Definition: FTMachine.h:395
casacore::Double timemass_p
Definition: GridFT.h:299
virtual void finalizeToSky()
Finalize transform to Sky plane: flushes the image cache and shows statistics if it is being used...
casacore::Bool usePut2_p
Check if using put that avoids non-necessary reads.
Definition: GridFT.h:294
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42