LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - GridBoth.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 5 0.0 %
Date: 2024-12-11 20:54:31 Functions: 0 4 0.0 %

          Line data    Source code
       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: casa-feedback@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             : 
      32             : #include <synthesis/TransformMachines/GridFT.h>
      33             : #include <synthesis/MeasurementComponents/SDGrid.h>
      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.
     157             :   void initializeToVis(casacore::ImageInterface<casacore::Complex>& image,
     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
     165             :   void initializeToSky(casacore::ImageInterface<casacore::Complex>& image,  casacore::Matrix<casacore::Float>& weight,
     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,
     178             :            FTMachine::Type type=FTMachine::OBSERVED);
     179             : 
     180             :   // Get the final image: do the Fourier transform and
     181             :   // grid-correct, then optionally normalize by the summed weights
     182             :   casacore::ImageInterface<casacore::Complex>& getImage(casacore::Matrix<casacore::Float>&, casacore::Bool normalize=true);
     183           0 :   virtual void normalizeImage(casacore::Lattice<casacore::Complex>& /*skyImage*/,
     184             :                               const casacore::Matrix<casacore::Double>& /*sumOfWts*/,
     185             :                               casacore::Lattice<casacore::Float>& /*sensitivityImage*/,
     186             :                               casacore::Bool /*fftNorm*/)
     187           0 :     {throw(casacore::AipsError("GridBoth::normalizeImage() called"));}
     188             : 
     189             :   // Get the final weights image
     190             :   void getWeightImage(casacore::ImageInterface<casacore::Float>&, casacore::Matrix<casacore::Float>&);
     191             : 
     192             :   // Save and restore the GridFT to and from a record
     193             :   virtual casacore::Bool toRecord(casacore::String& error, casacore::RecordInterface& outRec, 
     194             :                         casacore::Bool withImage=false, const casacore::String diskimage="");
     195             :   virtual casacore::Bool fromRecord(casacore::String& error, const casacore::RecordInterface& inRec);
     196             : 
     197             :   // Has this operator changed since the last application?
     198             :   virtual casacore::Bool changed(const VisBuffer& vb);
     199           0 :   virtual void setMiscInfo(const casacore::Int qualifier){(void)qualifier;};
     200           0 :   virtual void ComputeResiduals(VisBuffer&/*vb*/, casacore::Bool /*useCorrected*/) {};
     201           0 :   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 
     210             :   casacore::TempImage<casacore::Complex>* sdImage_p;
     211             :   casacore::TempImage<casacore::Complex>* synImage_p;
     212             : 
     213             :   casacore::Float sdScale_p, sdWeight_p;
     214             : 
     215             :   void ok();
     216             : 
     217             :   void init();
     218             : 
     219             : };
     220             : 
     221             : } //# NAMESPACE CASA - END
     222             : 
     223             : #endif

Generated by: LCOV version 1.16