casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GridBoth.h
Go to the documentation of this file.
1 //# GridBoth.h: Definition for GridBoth
2 //# Copyright (C) 1996,1997,1998,1999,2000,2001,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_GRIDBOTH_H
30 #define SYNTHESIS_GRIDBOTH_H
31 
34 
35 namespace casacore{
36 
37 template<class T> class TempImage;
38 }
39 
40 namespace casa { //# NAMESPACE CASA - BEGIN
41 
42 // <summary> An FTMachine for Gridding Single Dish data
43 // </summary>
44 
45 // <use visibility=export>
46 
47 // <reviewed reviewer="" date="" tests="" demos="">
48 
49 // <prerequisite>
50 // <li> <linkto class=FTMachine>FTMachine</linkto> module
51 // <li> <linkto class=SkyEquation>SkyEquation</linkto> module
52 // <li> <linkto class=VisBuffer>VisBuffer</linkto> module
53 // </prerequisite>
54 //
55 // <etymology>
56 // FTMachine is a Machine for Fourier Transforms. GridBoth does
57 // Single Dish gridding in a similar way
58 // </etymology>
59 //
60 // <synopsis>
61 // The <linkto class=SkyEquation>SkyEquation</linkto> needs to be able
62 // to perform Fourier transforms on visibility data and to grid
63 // single dish data.
64 // GridBoth allows efficient Single Dish processing using a
65 // <linkto class=VisBuffer>VisBuffer</linkto> which encapsulates
66 // a chunk of visibility (typically all baselines for one time)
67 // together with all the information needed for processing
68 // (e.g. direction coordinates).
69 //
70 // Gridding and degridding in GridBoth are performed using a
71 // novel sort-less algorithm. In this approach, the gridded plane is
72 // divided into small patches, a cache of which is maintained in memory
73 // using a general-purpose <linkto class=casacore::LatticeCache>LatticeCache</linkto> class. As the (time-sorted)
74 // visibility data move around slowly in the image plane, patches are
75 // swapped in and out as necessary. Thus, optimally, one would keep at
76 // least one patch per scan line of data.
77 //
78 // A grid cache is defined on construction. If the gridded image plane is smaller
79 // than this, it is kept entirely in memory and all gridding and
80 // degridding is done entirely in memory. Otherwise a cache of tiles is
81 // kept an paged in and out as necessary. Optimally the cache should be
82 // big enough to hold all polarizations and frequencies for one
83 // complete scan line.
84 // The paging rate will then be small. As the cache size is
85 // reduced below this critical value, paging increases. The algorithm will
86 // work for only one patch but it will be very slow!
87 //
88 // The gridding and degridding steps are implemented in Fortran
89 // for speed. In gridding, the visibilities are added onto the
90 // grid points in the neighborhood using a weighting function.
91 // In degridding, the value is derived by a weight summ of the
92 // same points, using the same weighting function.
93 // </synopsis>
94 //
95 // <example>
96 // See the example for <linkto class=SkyModel>SkyModel</linkto>.
97 // </example>
98 //
99 // <motivation>
100 // Define an interface to allow efficient processing of chunks of
101 // visibility data
102 // </motivation>
103 //
104 // <todo asof="97/10/01">
105 // <ul> Deal with large VLA spectral line case
106 // </todo>
107 
108 
109 class GridBoth : public FTMachine {
110 public:
111 
112  // Constructor: cachesize is the size of the cache in words
113  // (e.g. a few million is a good number), tilesize is the
114  // size of the tile used in gridding (cannot be less than
115  // 12, 16 works in most cases), and convType is the type of
116  // gridding used (SF is prolate spheriodal wavefunction,
117  // and BOX is plain box-car summation). mLocation is
118  // the position to be used in some phase rotations. If
119  // mTangent is specified then the uvw rotation is done for
120  // that location iso the image center.
121  // <group>
122  GridBoth(SkyJones& sj, casacore::Long cachesize, casacore::Int tilesize,
123  casacore::String sdConvType="BOX",
124  casacore::String synConvType="SF",
125  casacore::Float padding=1.0,
126  casacore::Float sdScale=1.0,
127  casacore::Float sdWeight=1.0);
128  GridBoth(SkyJones& sj, casacore::Long cachesize, casacore::Int tilesize,
129  casacore::MPosition mLocation,
130  casacore::String sdConvType="BOX",
131  casacore::String synConvType="SF",
132  casacore::Float padding=1.0,
133  casacore::Float sdScale=1.0,
134  casacore::Float sdWeight=1.0);
135  GridBoth(SkyJones& sj, casacore::Long cachesize, casacore::Int tilesize,
136  casacore::MPosition mLocation, casacore::MDirection mTangent,
137  casacore::String sdConvType="BOX",
138  casacore::String synConvType="SF",
139  casacore::Float padding=1.0,
140  casacore::Float sdScale=1.0,
141  casacore::Float sdWeight=1.0);
142  // </group>
143 
144  // Copy constructor
145  GridBoth(const GridBoth &other);
146 
147  // Assignment operator
148  GridBoth &operator=(const GridBoth &other);
149 
150  ~GridBoth();
151 
152  // Construct from a casacore::Record containing the GridFT state
153  GridBoth(const casacore::RecordInterface& stateRec);
154 
155  // Initialize transform to Visibility plane using the image
156  // as a template. The image is loaded and Fourier transformed.
158  const VisBuffer& vb);
159 
160  // Finalize transform to Visibility plane: flushes the image
161  // cache and shows statistics if it is being used.
162  void finalizeToVis();
163 
164  // Initialize transform to Sky plane: initializes the image
166  const VisBuffer& vb);
167 
168  // Finalize transform to Sky plane: flushes the image
169  // cache and shows statistics if it is being used. DOES NOT
170  // DO THE FINAL TRANSFORM!
171  void finalizeToSky();
172 
173  // Get actual coherence from grid by degridding
174  void get(VisBuffer& vb, casacore::Int row=-1);
175 
176  // Put coherence to grid by gridding.
177  void put(const VisBuffer& vb, casacore::Int row=-1, casacore::Bool dopsf=false,
179 
180  // Get the final image: do the Fourier transform and
181  // grid-correct, then optionally normalize by the summed weights
184  const casacore::Matrix<casacore::Double>& /*sumOfWts*/,
185  casacore::Lattice<casacore::Float>& /*sensitivityImage*/,
186  casacore::Bool /*fftNorm*/)
187  {throw(casacore::AipsError("GridBoth::normalizeImage() called"));}
188 
189  // Get the final weights image
191 
192  // Save and restore the GridFT to and from a record
194  casacore::Bool withImage=false, const casacore::String diskimage="");
196 
197  // Has this operator changed since the last application?
198  virtual casacore::Bool changed(const VisBuffer& vb);
199  virtual void setMiscInfo(const casacore::Int qualifier){(void)qualifier;};
200  virtual void ComputeResiduals(VisBuffer&/*vb*/, casacore::Bool /*useCorrected*/) {};
201  virtual casacore::String name() const { return "GridBoth";};
202 
203 private:
204 
205  FTMachine* synMachine_p; // Synthesis machine
206  FTMachine* sdMachine_p; // Single Dish machine
207  FTMachine* lastMachine_p; // Last Machine used
208 
209  // Images for Synthesis and SD
212 
214 
215  void ok();
216 
217  void init();
218 
219 };
220 
221 } //# NAMESPACE CASA - END
222 
223 #endif
A Measure: astronomical direction.
Definition: MDirection.h:174
void initializeToVis(casacore::ImageInterface< casacore::Complex > &image, const VisBuffer &vb)
Initialize transform to Visibility plane using the image as a template.
A Measure: position on Earth.
Definition: MPosition.h:79
int Int
Definition: aipstype.h:50
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...
Temporary astronomical images.
void getWeightImage(casacore::ImageInterface< casacore::Float > &, casacore::Matrix< casacore::Float > &)
Get the final weights image.
void finalizeToVis()
Finalize transform to Visibility plane: flushes the image cache and shows statistics if it is being u...
void initializeToSky(casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight, const VisBuffer &vb)
Initialize transform to Sky plane: initializes the image.
virtual Type type()
Return the type enum.
casacore::ImageInterface< casacore::Complex > * image
Definition: FTMachine.h:409
casacore::TempImage< casacore::Complex > * synImage_p
Definition: GridBoth.h:211
FTMachine * synMachine_p
Definition: GridBoth.h:201
void put(const VisBuffer &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
FTMachine * sdMachine_p
Definition: GridBoth.h:206
void finalizeToSky()
Finalize transform to Sky plane: flushes the image cache and shows statistics if it is being used...
Type
Types of known Images that may be made using the makeImage method.
Definition: FTMachine.h:125
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
GridBoth(SkyJones &sj, casacore::Long cachesize, casacore::Int tilesize, casacore::String sdConvType="BOX", casacore::String synConvType="SF", casacore::Float padding=1.0, casacore::Float sdScale=1.0, casacore::Float sdWeight=1.0)
Constructor: cachesize is the size of the cache in words (e.g.
float Float
Definition: aipstype.h:54
GridBoth & operator=(const GridBoth &other)
Assignment operator.
casacore::Float sdWeight_p
Definition: GridBoth.h:213
An FTMachine for Gridding Single Dish data.
Definition: GridBoth.h:109
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.
FTMachine * lastMachine_p
Definition: GridBoth.h:207
virtual casacore::Bool fromRecord(casacore::String &error, const casacore::RecordInterface &inRec)
Sky Jones: Model sky-plane instrumental effects for the SkyEquation.
Definition: SkyJones.h:172
Base class for all Casacore library errors.
Definition: Error.h:134
casacore::Float sdScale_p
Definition: GridBoth.h:213
virtual void ComputeResiduals(VisBuffer &, casacore::Bool)
Make the VB and VBStore interefaces for the interim re-factoring work.
Definition: GridBoth.h:200
virtual void normalizeImage(casacore::Lattice< casacore::Complex > &, const casacore::Matrix< casacore::Double > &, casacore::Lattice< casacore::Float > &, casacore::Bool)
Definition: GridBoth.h:183
casacore::TempImage< casacore::Complex > * sdImage_p
Images for Synthesis and SD.
Definition: GridBoth.h:210
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
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: GridBoth.h:199
Abstract base class for Record classes.
virtual casacore::Bool changed(const VisBuffer &vb)
Has this operator changed since the last application?
virtual casacore::String name() const
Return the name of the machine.
Definition: GridBoth.h:201
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