casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WProjectFT.h
Go to the documentation of this file.
1 //# WProjectFT.h: Definition for WProjectFT
2 //# Copyright (C) 2003-2016
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 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 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_WPROJECTFT_H
30 #define SYNTHESIS_TRANSFORM2_WPROJECTFT_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>
50 
51 namespace casacore{
52 
53 template <class K, class V> class SimpleOrderedMap;
54 template <class T> class PtrBlock;
55 template <class T> class CountedPtr;
56 }
57 
58 namespace casa { //# NAMESPACE CASA - BEGIN
59 
60 
61 namespace refim { //# namespace for imaging refactor
62 class WPConvFunc;
63 
64 // <summary> An FTMachine for Gridded Fourier transforms </summary>
65 
66 // <use visibility=export>
67 
68 // <reviewed reviewer="" date="" tests="" demos="">
69 
70 // <prerequisite>
71 // <li> <linkto class=FTMachine>FTMachine</linkto> module
72 // <li> <linkto class=SkyEquation>SkyEquation</linkto> module
73 // <li> <linkto class=VisBuffer>VisBuffer</linkto> module
74 // </prerequisite>
75 //
76 // <etymology>
77 // FTMachine is a Machine for Fourier Transforms. WProjectFT does
78 // Grid-based Fourier transforms.
79 // </etymology>
80 //
81 // <synopsis>
82 // The <linkto class=SkyEquation>SkyEquation</linkto> needs to be able
83 // to perform Fourier transforms on visibility data. WProjectFT
84 // allows efficient Fourier Transform processing using a
85 // <linkto class=VisBuffer>VisBuffer</linkto> which encapsulates
86 // a chunk of visibility (typically all baselines for one time)
87 // together with all the information needed for processing
88 // (e.g. UVW coordinates).
89 //
90 // Gridding and degridding in WProjectFT are performed using a
91 // novel sort-less algorithm. In this approach, the gridded plane is
92 // divided into small patches, a cache of which is maintained in memory
93 // using a general-purpose <linkto class=casacore::LatticeCache>LatticeCache</linkto> class. As the (time-sorted)
94 // visibility data move around slowly in the Fourier plane, patches are
95 // swapped in and out as necessary. Thus, optimally, one would keep at
96 // least one patch per baseline.
97 //
98 // A grid cache is defined on construction. If the gridded uv plane is smaller
99 // than this, it is kept entirely in memory and all gridding and
100 // degridding is done entirely in memory. Otherwise a cache of tiles is
101 // kept an paged in and out as necessary. Optimally the cache should be
102 // big enough to hold all polarizations and frequencies for all
103 // baselines. The paging rate will then be small. As the cache size is
104 // reduced below this critical value, paging increases. The algorithm will
105 // work for only one patch but it will be very slow!
106 //
107 // This scheme works well for arrays having a moderate number of
108 // antennas since the saving in space goes as the ratio of
109 // baselines to image size. For the ATCA, VLBA and WSRT, this ratio is
110 // quite favorable. For the VLA, one requires images of greater than
111 // about 200 pixels on a side to make it worthwhile.
112 //
113 // The FFT step is done plane by plane for images having less than
114 // 1024 * 1024 pixels on each plane, and line by line otherwise.
115 //
116 // The gridding and degridding steps are implemented in Fortran
117 // for speed. In gridding, the visibilities are added onto the
118 // grid points in the neighborhood using a weighting function.
119 // In degridding, the value is derived by a weight summ of the
120 // same points, using the same weighting function.
121 // </synopsis>
122 //
123 // <example>
124 // See the example for <linkto class=SkyModel>SkyModel</linkto>.
125 // </example>
126 //
127 // <motivation>
128 // Define an interface to allow efficient processing of chunks of
129 // visibility data
130 // </motivation>
131 //
132 // <todo asof="97/10/01">
133 // <ul> Deal with large VLA spectral line case
134 // </todo>
135 
136 class WProjectFT : public FTMachine {
137 public:
138 
139  // Constructor: cachesize is the size of the cache in words
140  // (e.g. a few million is a good number), tilesize is the
141  // size of the tile used in gridding (cannot be less than
142  // 12, 16 works in most cases).
143  // <group>
144  WProjectFT(
146  casacore::Bool usezero=true, casacore::Bool useDoublePrec=false, const casacore::Double minW=-1.0, const casacore::Double maxW=-1.0, const casacore::Double rmsW=-1.0);
147  //Constructor without tangent direction
148  WProjectFT(casacore::Int nFacets, casacore::MPosition mLocation,
149  casacore::Long cachesize, casacore::Int tilesize=16,
150  casacore::Bool usezero=true, casacore::Float padding=1.0, casacore::Bool useDoublePrec=false, const casacore::Double minW=-1.0, const casacore::Double maxW=-1.0, const casacore::Double rmsW=-1.0);
151  //Deprecated no longer need ms in constructor
152  WProjectFT(
153  casacore::Int nFacets, casacore::MDirection mTangent, casacore::MPosition mLocation,
154  casacore::Long cachesize, casacore::Int tilesize=16,
155  casacore::Bool usezero=true, casacore::Float padding=1.0, casacore::Bool useDoublePrec=false, const casacore::Double minW=-1.0, const casacore::Double maxW=-1.0, const casacore::Double rmsW=-1.0);
156  // </group>
157 
158  // Construct from a casacore::Record containing the WProjectFT state
159  WProjectFT(const casacore::RecordInterface& stateRec);
160 
161  // Copy constructor
162  WProjectFT(const WProjectFT &other);
163 
164  // Assignment operator
165  WProjectFT &operator=(const WProjectFT &other);
166 
167  ~WProjectFT();
168 
169  //clone to FTMachine pointer
170  virtual FTMachine* cloneFTM();
171  // Initialize transform to Visibility plane using the image
172  // as a template. The image is loaded and Fourier transformed.
174  const vi::VisBuffer2& vb);
175 
176  // Finalize transform to Visibility plane: flushes the image
177  // cache and shows statistics if it is being used.
178  void finalizeToVis();
179 
180  // Initialize transform to Sky plane: initializes the image
182  const vi::VisBuffer2& vb);
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  void finalizeToSky();
187 
188  // Get actual coherence from grid by degridding
189  void get(vi::VisBuffer2& vb, casacore::Int row=-1);
190 
191  // Put coherence to grid by gridding.
192  void put(const vi::VisBuffer2& vb, casacore::Int row=-1, casacore::Bool dopsf=false,
194 
195  // Make the entire image
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("WProjectFT::normalizeImage() called"));}
209 
210  // Get the final weights image
212 
213  // Save and restore the WProjectFT 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  casacore::Bool isFourier() {return true;}
220 
221 
222  // Return name of this machine
223 
224  casacore::String name() const;
225 
226  // Copy convolution function etc to another FT machine
227  // necessary if ft and ift are distinct but can share convfunctions
228 
231  virtual void setMiscInfo(const casacore::Int qualifier){(void)qualifier;};
232  virtual void ComputeResiduals(vi::VisBuffer2& /*vb*/, casacore::Bool /*useCorrected*/) {};
233  //Helper function to calculate min, max, rms of W in the data set
234  static void wStat(vi::VisibilityIterator2& vi, casacore::Double& minW, casacore::Double& maxW, casacore::Double& rmsW);
235 
236 protected:
237 
238  // Padding in FFT
240 
242 
243  // Find the convolution function
245  const vi::VisBuffer2& vb);
246 
248 
249  // Get the appropriate data pointer
251 
252  void ok();
253 
254  void init();
255 
256  void prepGridForDegrid();
257  // Is this record on Grid? check both ends. This assumes that the
258  // ends bracket the middle
259  //casacore::Bool recordOnGrid(const vi::VisBuffer2& vb, casacore::Int rownr) const;
260 
261 
262  // Image cache
264 
265  // Sizes
268 
269  // Gridder
271 
272  // Is this tiled?
274 
275  // casacore::Array lattice
277 
278  // Lattice. For non-tiled gridding, this will point to arrayLattice,
279  // whereas for tiled gridding, this points to the image
281 
283 
284  // Useful IPositions
286 
287  // Image Scaling and offset
290 
291 
292  // Grid/degrid zero spacing points?
294 
299 
301 
302 
304 
306 
308  const casacore::Double& interval);
309 
311 
315 };
316 } // end namespace refim
317 } //# NAMESPACE CASA - END
318 
319 #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
int Int
Definition: aipstype.h:50
void getWeightImage(casacore::ImageInterface< casacore::Float > &, casacore::Matrix< casacore::Float > &)
Get the final weights image.
defines interface for the Fourier Transform Machine
Definition: FTMachine.h:122
casacore::Vector< casacore::Int > convSupport
Definition: WProjectFT.h:298
An FTMachine for Gridded Fourier transforms.
Definition: WProjectFT.h:136
VisibilityIterator2 iterates through one or more readonly MeasurementSets.
casacore::Int nint(casacore::Double val)
Definition: WProjectFT.h:241
static void wStat(vi::VisibilityIterator2 &vi, casacore::Double &minW, casacore::Double &maxW, casacore::Double &rmsW)
Helper function to calculate min, max, rms of W in the data set.
casacore::Bool usezero_p
Grid/degrid zero spacing points?
Definition: WProjectFT.h:293
casacore::Cube< casacore::Complex > convFunc
Definition: WProjectFT.h:295
casacore::Int convSize
Definition: WProjectFT.h:297
virtual Type type()
Return the type enum.
casacore::CountedPtr< WPConvFunc > wpConvFunc_p
Definition: WProjectFT.h:312
casacore::Double rmsW_p
Definition: WProjectFT.h:314
casacore::String name() const
Return name of this machine.
virtual void normalizeImage(casacore::Lattice< casacore::Complex > &, const casacore::Matrix< casacore::Double > &, casacore::Lattice< casacore::Float > &, casacore::Bool)
Definition: WProjectFT.h:204
casacore::Double minW_p
Definition: WProjectFT.h:314
ABSTRACT TOOL CLASSES A PlotTool is a higher level event handler for a PlotCanvas The idea is to take common tasks which may require multiple events and put them in one place PlotTools also provide additional functionality in that they can be active and blocking non blocking The PlotCanvas will only send events to active and will not send events to later tools or event handlers if the latest tool was blocking In this way a single tool can be used to handle ALL user interaction via the GUI at one time
Definition: PlotTool.h:43
casacore::Double timemass_p
Definition: WProjectFT.h:313
casacore::IPosition centerLoc
Useful IPositions.
Definition: WProjectFT.h:285
casacore::Int tilesize
Definition: WProjectFT.h:267
casacore::Vector< casacore::Double > uvScale
Image Scaling and offset.
Definition: WProjectFT.h:288
void setConvFunc(casacore::CountedPtr< WPConvFunc > &pbconvFunc)
Copy convolution function etc to another FT machine necessary if ft and ift are distinct but can shar...
void findConvFunction(const casacore::ImageInterface< casacore::Complex > &image, const vi::VisBuffer2 &vb)
Find the convolution function.
casacore::Array< casacore::Complex > * getDataPointer(const casacore::IPosition &, casacore::Bool)
Get the appropriate data pointer.
WProjectFT(casacore::Int nFacets, casacore::Long cachesize, casacore::Int tilesize=16, casacore::Bool usezero=true, casacore::Bool useDoublePrec=false, const casacore::Double minW=-1.0, const casacore::Double maxW=-1.0, const casacore::Double rmsW=-1.0)
Constructor: cachesize is the size of the cache in words (e.g.
void finalizeToSky()
Finalize transform to Sky plane: flushes the image cache and shows statistics if it is being used...
void makeImage(FTMachine::Type type, vi::VisibilityIterator2 &vi, casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight)
Make the entire image.
LatticeExprNode floor(const LatticeExprNode &expr)
casacore::Bool toRecord(casacore::String &error, casacore::RecordInterface &outRec, casacore::Bool withImage=false, const casacore::String diskimage="")
Save and restore the WProjectFT to and from a record.
casacore::CountedPtr< casacore::Lattice< casacore::Complex > > arrayLattice
casacore::Array lattice
Definition: WProjectFT.h:276
casacore::Vector< casacore::Double > uvOffset
Definition: WProjectFT.h:288
void finalizeToVis()
Finalize transform to Visibility plane: flushes the image cache and shows statistics if it is being u...
casacore::Int lastIndex_p
Definition: WProjectFT.h:305
long Long
Definition: aipstype.h:52
casacore::CountedPtr< casacore::Lattice< casacore::Complex > > lattice
Lattice.
Definition: WProjectFT.h:280
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...
Simple map with keys ordered.
Definition: WProjectFT.h:53
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
casacore::Int getIndex(const casacore::ROMSPointingColumns &mspc, const casacore::Double &time, const casacore::Double &interval)
casacore::Double maxW_p
Definition: WProjectFT.h:314
void initializeToVis(casacore::ImageInterface< casacore::Complex > &image, const vi::VisBuffer2 &vb)
Initialize transform to Visibility plane using the image as a template.
A class to provide easy read-only access to MSPointing columns.
casacore::Int convSampling
Definition: WProjectFT.h:296
double Double
Definition: aipstype.h:55
casacore::CountedPtr< WPConvFunc > & getConvFunc()
casacore::Float maxAbsData
Definition: WProjectFT.h:282
Type
Types of known Images that may be made using the makeImage method.
Definition: FTMachine.h:127
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::IPosition offsetLoc
Definition: WProjectFT.h:285
float Float
Definition: aipstype.h:54
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.
casacore::Bool fromRecord(casacore::String &error, const casacore::RecordInterface &inRec)
virtual FTMachine * cloneFTM()
clone to FTMachine pointer
A drop-in replacement for Block&lt;T*&gt;.
Definition: WProjectFT.h:54
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: WProjectFT.h:231
casacore::Int nWPlanes_p
Definition: WProjectFT.h:247
casacore::Vector< casacore::Int > convSizes_p
Definition: WProjectFT.h:300
casacore::Int wConvSize
Definition: WProjectFT.h:303
casacore::LatticeCache< casacore::Complex > * imageCache
Is this record on Grid? check both ends.
Definition: WProjectFT.h:263
casacore::Double timedegrid_p
Definition: WProjectFT.h:313
VisBuffer2s encapsulate one chunk of visibility data for processing.
Definition: VisBuffer2.h:141
WProjectFT & operator=(const WProjectFT &other)
Assignment operator.
casacore::Double savedWScale_p
Definition: WProjectFT.h:289
Base class for all Casacore library errors.
Definition: Error.h:134
void initializeToSky(casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight, const vi::VisBuffer2 &vb)
Initialize transform to Sky plane: initializes the image.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::String machineName_p
Definition: WProjectFT.h:310
Abstract base class for Record classes.
virtual void ComputeResiduals(vi::VisBuffer2 &, casacore::Bool)
Make the VB and VBStore interefaces for the interim re-factoring work.
Definition: WProjectFT.h:232
casacore::Float padding_p
Padding in FFT.
Definition: WProjectFT.h:239
casacore::Bool isTiled
Is this tiled?
Definition: WProjectFT.h:273
casacore::ImageInterface< casacore::Complex > * image
Definition: FTMachine.h:395
casacore::Long cachesize
Sizes.
Definition: WProjectFT.h:266
casacore::Bool isFourier()
Can this FTMachine be represented by Fourier convolutions?
Definition: WProjectFT.h:219
casacore::Double timegrid_p
Definition: WProjectFT.h:313
casacore::ConvolveGridder< casacore::Double, casacore::Complex > * gridder
Gridder.
Definition: WProjectFT.h:270
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42