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_GRIDFT_H
30 #define SYNTHESIS_GRIDFT_H
31 
33 #include <casa/Arrays/Matrix.h>
35 #include <msvis/MSVis/VisBuffer.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 //#include <synthesis/MeasurementComponents/SynthesisPeek.h>
46 
47 
48 namespace casacore{
49 
50 class UVWMachine;
51 }
52 
53 namespace casa { //# NAMESPACE CASA - BEGIN
54 
55 // <summary> An FTMachine for Gridded Fourier transforms </summary>
56 
57 // <use visibility=export>
58 
59 // <reviewed reviewer="" date="" tests="" demos="">
60 
61 // <prerequisite>
62 // <li> <linkto class=FTMachine>FTMachine</linkto> module
63 // <li> <linkto class=SkyEquation>SkyEquation</linkto> module
64 // <li> <linkto class=VisBuffer>VisBuffer</linkto> module
65 // </prerequisite>
66 //
67 // <etymology>
68 // FTMachine is a Machine for Fourier Transforms. GridFT does
69 // Grid-based Fourier transforms.
70 // </etymology>
71 //
72 // <synopsis>
73 // The <linkto class=SkyEquation>SkyEquation</linkto> needs to be able
74 // to perform Fourier transforms on visibility data. GridFT
75 // allows efficient Fourier Transform processing using a
76 // <linkto class=VisBuffer>VisBuffer</linkto> which encapsulates
77 // a chunk of visibility (typically all baselines for one time)
78 // together with all the information needed for processing
79 // (e.g. UVW coordinates).
80 //
81 // Gridding and degridding in GridFT are performed using a
82 // novel sort-less algorithm. In this approach, the gridded plane is
83 // divided into small patches, a cache of which is maintained in memory
84 // using a general-purpose <linkto class=casacore::LatticeCache>LatticeCache</linkto> class. As the (time-sorted)
85 // visibility data move around slowly in the Fourier plane, patches are
86 // swapped in and out as necessary. Thus, optimally, one would keep at
87 // least one patch per baseline.
88 //
89 // A grid cache is defined on construction. If the gridded uv plane is smaller
90 // than this, it is kept entirely in memory and all gridding and
91 // degridding is done entirely in memory. Otherwise a cache of tiles is
92 // kept an paged in and out as necessary. Optimally the cache should be
93 // big enough to hold all polarizations and frequencies for all
94 // baselines. The paging rate will then be small. As the cache size is
95 // reduced below this critical value, paging increases. The algorithm will
96 // work for only one patch but it will be very slow!
97 //
98 // This scheme works well for arrays having a moderate number of
99 // antennas since the saving in space goes as the ratio of
100 // baselines to image size. For the ATCA, VLBA and WSRT, this ratio is
101 // quite favorable. For the VLA, one requires images of greater than
102 // about 200 pixels on a side to make it worthwhile.
103 //
104 // The FFT step is done plane by plane for images having less than
105 // 1024 * 1024 pixels on each plane, and line by line otherwise.
106 //
107 // The gridding and degridding steps are implemented in Fortran
108 // for speed. In gridding, the visibilities are added onto the
109 // grid points in the neighborhood using a weighting function.
110 // In degridding, the value is derived by a weight summ of the
111 // same points, using the same weighting function.
112 // </synopsis>
113 //
114 // <example>
115 // See the example for <linkto class=SkyModel>SkyModel</linkto>.
116 // </example>
117 //
118 // <motivation>
119 // Define an interface to allow efficient processing of chunks of
120 // visibility data
121 // </motivation>
122 //
123 // <todo asof="97/10/01">
124 // <ul> Deal with large VLA spectral line case
125 // </todo>
126 
127 class GridFT : public FTMachine {
128 public:
129 
130  // Constructor: cachesize is the size of the cache in words
131  // (e.g. a few million is a good number), tilesize is the
132  // size of the tile used in gridding (cannot be less than
133  // 12, 16 works in most cases), and convType is the type of
134  // gridding used (SF is prolate spheriodal wavefunction,
135  // and BOX is plain box-car summation). mLocation is
136  // the position to be used in some phase rotations. If
137  // mTangent is specified then the uvw rotation is done for
138  // that location iso the image center.
139  // <group>
140  GridFT();
142  casacore::Float padding=1.0, casacore::Bool usezero=true, casacore::Bool useDoublePrec=false);
144  casacore::MPosition mLocation, casacore::Float padding=1.0, casacore::Bool usezero=true,
145  casacore::Bool useDoublePrec=false);
146  GridFT(casacore::Long cachesize, casacore::Int tilesize, casacore::String convType,
147  casacore::MDirection mTangent, casacore::Float padding=1.0, casacore::Bool usezero=true,
148  casacore::Bool useDoublePrec=false);
149  GridFT(casacore::Long cachesize, casacore::Int tilesize, casacore::String convType,
150  casacore::MPosition mLocation, casacore::MDirection mTangent, casacore::Float passing=1.0,
151  casacore::Bool usezero=true, casacore::Bool useDoublePrec=false);
152  // </group>
153 
154  // Construct from a casacore::Record containing the GridFT state
155  GridFT(const casacore::RecordInterface& stateRec);
156 
157  // Copy constructor
158  GridFT(const GridFT &other);
159 
160  // Assignment operator
161  virtual GridFT &operator=(const GridFT &other);
162 
163  virtual ~GridFT();
164 
165  virtual FTMachine* cloneFTM();
166 
167  // Initialize transform to Visibility plane using the image
168  // as a template. The image is loaded and Fourier transformed.
170  const VisBuffer& vb);
171 
172  // Finalize transform to Visibility plane: flushes the image
173  // cache and shows statistics if it is being used.
174  virtual void finalizeToVis();
175 
176  // Initialize transform to Sky plane: initializes the image
178  const VisBuffer& vb);
179 
180 
181  // Finalize transform to Sky plane: flushes the image
182  // cache and shows statistics if it is being used. DOES NOT
183  // DO THE FINAL TRANSFORM!
184  virtual void finalizeToSky();
185 
186 
187  // Get actual coherence from grid by degridding
188  virtual void get(VisBuffer& vb, casacore::Int row=-1);
189 
190 
191  // Put coherence to grid by gridding.
192  virtual void put(const VisBuffer& vb, casacore::Int row=-1, casacore::Bool dopsf=false,
194 
195  // Make the entire image
197  VisSet& vs,
200 
201  // Get the final image: do the Fourier transform and
202  // grid-correct, then optionally normalize by the summed weights
205  const casacore::Matrix<casacore::Double>& /*sumOfWts*/,
206  casacore::Lattice<casacore::Float>& /*sensitivityImage*/,
207  casacore::Bool /*fftNorm*/)
208  {throw(casacore::AipsError("GridFT::normalizeImage() called"));}
209 
210  // Get the final weights image
212 
213  // Save and restore the GridFT to and from a record
215  casacore::Bool withImage=false, const casacore::String diskimage="");
217 
218  // Can this FTMachine be represented by Fourier convolutions?
219  virtual casacore::Bool isFourier() {return true;}
220 
221  virtual void setNoPadding(casacore::Bool nopad){noPadding_p=nopad;};
222  virtual void modifyConvFunc(const casacore::Vector<casacore::Double>& convFunc, casacore::Int convSupport, casacore::Int convSampling);
223  virtual casacore::String name() const;
224  virtual void setMiscInfo(const casacore::Int qualifier){(void)qualifier;};
225  virtual void ComputeResiduals(VisBuffer&/*vb*/, casacore::Bool /*useCorrected*/) {};
226 
227 protected:
228 
229 
230  // Padding in FFT
232 
233  // Get the appropriate data pointer
235 
236  virtual void ok();
237 
238  virtual void init();
239 
240  //Prepare the grid for degridding
241  virtual void prepGridForDegrid();
242 
243  // Is this record on Grid? check both ends. This assumes that the
244  // ends bracket the middle
245  casacore::Bool recordOnGrid(const VisBuffer& vb, casacore::Int rownr) const;
246 
247 
248  // Image cache
250 
251  // Sizes
254 
255  // Gridder
257 
258  // Is this tiled?
260 
261  // casacore::Array lattice
263 
264  // Lattice. For non-tiled gridding, this will point to arrayLattice,
265  // whereas for tiled gridding, this points to the image
267 
269 
271 
272  // Useful IPositions
274 
275  // Image Scaling and offset
277 
278 
280 
281  // Grid/degrid zero spacing points?
282 
284 
285  //force no padding
287 
288  //Check if using put that avoids non-necessary reads
290 
291  //machine name
293 
297  // casa::async::SynthesisAsyncPeek *peek;
298 };
299 
300 } //# NAMESPACE CASA - END
301 
302 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
virtual void init()
A Measure: astronomical direction.
Definition: MDirection.h:174
casacore::ConvolveGridder< casacore::Double, casacore::Complex > * gridder
Gridder.
Definition: GridFT.h:256
A Measure: position on Earth.
Definition: MPosition.h:79
int Int
Definition: aipstype.h:50
virtual GridFT & operator=(const GridFT &other)
Assignment operator.
virtual ~GridFT()
casacore::Float padding_p
Padding in FFT.
Definition: GridFT.h:225
virtual Type type()
Return the type enum.
casacore::Bool recordOnGrid(const VisBuffer &vb, casacore::Int rownr) const
Is this record on Grid? check both ends.
casacore::Long cachesize
Sizes.
Definition: GridFT.h:252
virtual void normalizeImage(casacore::Lattice< casacore::Complex > &, const casacore::Matrix< casacore::Double > &, casacore::Lattice< casacore::Float > &, casacore::Bool)
Definition: GridFT.h:204
GridFT()
Constructor: cachesize is the size of the cache in words (e.g.
virtual void prepGridForDegrid()
Prepare the grid for degridding.
casacore::ImageInterface< casacore::Complex > * image
Definition: FTMachine.h:409
void getWeightImage(casacore::ImageInterface< casacore::Float > &, casacore::Matrix< casacore::Float > &)
Get the final weights image.
virtual void finalizeToVis()
Finalize transform to Visibility plane: flushes the image cache and shows statistics if it is being u...
casacore::Int convSupport_p
Definition: GridFT.h:296
casacore::String convType
Definition: GridFT.h:268
virtual void initializeToVis(casacore::ImageInterface< casacore::Complex > &image, const VisBuffer &vb)
Initialize transform to Visibility plane using the image as a template.
virtual void finalizeToSky()
Finalize transform to Sky plane: flushes the image cache and shows statistics if it is being used...
casacore::IPosition offsetLoc
Definition: GridFT.h:273
long Long
Definition: aipstype.h:52
virtual void setNoPadding(casacore::Bool nopad)
To make sure no padding is used in certain gridders.
Definition: GridFT.h:221
void makeImage(FTMachine::Type type, VisSet &vs, casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight)
Make the entire image.
virtual void put(const VisBuffer &vb, casacore::Int row=-1, casacore::Bool dopsf=false, FTMachine::Type type=FTMachine::OBSERVED)
Put coherence to grid by gridding.
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
casacore::Vector< casacore::Double > uvScale
Image Scaling and offset.
Definition: GridFT.h:276
casacore::Int priorCacheSize
Definition: GridFT.h:279
casacore::Double timegrid_p
Definition: GridFT.h:294
double Double
Definition: aipstype.h:55
casacore::Bool usePut2_p
Check if using put that avoids non-necessary reads.
Definition: GridFT.h:289
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:224
virtual void ComputeResiduals(VisBuffer &, casacore::Bool)
Make the VB and VBStore interefaces for the interim re-factoring work.
Definition: GridFT.h:225
casacore::Vector< casacore::Double > convFunc_p
Definition: GridFT.h:295
casacore::Double timedegrid_p
Definition: GridFT.h:294
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::CountedPtr< casacore::Lattice< casacore::Complex > > arrayLattice
casacore::Array lattice
Definition: GridFT.h:262
Type
Types of known Images that may be made using the makeImage method.
Definition: FTMachine.h:125
Converts UVW coordinates between coordinate systems.
Definition: UVWMachine.h:160
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Int convSampling_p
Definition: GridFT.h:296
casacore::LatticeCache< casacore::Complex > * imageCache
Image cache.
Definition: GridFT.h:249
casacore::Array< casacore::Complex > * getDataPointer(const casacore::IPosition &, casacore::Bool)
Get the appropriate data pointer.
casacore::String machineName_p
machine name
Definition: GridFT.h:292
casacore::Float maxAbsData
Definition: GridFT.h:270
float Float
Definition: aipstype.h:54
casacore::Double timemass_p
Definition: GridFT.h:294
An FTMachine for Gridded Fourier transforms.
Definition: GridFT.h:127
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...
casacore::IPosition centerLoc
Useful IPositions.
Definition: GridFT.h:273
virtual FTMachine * cloneFTM()
clone copy the default cloner clones via a Record copy
Base class for all Casacore library errors.
Definition: Error.h:134
virtual void initializeToSky(casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight, const VisBuffer &vb)
Initialize transform to Sky plane: initializes the image.
virtual casacore::String name() const
Return the name of the machine.
virtual casacore::Bool isFourier()
Can this FTMachine be represented by Fourier convolutions?
Definition: GridFT.h:219
String: the storage and methods of handling collections of characters.
Definition: String.h:223
VisBuffers encapsulate one chunk of visibility data for processing.
Definition: VisBuffer.h:153
casacore::CountedPtr< casacore::Lattice< casacore::Complex > > lattice
Lattice.
Definition: GridFT.h:266
virtual casacore::Bool fromRecord(casacore::String &error, const casacore::RecordInterface &inRec)
casacore::Vector< casacore::Double > uvOffset
Definition: GridFT.h:276
virtual void ok()
Abstract base class for Record classes.
casacore::Int tilesize
Definition: GridFT.h:253
casacore::Bool noPadding_p
force no padding
Definition: GridFT.h:286
casacore::Bool isTiled
Is this tiled?
Definition: GridFT.h:259
virtual void modifyConvFunc(const casacore::Vector< casacore::Double > &convFunc, casacore::Int convSupport, casacore::Int convSampling)
casacore::Bool usezero_p
Grid/degrid zero spacing points?
Definition: GridFT.h:283
defines interface for the Fourier Transform Machine
Definition: FTMachine.h:120
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42