casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rGridFT.h
Go to the documentation of this file.
1 //# rGridFT.h: Definition for rGridFT
2 //# Copyright (C) 1996,1997,1998,1999,2000,2002
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_RGRIDFT_H
30 #define SYNTHESIS_RGRIDFT_H
31 
33 #include <synthesis/MeasurementComponents/VisibilityResampler.h>
35 #include <casa/Arrays/Matrix.h>
37 #include <msvis/MSVis/VisBuffer.h>
40 #include <casa/Containers/Block.h>
41 #include <casa/Arrays/Array.h>
42 #include <casa/Arrays/Vector.h>
43 #include <casa/Arrays/Matrix.h>
47 
48 
49 namespace casacore{
50 
51 class UVWMachine;
52 }
53 
54 namespace casa { //# NAMESPACE CASA - BEGIN
55 
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. rGridFT 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. rGridFT
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 rGridFT 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 rGridFT : 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>
142  casacore::String convType="SF", 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);
147  casacore::MDirection mTangent, casacore::Float padding=1.0, casacore::Bool usezero=true,
148  casacore::Bool useDoublePrec=false);
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 rGridFT state
155  rGridFT(const casacore::RecordInterface& stateRec);
156 
157  // Copy constructor
158  rGridFT(const rGridFT &other);
159 
160  // Assignment operator
161  rGridFT &operator=(const rGridFT &other);
162 
163  // Clone
164  rGridFT* clone();
165 
166  ~rGridFT();
167 
168  // Initialize transform to Visibility plane using the image
169  // as a template. The image is loaded and Fourier transformed.
171  const VisBuffer& vb);
172 
173  // Finalize transform to Visibility plane: flushes the image
174  // cache and shows statistics if it is being used.
175  void finalizeToVis();
176 
177  // Initialize transform to Sky plane: initializes the image
179  const VisBuffer& vb);
180 
181 
182  // Finalize transform to Sky plane: flushes the image
183  // cache and shows statistics if it is being used. DOES NOT
184  // DO THE FINAL TRANSFORM!
185  void finalizeToSky();
186 
187 
188  // Get actual coherence from grid by degridding
189  void get(VisBuffer& vb, casacore::Int row=-1);
190 
191 
192  // Put coherence to grid by gridding.
193  void put(const VisBuffer& vb, casacore::Int row=-1, casacore::Bool dopsf=false,
195 
196 
197  // Make the entire image
199  VisSet& vs,
202 
203  // Get the final image: do the Fourier transform and
204  // grid-correct, then optionally normalize by the summed weights
207  const casacore::Matrix<casacore::Double>& sumOfWts,
208  casacore::Lattice<casacore::Float>& sensitivityImage,
209  casacore::Bool fftNorm)
210  {throw(casacore::AipsError("rGridFT::normalizeImage() called"));}
211 
212  // Get the final weights image
214 
215  // Save and restore the rGridFT to and from a record
217  casacore::Bool withImage=false);
219 
220  // Can this FTMachine be represented by Fourier convolutions?
221  virtual casacore::Bool isFourier() {return true;}
222 
223  virtual void setNoPadding(casacore::Bool nopad){noPadding_p=nopad;};
224 
225  virtual casacore::String name();
226  virtual void setMiscInfo(const casacore::Int qualifier){(void)qualifier;};
227  virtual void ComputeResiduals(VisBuffer&vb, casacore::Bool useCorrected);
228 
229 protected:
230 
231 
232  // Padding in FFT
234 
235  // Get the appropriate data pointer
237 
238  void ok();
239 
240  void init();
241 
242  // Is this record on Grid? check both ends. This assumes that the
243  // ends bracket the middle
244  casacore::Bool recordOnGrid(const VisBuffer& vb, casacore::Int rownr) const;
245 
246  // Image cache
248 
249  // Sizes
252 
253  // Gridder
255 
256  // Is this tiled?
258 
259  // casacore::Array lattice
261 
262  // Lattice. For non-tiled gridding, this will point to arrayLattice,
263  // whereas for tiled gridding, this points to the image
265 
267 
269 
270  // Useful IPositions
272 
273  // Image Scaling and offset
275 
276  // casacore::Array for non-tiled gridding
279 
281 
282  // Grid/degrid zero spacing points?
283 
285 
286  //force no padding
288 
289  //Check if using put that avoids non-necessary reads
291 
292  //machine name
294 
295  // VisibilityResampler - a.k.a the "gridder" object
296  // VisibilityResampler visResampler_p;
297  // casacore::CountedPtr<MultiThreadedVisibilityResampler> visResampler_p;
299 };
300 
301 } //# NAMESPACE CASA - END
302 
303 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
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.
void finalizeToVis()
Finalize transform to Visibility plane: flushes the image cache and shows statistics if it is being u...
A Measure: astronomical direction.
Definition: MDirection.h:174
A Measure: position on Earth.
Definition: MPosition.h:79
int Int
Definition: aipstype.h:50
virtual casacore::Bool fromRecord(casacore::String &error, const casacore::RecordInterface &inRec)
casacore::CountedPtr< VisibilityResamplerBase > visResampler_p
VisibilityResampler - a.k.a the &quot;gridder&quot; object VisibilityResampler visResampler_p; casacore::Counte...
Definition: rGridFT.h:298
casacore::ConvolveGridder< casacore::Double, casacore::Complex > * gridder
Gridder.
Definition: rGridFT.h:253
casacore::LatticeCache< casacore::Complex > * imageCache
Image cache.
Definition: rGridFT.h:246
void makeImage(FTMachine::Type type, VisSet &vs, casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight)
Make the entire image.
virtual casacore::String name() const
Return the name of the machine.
virtual Type type()
Return the type enum.
casacore::Float padding_p
Padding in FFT.
Definition: rGridFT.h:222
casacore::Bool recordOnGrid(const VisBuffer &vb, casacore::Int rownr) const
Is this record on Grid? check both ends.
casacore::Bool usezero_p
Grid/degrid zero spacing points?
Definition: rGridFT.h:280
casacore::String convType
Definition: rGridFT.h:265
void put(const VisBuffer &vb, casacore::Int row=-1, casacore::Bool dopsf=false, FTMachine::Type type=FTMachine::OBSERVED)
Put coherence to grid by gridding.
void finalizeToSky()
Finalize transform to Sky plane: flushes the image cache and shows statistics if it is being used...
void initializeToSky(casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight, const VisBuffer &vb)
Initialize transform to Sky plane: initializes the image.
casacore::Vector< casacore::Double > uvOffset
Definition: rGridFT.h:273
casacore::Float maxAbsData
Definition: rGridFT.h:267
casacore::ImageInterface< casacore::Complex > * image
Definition: FTMachine.h:409
casacore::IPosition offsetLoc
Definition: rGridFT.h:270
casacore::Array< casacore::Complex > * getDataPointer(const casacore::IPosition &, casacore::Bool)
Get the appropriate data pointer.
casacore::Array< casacore::Complex > griddedData
casacore::Array for non-tiled gridding
Definition: rGridFT.h:277
long Long
Definition: aipstype.h:52
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
void getWeightImage(casacore::ImageInterface< casacore::Float > &, casacore::Matrix< casacore::Float > &)
Get the final weights image.
virtual void normalizeImage(casacore::Lattice< casacore::Complex > &skyImage, const casacore::Matrix< casacore::Double > &sumOfWts, casacore::Lattice< casacore::Float > &sensitivityImage, casacore::Bool fftNorm)
Definition: rGridFT.h:206
Type
Types of known Images that may be made using the makeImage method.
Definition: FTMachine.h:125
virtual void ComputeResiduals(VisBuffer &, casacore::Bool)
Make the VB and VBStore interefaces for the interim re-factoring work.
Definition: rGridFT.h:222
Converts UVW coordinates between coordinate systems.
Definition: UVWMachine.h:160
casacore::Long cachesize
Sizes.
Definition: rGridFT.h:249
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
float Float
Definition: aipstype.h:54
virtual casacore::Bool isFourier()
Can this FTMachine be represented by Fourier convolutions?
Definition: rGridFT.h:221
rGridFT & operator=(const rGridFT &other)
Assignment operator.
casacore::Int priorCacheSize
Definition: rGridFT.h:276
casacore::CountedPtr< casacore::Lattice< casacore::Complex > > lattice
Lattice.
Definition: rGridFT.h:263
casacore::Bool isTiled
Is this tiled?
Definition: rGridFT.h:256
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: rGridFT.h:226
casacore::IPosition centerLoc
Useful IPositions.
Definition: rGridFT.h:270
void initializeToVis(casacore::ImageInterface< casacore::Complex > &image, const VisBuffer &vb)
Initialize transform to Visibility plane using the image as a template.
virtual void setNoPadding(casacore::Bool nopad)
To make sure no padding is used in certain gridders.
Definition: rGridFT.h:223
casacore::Bool noPadding_p
force no padding
Definition: rGridFT.h:283
casacore::Vector< casacore::Double > uvScale
Image Scaling and offset.
Definition: rGridFT.h:273
Base class for all Casacore library errors.
Definition: Error.h:134
casacore::CountedPtr< casacore::Lattice< casacore::Complex > > arrayLattice
casacore::Array lattice
Definition: rGridFT.h:259
casacore::Int tilesize
Definition: rGridFT.h:250
casacore::Bool usePut2_p
Check if using put that avoids non-necessary reads.
Definition: rGridFT.h:286
String: the storage and methods of handling collections of characters.
Definition: String.h:223
rGridFT * clone()
Clone.
VisBuffers encapsulate one chunk of visibility data for processing.
Definition: VisBuffer.h:153
Abstract base class for Record classes.
rGridFT(casacore::Long cachesize, casacore::Int tilesize, casacore::String convType="SF", casacore::Float padding=1.0, casacore::Bool usezero=true, casacore::Bool useDoublePrec=false)
Constructor: cachesize is the size of the cache in words (e.g.
casacore::String machineName_p
machine name
Definition: rGridFT.h:289
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::Array< casacore::DComplex > griddedData2
Definition: rGridFT.h:278
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42