casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MosaicFT.h
Go to the documentation of this file.
1 //# MosaicFT.h: Definition for MosaicFT
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_MOSAICFT_H
30 #define SYNTHESIS_MOSAICFT_H
31 
34 #include <casa/Arrays/Matrix.h>
36 #include <msvis/MSVis/VisBuffer.h>
39 #include <casa/Containers/Block.h>
40 #include <casa/Arrays/Array.h>
41 #include <casa/Arrays/Vector.h>
51 
52 namespace casacore{
53 
54  class MPosition;
55  class UVWMachine;
56 }
57 
58 namespace casa { //# NAMESPACE CASA - BEGIN
59 
60 // <summary> An FTMachine for Gridded Fourier transforms </summary>
61 
62 // <use visibility=export>
63 
64 // <reviewed reviewer="" date="" tests="" demos="">
65 
66 // <prerequisite>
67 // <li> <linkto class=FTMachine>FTMachine</linkto> module
68 // <li> <linkto class=SkyEquation>SkyEquation</linkto> module
69 // <li> <linkto class=VisBuffer>VisBuffer</linkto> module
70 // </prerequisite>
71 //
72 // <etymology>
73 // FTMachine is a Machine for Fourier Transforms. MosaicFT does
74 // Grid-based Fourier transforms.
75 // </etymology>
76 //
77 // <synopsis>
78 // The <linkto class=SkyEquation>SkyEquation</linkto> needs to be able
79 // to perform Fourier transforms on visibility data. MosaicFT
80 // allows efficient Fourier Transform processing using a
81 // <linkto class=VisBuffer>VisBuffer</linkto> which encapsulates
82 // a chunk of visibility (typically all baselines for one time)
83 // together with all the information needed for processing
84 // (e.g. UVW coordinates).
85 //
86 // Gridding and degridding in MosaicFT are performed using a
87 // novel sort-less algorithm. In this approach, the gridded plane is
88 // divided into small patches, a cache of which is maintained in memory
89 // using a general-purpose <linkto class=casacore::LatticeCache>LatticeCache</linkto> class. As the (time-sorted)
90 // visibility data move around slowly in the Fourier plane, patches are
91 // swapped in and out as necessary. Thus, optimally, one would keep at
92 // least one patch per baseline.
93 //
94 // A grid cache is defined on construction. If the gridded uv plane is smaller
95 // than this, it is kept entirely in memory and all gridding and
96 // degridding is done entirely in memory. Otherwise a cache of tiles is
97 // kept an paged in and out as necessary. Optimally the cache should be
98 // big enough to hold all polarizations and frequencies for all
99 // baselines. The paging rate will then be small. As the cache size is
100 // reduced below this critical value, paging increases. The algorithm will
101 // work for only one patch but it will be very slow!
102 //
103 // This scheme works well for arrays having a moderate number of
104 // antennas since the saving in space goes as the ratio of
105 // baselines to image size. For the ATCA, VLBA and WSRT, this ratio is
106 // quite favorable. For the VLA, one requires images of greater than
107 // about 200 pixels on a side to make it worthwhile.
108 //
109 // The FFT step is done plane by plane for images having less than
110 // 1024 * 1024 pixels on each plane, and line by line otherwise.
111 //
112 // The gridding and degridding steps are implemented in Fortran
113 // for speed. In gridding, the visibilities are added onto the
114 // grid points in the neighborhood using a weighting function.
115 // In degridding, the value is derived by a weight summ of the
116 // same points, using the same weighting function.
117 // </synopsis>
118 //
119 // <example>
120 // See the example for <linkto class=SkyModel>SkyModel</linkto>.
121 // </example>
122 //
123 // <motivation>
124 // Define an interface to allow efficient processing of chunks of
125 // visibility data
126 // </motivation>
127 //
128 // <todo asof="97/10/01">
129 // <ul> Deal with large VLA spectral line case
130 // </todo>
131  class MosaicFT;
132  class SimplePBConvFunc;
133 
134 
135 class MosaicFT : public FTMachine {
136 public:
137 
138  // Constructor: cachesize is the size of the cache in words
139  // (e.g. a few million is a good number), tilesize is the
140  // size of the tile used in gridding (cannot be less than
141  // 12, 16 works in most cases).
142  // <group>
145  casacore::Bool usezero=true, casacore::Bool useDoublePrec=false);
146  // </group>
147 
148  // Construct from a casacore::Record containing the MosaicFT state
149  MosaicFT(const casacore::RecordInterface& stateRec);
150 
151  // Copy constructor--convolution function is referenced
152  MosaicFT(const MosaicFT &other);
153 
154  // Assignment operator -- convolution function is referenced
155  MosaicFT &operator=(const MosaicFT &other);
156 
157  ~MosaicFT();
158 
159  // Initialize transform to Visibility plane using the image
160  // as a template. The image is loaded and Fourier transformed.
162  const VisBuffer& vb);
163 
164  // Finalize transform to Visibility plane: flushes the image
165  // cache and shows statistics if it is being used.
166  void finalizeToVis();
167 
168  // Initialize transform to Sky plane: initializes the image
170  const VisBuffer& vb);
172 
173  // Finalize transform to Sky plane: flushes the image
174  // cache and shows statistics if it is being used. DOES NOT
175  // DO THE FINAL TRANSFORM!
177 
178  // Get actual coherence from grid by degridding
179  void get(VisBuffer& vb, casacore::Int row=-1);
180 
181 
182  // Put coherence to grid by gridding.
183  void put(const VisBuffer& vb, casacore::Int row=-1, casacore::Bool dopsf=false,
185 
186  // Make the entire image
188  VisSet& vs,
191 
192  // Get the final image: do the Fourier transform and
193  // grid-correct, then optionally normalize by the summed weights
196  const casacore::Matrix<casacore::Double>& /*sumOfWts*/,
197  casacore::Lattice<casacore::Float>& /*sensitivityImage*/,
198  casacore::Bool /*fftNorm*/)
199  {throw(casacore::AipsError("MosaicFT::normalizeImage() called"));}
200 
201 
202  // Get the final weights image
204 
205  // Get a flux (divide by this to get a flux density correct image)
206  // image if there is one
208 
209  // Save and restore the MosaicFT to and from a record
210 
212  casacore::Bool withImage=false, const casacore::String diskimage="");
214 
215  // Can this FTMachine be represented by Fourier convolutions?
216  casacore::Bool isFourier() {return true;}
217 
218  // Return name of this machine
219 
220  virtual casacore::String name() const;
221  virtual casacore::Bool useWeightImage(){return true;};
222 
223 
224  // Copy convolution function etc to another FT machine
225  // necessary if ft and ift are distinct but can share convfunctions
226 
229 
231 
232  //reset weight image
233  virtual void reset();
234  virtual void setMiscInfo(const casacore::Int qualifier){(void)qualifier;};
235  virtual void ComputeResiduals(VisBuffer&/*vb*/, casacore::Bool /*useCorrected*/) {};
236 
237 protected:
238 
240 
241  // Find the convolution function
243  const VisBuffer& vb);
244 
245  // void girarUVW(casacore::Matrix<casacore::Double>& uvw, casacore::Vector<casacore::Double>& dphase,
246  // const VisBuffer& vb);
247 
249  void prepGridForDegrid();
250 
252 
253 
254  // Get the appropriate data pointer
256 
257  void ok();
258 
259  void init();
260 
261  // Is this record on Grid? check both ends. This assumes that the
262  // ends bracket the middle
263  casacore::Bool recordOnGrid(const VisBuffer& vb, casacore::Int rownr) const;
264 
265 
266  // Image cache
268 
269  // Sizes
272 
273  // Gridder
275 
276  // Is this tiled?
278 
279  // casacore::Array lattice
281 
282  // Lattice. For non-tiled gridding, this will point to arrayLattice,
283  // whereas for tiled gridding, this points to the image
286 
288 
289  // Useful IPositions
291 
292  // Image Scaling and offset
294 
295  // casacore::Array for non-tiled gridding
298  // Pointing columns
300 
301  // Antenna columns
303 
305 
307 
309 
311 
313 
314  // Grid/degrid zero spacing points?
316 
327 
329 
331 
333  const casacore::Double& interval);
334 
336 
337 
341  //Later this
345 
346 
347 };
348 
349 } //# NAMESPACE CASA - END
350 
351 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
casacore::IPosition centerLoc
Useful IPositions.
Definition: MosaicFT.h:290
void findConvFunction(const casacore::ImageInterface< casacore::Complex > &image, const VisBuffer &vb)
Find the convolution function.
A Measure: astronomical direction.
Definition: MDirection.h:174
A Measure: position on Earth.
Definition: MPosition.h:79
int Int
Definition: aipstype.h:50
casacore::Int convSampling
Definition: MosaicFT.h:319
void prepGridForDegrid()
casacore::Vector< casacore::Int > convSizePlanes_p
Definition: MosaicFT.h:323
casacore::CountedPtr< SimplePBConvFunc > & getConvFunc()
virtual casacore::String name() const
Return name of this machine.
MosaicFT & operator=(const MosaicFT &other)
Assignment operator – convolution function is referenced.
casacore::String stokes_p
Definition: MosaicFT.h:344
casacore::Vector< casacore::Double > uvOffset
Definition: MosaicFT.h:293
casacore::Vector< casacore::Int > convPolMap_p
Definition: MosaicFT.h:326
casacore::CountedPtr< SimplePBConvFunc > pbConvFunc_p
Definition: MosaicFT.h:340
SkyJones * sj_p
Definition: MosaicFT.h:251
casacore::Int convSize
Definition: MosaicFT.h:320
casacore::Array< casacore::Complex > weightConvFunc_p
Definition: MosaicFT.h:318
virtual Type type()
Return the type enum.
casacore::Int wConvSize
Definition: MosaicFT.h:328
casacore::Array< casacore::Complex > convFunc
Definition: MosaicFT.h:317
casacore::String machineName_p
Later this.
Definition: MosaicFT.h:342
virtual void normalizeImage(casacore::Lattice< casacore::Complex > &, const casacore::Matrix< casacore::Double > &, casacore::Lattice< casacore::Float > &, casacore::Bool)
Definition: MosaicFT.h:195
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
void setConvFunc(casacore::CountedPtr< SimplePBConvFunc > &pbconvFunc)
Copy convolution function etc to another FT machine necessary if ft and ift are distinct but can shar...
A class to provide easy read-write access to MSPointing columns.
casacore::Int getIndex(const casacore::ROMSPointingColumns &mspc, const casacore::Double &time, const casacore::Double &interval)
casacore::Bool toRecord(casacore::String &error, casacore::RecordInterface &outRec, casacore::Bool withImage=false, const casacore::String diskimage="")
Save and restore the MosaicFT to and from a record.
casacore::ImageInterface< casacore::Complex > * image
Definition: FTMachine.h:409
casacore::MDirection worldPosMeas
Definition: MosaicFT.h:310
casacore::Int priorCacheSize
Definition: MosaicFT.h:312
casacore::Vector< casacore::Double > xyPos
Definition: MosaicFT.h:308
casacore::Bool usezero_p
Grid/degrid zero spacing points?
Definition: MosaicFT.h:315
virtual void ComputeResiduals(VisBuffer &, casacore::Bool)
Make the VB and VBStore interefaces for the interim re-factoring work.
Definition: MosaicFT.h:235
casacore::LatticeCache< casacore::Complex > * imageCache
Image cache.
Definition: MosaicFT.h:267
void addBeamCoverage(casacore::ImageInterface< casacore::Complex > &image)
void girarUVW(casacore::Matrix&lt;casacore::Double&gt;&amp; uvw, casacore::Vector&lt;casacore::Double&gt;&amp; dphase...
LatticeExprNode floor(const LatticeExprNode &expr)
void getWeightImage(casacore::ImageInterface< casacore::Float > &, casacore::Matrix< casacore::Float > &)
Get the final weights image.
virtual void getFluxImage(casacore::ImageInterface< casacore::Float > &image)
Get a flux (divide by this to get a flux density correct image) image if there is one...
long Long
Definition: aipstype.h:52
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: MosaicFT.h:234
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
A class to provide easy read-only access to MSPointing columns.
Interconvert pixel positions and directions (e.g. RA/DEC).
casacore::Vector< casacore::Double > uvScale
Image Scaling and offset.
Definition: MosaicFT.h:293
double Double
Definition: aipstype.h:55
void finalizeToVis()
Finalize transform to Visibility plane: flushes the image cache and shows statistics if it is being u...
casacore::Float maxAbsData
Definition: MosaicFT.h:287
MosaicFT(SkyJones *sj, casacore::MPosition mloc, casacore::String stokes, casacore::Long cachesize, casacore::Int tilesize=16, casacore::Bool usezero=true, casacore::Bool useDoublePrec=false)
Constructor: cachesize is the size of the cache in words (e.g.
Type
Types of known Images that may be made using the makeImage method.
Definition: FTMachine.h:125
casacore::Array< casacore::Complex > * getDataPointer(const casacore::IPosition &, casacore::Bool)
Get the appropriate data pointer.
casacore::Bool isTiled
Is this tiled?
Definition: MosaicFT.h:277
casacore::MSPointingColumns * mspc
Pointing columns.
Definition: MosaicFT.h:299
Converts UVW coordinates between coordinate systems.
Definition: UVWMachine.h:160
casacore::Bool isFourier()
Can this FTMachine be represented by Fourier convolutions?
Definition: MosaicFT.h:216
A class to provide easy read-write access to MSAntenna columns.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void put(const VisBuffer &vb, casacore::Int row=-1, casacore::Bool dopsf=false, FTMachine::Type type=FTMachine::OBSERVED)
Put coherence to grid by gridding.
casacore::Vector< casacore::Int > convSupportPlanes_p
Definition: MosaicFT.h:322
casacore::TempImage< casacore::Complex > * convWeightImage_p
Definition: MosaicFT.h:339
float Float
Definition: aipstype.h:54
casacore::CountedPtr< casacore::Lattice< casacore::Complex > > arrayLattice
casacore::Array lattice
Definition: MosaicFT.h:280
casacore::CountedPtr< casacore::Lattice< casacore::Complex > > weightLattice
Definition: MosaicFT.h:285
casacore::CountedPtr< casacore::TempImage< casacore::Float > > skyCoverage_p
Definition: MosaicFT.h:338
casacore::Vector< casacore::Int > convChanMap_p
Definition: MosaicFT.h:325
virtual void finalizeToSky()=0
Finalize transform to Sky plane
casacore::Array< casacore::DComplex > griddedWeight2
Definition: MosaicFT.h:297
casacore::Int nint(casacore::Double val)
Definition: MosaicFT.h:239
casacore::Array< casacore::Complex > griddedWeight
casacore::Array for non-tiled gridding
Definition: MosaicFT.h:296
void initializeToSky(casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight, const VisBuffer &vb)
Initialize transform to Sky plane: initializes the image.
Sky Jones: Model sky-plane instrumental effects for the SkyEquation.
Definition: SkyJones.h:172
void makeImage(FTMachine::Type type, VisSet &vs, casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight)
Make the entire image.
casacore::Bool doneWeightImage_p
Definition: MosaicFT.h:343
Base class for all Casacore library errors.
Definition: Error.h:134
casacore::Int lastIndex_p
Definition: MosaicFT.h:330
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 casacore::Bool useWeightImage()
All FTMachines that fill weightimage, need to set this.
Definition: MosaicFT.h:221
casacore::CountedPtr< casacore::TempImage< casacore::Float > > & getConvWeightImage()
void initializeToVis(casacore::ImageInterface< casacore::Complex > &image, const VisBuffer &vb)
Initialize transform to Visibility plane using the image as a template.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Int tilesize
Definition: MosaicFT.h:271
casacore::ConvolveGridder< casacore::Double, casacore::Complex > * gridder
Gridder.
Definition: MosaicFT.h:274
VisBuffers encapsulate one chunk of visibility data for processing.
Definition: VisBuffer.h:153
virtual void reset()
reset weight image
casacore::CountedPtr< casacore::Lattice< casacore::Complex > > lattice
Lattice.
Definition: MosaicFT.h:284
Abstract base class for Record classes.
casacore::Vector< casacore::Int > convRowMap_p
Definition: MosaicFT.h:324
casacore::DirectionCoordinate directionCoord
Definition: MosaicFT.h:304
casacore::Int convSupport
Definition: MosaicFT.h:321
casacore::Long cachesize
Sizes.
Definition: MosaicFT.h:270
casacore::Bool getXYPos(const VisBuffer &vb, casacore::Int row)
casacore::IPosition offsetLoc
Definition: MosaicFT.h:290
casacore::MDirection::Convert * pointingToImage
Definition: MosaicFT.h:306
casacore::MSAntennaColumns * msac
Antenna columns.
Definition: MosaicFT.h:302
casacore::Bool recordOnGrid(const VisBuffer &vb, casacore::Int rownr) const
Is this record on Grid? check both ends.
casacore::Bool fromRecord(casacore::String &error, const casacore::RecordInterface &inRec)
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