casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WOnlyProjectFT.h
Go to the documentation of this file.
1 //# WOnlyProjectFT.h: Definition for WOnlyProjectFT
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_WONLYPROJECTFT_H
30 #define SYNTHESIS_WONLYPROJECTFT_H
31 
32 #include <synthesis/MeasurementComponents/VLACalcIlluminationConvFunc.h>
33 #include <synthesis/MeasurementComponents/VLAIlluminationConvFunc.h>
34 //#include <synthesis/TransformMachines/ConvolutionFunction.h>
35 #include <synthesis/MeasurementComponents/EVLAConvFunc.h>
39 //#include <synthesis/TransformMachines/CFCache.h>
41 
43 #include <msvis/MSVis/VisBuffer.h>
44 
45 #include <casa/Containers/Block.h>
46 #include <casa/Arrays/Array.h>
47 #include <casa/Arrays/Vector.h>
48 #include <casa/Arrays/Matrix.h>
49 
59 
60 namespace casa { //# NAMESPACE CASA - BEGIN
61 
62  // <summary> An FTMachine for Gridded Fourier transforms including effects of primary beam and pointing offsets and the w-term</summary>
63 
64  // <use visibility=export>
65 
66  // <reviewed reviewer="" date="" tests="" demos="">
67 
68  // <prerequisite>
69  // <li> <linkto class=FTMachine>FTMachine</linkto> module
70  // <li> <linkto class=SkyEquation>SkyEquation</linkto> module
71  // <li> <linkto class=VisBuffer>VisBuffer</linkto> module
72  // <li> <linto class=EPJones>EPJones</linkto> module
73  // </prerequisite>
74  //
75  // <etymology>
76  // FTMachine is a Machine for Fourier Transforms. Like
77  // WProjectFT, WOnlyProjectFT does Grid-based Fourier transforms but
78  // also includes the effects of primary beam and antenna pointing
79  // offsets.
80  // </etymology>
81  //
82  // <synopsis>
83  //
84  // The <linkto class=SkyEquation>SkyEquation</linkto> needs to be
85  // able to perform Fourier transforms on visibility
86  // data. WOnlyProjectFT allows efficient handling of direction
87  // dependent effects due to the primary beam and antenna pointing
88  // offsets using a <linkto class=VisBuffer>VisBuffer</linkto> which
89  // encapsulates a chunk of visibility (typically all baselines for
90  // one time) together with all the information needed for processing
91  // (e.g. UVW coordinates).
92  //
93  // Using this FTMachine, errors due antenna pointing offsets can be
94  // corrected during deconvolution. One form of antenna pointing
95  // error which is known a-priori is the VLA polarization squint
96  // (about 6% of the Primary beam width at any frequency). For
97  // casacore::Stokes imaging, using this FTMachine, the VLA polarization squint
98  // and beam polarization can also be corrected. Also since the
99  // effects of antenna pointing errors is strongest in the range of
100  // 1-2GHz band (where the sky is not quite empty while the beams are
101  // not too large either), this FTMachine can also be setup to
102  // correct for the w-term.
103  //
104  // Switches are provided in the get() method to compute the
105  // derivatives with respect to the parameters of the primary beam
106  // (only pointing offsets for now). This is used in the pointing
107  // offset solver.
108  //
109  // See the documentation of other FTMachines for details about the
110  // design of the FTMachines in general.
111  //
112  // </synopsis>
113  //
114  // <example>
115  // See the example for <linkto class=SkyModel>SkyModel</linkto>.
116  // </example>
117  //
118  // <motivation>
119  //
120  // Encapsulate the correction of direction dependent effects via
121  // visibility plane convolutions with a potentially different
122  // convolution function for each baseline.
123  //
124  // </motivation>
125  //
126  // <todo asof="2005/07/21">
127  //
128  // <ul> Include the antenna based complex gain term as well since
129  // that can interfere with the effects of pointing offsets.
130  //
131  // <ul> Factor out the actual convolution functions as a separate
132  // class making FTMachines for various direction dependent effects
133  // generic.
134  //
135  // </todo>
136 
137  // class EPJones;
138  class SolvableVisJones;
139  class WOnlyProjectFT : public FTMachine {
140  public:
141 
142  // Constructor: cachesize is the size of the cache in words
143  // (e.g. a few million is a good number), tilesize is the
144  // size of the tile used in gridding (cannot be less than
145  // 12, 16 works in most cases).
146  // <group>
152  casacore::Float pbLimit=5e-2,
153  casacore::Bool usezero=false);
154  // </group>
155 
156  // Construct from a casacore::Record containing the WOnlyProjectFT state
157  WOnlyProjectFT(const casacore::RecordInterface& stateRec);
158 
159  // Copy constructor
160  WOnlyProjectFT(const WOnlyProjectFT &other);
161 
162  // Assignment operator
163  WOnlyProjectFT &operator=(const WOnlyProjectFT &other);
164 
165  ~WOnlyProjectFT();
166 
168  const VisBuffer& vb);
169  // This version returns the gridded vis...should be used in conjunction
170  // with the version of 'get' that needs the gridded visdata
172  const VisBuffer& vb, casacore::Array<casacore::Complex>& griddedVis,
174 
175  // Finalize transform to Visibility plane: flushes the image
176  // cache and shows statistics if it is being used.
177  virtual void finalizeToVis();
178 
179  // Initialize transform to Sky plane: initializes the image
181  const VisBuffer& vb);
182 
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  virtual void finalizeToSky();
187 
188  virtual void initVisBuffer(VisBuffer& vb, Type whichVBColumn);
189  void initVisBuffer(VisBuffer& vb, Type whichVBColumn, casacore::Int row);
190 
191  // Get actual coherence from grid by degridding
192  void get(VisBuffer& vb, casacore::Int row=-1);
193 
194  // Get the coherence from grid return it in the degrid
195  // is used especially when scratch columns are not
196  // present in ms.
197  void get(VisBuffer& vb, casacore::Cube<casacore::Complex>& degrid,
199  casacore::Int row=-1);
200 
201 
202 
203  // Put coherence to grid by gridding.
206  {
207  // throw(casacore::AipsError("WOnlyProjectFT::put is not implemented"));
208  }
209  void put(const VisBuffer& vb, casacore::Int row=-1, casacore::Bool dopsf=false,
211 
212  // Make the entire image
214  VisSet& vs,
217 
218  // Get the final image: do the Fourier transform and
219  // grid-correct, then optionally normalize by the summed weights
221 
222  // Save and restore the WOnlyProjectFT to and from a record
225 
226  // Can this FTMachine be represented by Fourier convolutions?
227  casacore::Bool isFourier() {return true;}
228 
229  //
230  // Make a sensitivity image (sensitivityImage), given the gridded
231  // weights (wtImage). These are related to each other by a
232  // Fourier transform and normalization by the sum-of-weights
233  // (sumWt) and normalization by the product of the 2D FFT size
234  // along each axis. If doFFTNorm=false, normalization by the FFT
235  // size is not done. If sumWt is not provided, normalization by
236  // the sum of weights is also not done.
237  //
241  const casacore::Bool& doFFTNorm=true) {};
242  virtual void makeSensitivityImage(const VisBuffer& vb,
243  const casacore::ImageInterface<casacore::Complex>& imageTemplate,
245  //
246  // Given the sky image (Fourier transform of the visibilities),
247  // sum of weights and the sensitivity image, this method replaces
248  // the skyImage with the normalized image of the sky.
249  //
251  const casacore::Matrix<casacore::Double>& sumOfWts,
252  casacore::Lattice<casacore::Float>& sensitivityImage,
253  casacore::Bool fftNorm=true);
255  const casacore::Matrix<casacore::Double>& sumOfWts,
256  casacore::Lattice<casacore::Float>& sensitivityImage,
257  casacore::Lattice<casacore::Complex>& sensitivitySqImage,
258  casacore::Bool fftNorm=true);
259 
262 
264  virtual casacore::String name(){ return "WOnlyProjectFT";};
266  virtual void setMiscInfo(const casacore::Int qualifier){(void)qualifier;};
267 
268  protected:
269 
271  // Locate convolution functions on the disk
272  // casacore::Int locateConvFunction(const casacore::Int Nw, const casacore::Float pa);
273  // void cacheConvFunction(casacore::Int which, casacore::Array<casacore::Complex>& cf, casacore::CoordinateSystem& coord);
274  // Find the convolution function
276  const VisBuffer& vb);
277 
278  // Get the appropriate data pointer
280 
281  void ok();
282 
283  void init();
284  // virtual void initPolInfo(const VisBuffer& vb);
285  // Is this record on Grid? check both ends. This assumes that the
286  // ends bracket the middle
287  casacore::Bool recordOnGrid(const VisBuffer& vb, casacore::Int rownr) const;
288 
289  // Padding in FFT
291 
293  // Image cache
295 
296  // Sizes
299 
300  // Gridder
302 
303  // Is this tiled?
305 
306  // casacore::Array lattice
308 
309  // Lattice. For non-tiled gridding, this will point to arrayLattice,
310  // whereas for tiled gridding, this points to the image
312 
314 
315  // Useful IPositions
317 
318  // Image Scaling and offset
320 
321  // casacore::Array for non-tiled gridding
323 
324  // casacore::DirectionCoordinate directionCoord;
326 
327  // Grid/degrid zero spacing points?
329 
330  // casacore::CountedPtr<ConvolutionFunction> telescopeConvFunc_p;
331  // CFStore cfs_p, cfwts_p;
334  //
335  // casacore::Vector to hold the support size info. for the convolution
336  // functions pointed to by the elements of convFunctions_p. The
337  // co-ordinates of this array are (W-term, Poln, PA).
338  //
340 
341  //
342  // No. of vis. polarization planes used in making the user defined
343  // casacore::Stokes images
344  //
346 
349 
353  //casacore::Cube<casacore::Complex>& gradVisAzData,
354  //casacore::Cube<casacore::Complex>& gradVisElData,
355  //casacore::IPosition& gradS,
362  casacore::Double& sigma,
365  casacore::Double area,
366  casacore::Int& doGrad,casacore::Int paIndex);
368  const casacore::Complex& visdata_p,
370  //casacore::Cube<casacore::Complex>& gradVisAzData,
371  //casacore::Cube<casacore::Complex>& gradVisElData,
372  //casacore::IPosition& gradS,
375  const casacore::Matrix<casacore::Float>& weight,
379  const VisBuffer& vb,casacore::Int& Nant_p, casacore::Int& scanNo,
380  casacore::Double& sigma,
384  casacore::Double& area,
385  casacore::Int& doGrad,
386  casacore::Int& doPSF,casacore::Int paIndex);
390  casacore::Cube<casacore::Complex>& gradVisAzData,
391  casacore::Cube<casacore::Complex>& gradVisElData,
392  // casacore::IPosition& gradS,
399  casacore::Double& sigma,
402  casacore::Double area,
403  casacore::Int& doGrad,
404  casacore::Int paIndex);
405  };
406 } //# NAMESPACE CASA - END
407  // void makeAntiAliasingOp(casacore::Vector<casacore::Complex>& val, const casacore::Int len, const casacore::Double HPBW);
408  // void makeAntiAliasingCorrection(casacore::Vector<casacore::Complex>& correction,
409  // const casacore::Vector<casacore::Complex>& op,
410  // const casacore::Int nx);
411  // void applyAntiAliasingOp(casacore::ImageInterface<casacore::Complex>& cf,
412  // casacore::Vector<casacore::IPosition>& offset,
413  // casacore::Double HPBW,
414  // casacore::Int op=0,
415  // casacore::Bool Square=false);
416  // void applyAntiAliasingOp(casacore::ImageInterface<casacore::Float>& cf,
417  // casacore::Vector<casacore::IPosition>& offset,
418  // casacore::Double HPBW,
419  // casacore::Int op=0,
420  // casacore::Bool Square=false);
421  // void correctAntiAliasing(casacore::Lattice<casacore::Complex>& cf);
422 
423 #endif
casacore::MDirection::Convert * pointingToImage
casacore::DirectionCoordinate directionCoord;
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
casacore::Int npol
Definition: FTMachine.h:445
casacore::Int Nant_p
casacore::Int tilesize
casacore::Int maxConvSupport
No.
int Int
Definition: aipstype.h:50
casacore::Vector< casacore::Int > polMap
Definition: FTMachine.h:448
casacore::Float padding_p
Padding in FFT.
void runFortranGetGrad(casacore::Matrix< casacore::Double > &uvw, casacore::Vector< casacore::Double > &dphase, casacore::Cube< casacore::Complex > &visdata, casacore::IPosition &s, casacore::Cube< casacore::Complex > &gradVisAzData, casacore::Cube< casacore::Complex > &gradVisElData, casacore::Int &Conj, casacore::Cube< casacore::Int > &flags, casacore::Vector< casacore::Int > &rowFlags, casacore::Int &rownr, casacore::Vector< casacore::Double > &actualOffset, casacore::Array< casacore::Complex > *dataPtr, casacore::Int &aNx, casacore::Int &aNy, casacore::Int &npol, casacore::Int &nchan, VisBuffer &vb, casacore::Int &Nant_p, casacore::Int &scanNo, casacore::Double &sigma, casacore::Array< casacore::Float > &l_off, casacore::Array< casacore::Float > &m_off, casacore::Double area, casacore::Int &doGrad, casacore::Int paIndex)
virtual void normalizeImage(casacore::Lattice< casacore::Complex > &skyImage, const casacore::Matrix< casacore::Double > &sumOfWts, casacore::Lattice< casacore::Float > &sensitivityImage, casacore::Bool fftNorm=true)
Given the sky image (Fourier transform of the visibilities), sum of weights and the sensitivity image...
void findConvFunction(const casacore::ImageInterface< casacore::Complex > &image, const VisBuffer &vb)
Locate convolution functions on the disk casacore::Int locateConvFunction(const casacore::Int Nw...
casacore::CountedPtr< VisibilityResampler > reSampler_p
casacore::Vector< casacore::Double > uvOffset
virtual void initializeToVis(casacore::ImageInterface< casacore::Complex > &image, const VisBuffer &vb)
Initialize transform to Visibility plane.
virtual void runFortranGet(casacore::Matrix< casacore::Double > &uvw, casacore::Vector< casacore::Double > &dphase, casacore::Cube< casacore::Complex > &visdata, casacore::IPosition &s, casacore::Int &Conj, casacore::Cube< casacore::Int > &flags, casacore::Vector< casacore::Int > &rowFlags, casacore::Int &rownr, casacore::Vector< casacore::Double > &actualOffset, casacore::Array< casacore::Complex > *dataPtr, casacore::Int &aNx, casacore::Int &aNy, casacore::Int &npol, casacore::Int &nchan, VisBuffer &vb, casacore::Int &Nant_p, casacore::Int &scanNo, casacore::Double &sigma, casacore::Array< casacore::Float > &raoffsets, casacore::Array< casacore::Float > &decoffsets, casacore::Double area, casacore::Int &doGrad, casacore::Int paIndex)
virtual Type type()
Return the type enum.
casacore::Int lastIndex_p
casacore::Array< casacore::Complex > convFunc_p
casacore::CountedPtr&lt;ConvolutionFunction&gt; telescopeConvFunc_p; CFStore cfs_p, cfwts_p; ...
casacore::ConvolveGridder< casacore::Double, casacore::Complex > * gridder
Gridder.
virtual casacore::String name()
casacore::Array< casacore::Complex > * getDataPointer(const casacore::IPosition &, casacore::Bool)
Get the appropriate data pointer.
WOnlyProjectFT(casacore::Int nFacets, casacore::Long cachesize, casacore::CountedPtr< CFCache > &cfcache, casacore::CountedPtr< ConvolutionFunction > &cf, casacore::CountedPtr< VisibilityResampler > &reSampler, casacore::Int tilesize=16, casacore::Float pbLimit=5e-2, casacore::Bool usezero=false)
Constructor: cachesize is the size of the cache in words (e.g.
casacore::LatticeCache< casacore::Complex > * imageCache
Image cache.
casacore::ImageInterface< casacore::Complex > * image
Definition: FTMachine.h:409
virtual void finalizeToSky()
Finalize transform to Sky plane: flushes the image cache and shows statistics if it is being used...
casacore::Int nWPlanes_p
LatticeExprNode floor(const LatticeExprNode &expr)
WOnlyProjectFT & operator=(const WOnlyProjectFT &other)
Assignment operator.
virtual void finalizeToVis()
Finalize transform to Visibility plane: flushes the image cache and shows statistics if it is being u...
casacore::Bool fromRecord(const casacore::RecordInterface &inRec)
casacore::CountedPtr< casacore::Lattice< casacore::Complex > > lattice
Lattice.
casacore::Bool recordOnGrid(const VisBuffer &vb, casacore::Int rownr) const
virtual void initPolInfo(const VisBuffer&amp; vb); Is this record on Grid? check both ends...
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...
casacore::Bool makingPSF
long Long
Definition: aipstype.h:52
casacore::Array< casacore::Complex > griddedData
casacore::Array for non-tiled gridding
casacore::Int wConvSize
virtual void initVisBuffer(VisBuffer &vb, Type whichVBColumn)
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
casacore::Bool toRecord(casacore::RecordInterface &outRec, casacore::Bool withImage=false)
Save and restore the WOnlyProjectFT to and from a record.
double Double
Definition: aipstype.h:55
void makeImage(FTMachine::Type type, VisSet &vs, casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight)
Make the entire image.
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
virtual void makeSensitivityImage(casacore::Lattice< casacore::Complex > &wtImage, casacore::ImageInterface< casacore::Float > &sensitivityImage, const casacore::Matrix< casacore::Float > &sumWt=casacore::Matrix< casacore::Float >(), const casacore::Bool &doFFTNorm=true)
Make a sensitivity image (sensitivityImage), given the gridded weights (wtImage). ...
float Float
Definition: aipstype.h:54
Functor to apply complex function conj.
Definition: Functors.h:525
casacore::Matrix< casacore::Double > sumWeight
Sum of weights per polarization and per chan.
Definition: FTMachine.h:442
casacore::Vector< casacore::Int > & getPolMap()
casacore::Bool isFourier()
Can this FTMachine be represented by Fourier convolutions?
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::ImageInterface< casacore::Float > & getSensitivityImage()
virtual 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::Int convSampling
casacore::IPosition centerLoc
Useful IPositions.
virtual casacore::Bool verifyShapes(casacore::IPosition shape0, casacore::IPosition shape1)
const Double e
e and functions thereof:
casacore::Bool usezero_p
Grid/degrid zero spacing points?
casacore::IPosition offsetLoc
casacore::Int nchan
Definition: FTMachine.h:445
casacore::Vector< casacore::Double > uvScale
Image Scaling and offset.
casacore::Float maxAbsData
casacore::Int nint(casacore::Double val)
virtual void runFortranPut(casacore::Matrix< casacore::Double > &uvw, casacore::Vector< casacore::Double > &dphase, const casacore::Complex &visdata_p, casacore::IPosition &s, casacore::Int &Conj, casacore::Cube< casacore::Int > &flags, casacore::Vector< casacore::Int > &rowFlags, const casacore::Matrix< casacore::Float > &weight, casacore::Int &rownr, casacore::Vector< casacore::Double > &actualOffset, casacore::Array< casacore::Complex > &dataPtr, casacore::Int &aNx, casacore::Int &aNy, casacore::Int &npol, casacore::Int &nchan, const VisBuffer &vb, casacore::Int &Nant_p, casacore::Int &scanNo, casacore::Double &sigma, casacore::Array< casacore::Float > &raoffsets, casacore::Array< casacore::Float > &decoffsets, casacore::Matrix< casacore::Double > &sumWeight, casacore::Double &area, casacore::Int &doGrad, casacore::Int &doPSF, casacore::Int paIndex)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Long cachesize
Sizes.
casacore::Int convSize
casacore::Vector to hold the support size info.
VisBuffers encapsulate one chunk of visibility data for processing.
Definition: VisBuffer.h:153
Abstract base class for Record classes.
virtual casacore::Matrix< casacore::Double > & getSumOfWeights()
casacore::Array< casacore::Complex > convWeights_p
casacore::Bool isTiled
Is this tiled?
void put(const VisBuffer &, casacore::TempImage< casacore::Complex > &, casacore::Vector< casacore::Double > &, int, casacore::UVWMachine *, casacore::Bool)
Put coherence to grid by gridding.
casacore::CountedPtr< casacore::Lattice< casacore::Complex > > arrayLattice
casacore::Array lattice
defines interface for the Fourier Transform Machine
Definition: FTMachine.h:120