LCOV - code coverage report
Current view: top level - synthesis/TransformMachines - PBMathInterface.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 7 0.0 %
Date: 2024-10-04 16:51:10 Functions: 0 3 0.0 %

          Line data    Source code
       1             : //# PBMathInterface.h: Definitions of interface for PBMath objects
       2             : //# Copyright (C) 1996,1997,1998,1999,2000,2003
       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_PBMATHINTERFACE_H
      30             : #define SYNTHESIS_PBMATHINTERFACE_H
      31             : 
      32             : #include <casacore/casa/aips.h>
      33             : #include <synthesis/TransformMachines/BeamSquint.h>
      34             : #include <casacore/images/Images/ImageInterface.h>
      35             : #include <components/ComponentModels/Flux.h>
      36             : #include <components/ComponentModels/ComponentShape.h>
      37             : #include <casacore/casa/BasicSL/Complex.h>
      38             : #include <synthesis/TransformMachines/SkyJones.h>
      39             : 
      40             : namespace casacore{
      41             : 
      42             : class Table;
      43             : class MDirection;
      44             : class CoordinateSystem;
      45             : class ImageRegion;
      46             : class String;
      47             : }
      48             : 
      49             : namespace casa { //# NAMESPACE CASA - BEGIN
      50             : 
      51             : //Forward declaration
      52             : class SkyComponent;
      53             : 
      54             : // <summary> Virtual base class defining the Primary Beam interface </summary>
      55             : 
      56             : 
      57             : // <use visibility=export>
      58             : 
      59             : // <reviewed reviewer="" date="" tests="" demos="">
      60             : 
      61             : // <prerequisite>
      62             : // <li> <linkto class="SkyJones">SkyJones</linkto> class
      63             : // <li> <linkto class="BeamSkyJones">BeamSkyJones</linkto> class
      64             : // </prerequisite>
      65             : //
      66             : // <etymology>
      67             : //  PBMathInterface defines the interface to PB Math objects, the
      68             : //  encapsulations of the PB mathematical functioning
      69             : // </etymology>
      70             : //
      71             : // <synopsis>
      72             : // PBMathInterface is a virtual base class that defines the
      73             : // PBMath interface.  The big thing that it does is to define
      74             : // the applyPB, applyVP, and applyPB2 methods, which call a polymorphic
      75             : // low level apply method depending upon whether the PBMath type is a
      76             : // 1D or 2D type.
      77             : //
      78             : // PBMathInterface - there are many forms the primary beam can
      79             : // take, each of which will be derived from this virtual class which
      80             : // defines the generic interface to the multitude of PBMath objects.
      81             : // The main part of that interface is application of the PB to
      82             : // images, which is defined by PBMathInterface.
      83             : //
      84             : // PBMathInterface is the virtual base class, and
      85             : // PBMath is an envelope type which is derived from
      86             : // PBMathInterface.  The two letter classes currently
      87             : // envisioned are PBMath1D and PBMath2D.
      88             : //
      89             : // PBMath can function independent of MeasurementSets.
      90             : // PBMath is used by the BeamSkyJones classes VPSkyJones and
      91             : // DBeamSkyJones.
      92             : // </synopsis>
      93             : //
      94             : //
      95             : // <example>
      96             : // <srcblock>
      97             : 
      98             : // </srcblock>
      99             : // </example>
     100             : //
     101             : // <motivation>
     102             : // The SkyJones classes are all tied up with the casacore::MS or VisBuffers.  This class
     103             : // encapsulates the raw mathematical functionality of the PB from the
     104             : // BeamSkyJones-derived classes which deal with the casacore::MS/VisBuff's.
     105             : // Also, several different BeamSkyJones objects and effects can be treated
     106             : // with the same PBMath heirarchy objects.
     107             : // </motivation>
     108             : //
     109             : // <todo asof="98/10/21">
     110             : // <li> summary()
     111             : // </todo>
     112             : 
     113             :  
     114             : class PBMathInterface {
     115             : public:
     116             : 
     117             :   // required so PBMath can see the protected "apply" method
     118             :   // Other derivatives of PBMathInterface, such as PBMath2D, will
     119             :   // also require friend class PBMath;
     120             :   friend class PBMath;  
     121             : 
     122             :   // Allowed PBMath Classes.
     123             :   // Currently, COMMONPB, Airy, Gauss, Poly, Ipoly, CosPoly, Numerical
     124             :   // are all implemented; Image and Zernike (2D PB's) are not.
     125             :   // This enumeration order becomes locked in when we get permanent
     126             :   // PB's in the casacore::MeasurementSet Tables.
     127             :   //
     128             :   // COMMPNPB is not really a PB Class, but is here for consistency with
     129             :   // glish code in vpmanager
     130             :   enum PBClass{NONE, COMMONPB, AIRY, GAUSS, POLY, IPOLY, COSPOLY,
     131             :                NUMERIC, IMAGE, ZERNIKE};
     132             : 
     133             :   // Number of different classes in PBClass enumeration
     134             :   enum {
     135             :     NumberOfPBClasses=10
     136             :   };
     137             : 
     138             :   // Useful constructor
     139             :   PBMathInterface(casacore::Bool isThisVP,
     140             :                   BeamSquint squint, 
     141             :                   casacore::Bool useSymmetricBeam);
     142             : 
     143             :   // virtual destructor
     144             :   virtual ~PBMathInterface() = 0;
     145             : 
     146             :   // Apply Jones matrix to an image (and adjoint)
     147             :   // <group>
     148             : 
     149             :   casacore::ImageInterface<casacore::Complex>& applyVP(const casacore::ImageInterface<casacore::Complex>& in,
     150             :                                    casacore::ImageInterface<casacore::Complex>& out,
     151             :                                    const casacore::MDirection& sp,
     152           0 :                                    const casacore::Quantity parAngle = casacore::Quantity(0.0,"deg"),
     153             :                                    const BeamSquint::SquintType doSquint = BeamSquint::NONE,
     154             :                                    casacore::Bool inverse = false,
     155             :                                    casacore::Bool conjugate = false,
     156             :                                    casacore::Float cutoff = 0.01,
     157             :                                    casacore::Bool forward=true);
     158             : 
     159             :   casacore::ImageInterface<casacore::Complex>& applyPB(const casacore::ImageInterface<casacore::Complex>& in,
     160             :                                    casacore::ImageInterface<casacore::Complex>& out,
     161             :                                    const casacore::MDirection& sp,
     162           0 :                                    const casacore::Quantity parAngle = casacore::Quantity(0.0,"deg"),
     163             :                                    const BeamSquint::SquintType doSquint = BeamSquint::NONE,
     164             :                                    casacore::Bool inverse = false,
     165             :                                    casacore::Float cutoff = 0.01,
     166             :                                    casacore::Bool forward=true);
     167             : 
     168             :   casacore::ImageInterface<casacore::Float>& applyPB(const casacore::ImageInterface<casacore::Float>& in,
     169             :                                    casacore::ImageInterface<casacore::Float>& out,
     170             :                                    const casacore::MDirection& sp,
     171             :                                    const casacore::Quantity parAngle = casacore::Quantity(0.0,"deg"),
     172             :                                    const BeamSquint::SquintType doSquint = BeamSquint::NONE,
     173             :                                    casacore::Float cutoff = 0.01);
     174             : 
     175             :   // This has a very specialized role (in SkyEquation) and should
     176             :   // not be used elsewhere
     177             :   casacore::ImageInterface<casacore::Float>& applyPB2(const casacore::ImageInterface<casacore::Float>& in,
     178             :                                   casacore::ImageInterface<casacore::Float>& out,
     179             :                                   const casacore::MDirection& sp,
     180             :                                   const casacore::Quantity parAngle = casacore::Quantity(0.0,"deg"),
     181             :                                   const BeamSquint::SquintType doSquint = BeamSquint::NONE,
     182             :                                   casacore::Float cutoff=0.01);
     183             :   // </group>
     184             :   
     185             :   // Apply Jones matrix to a sky component (and adjoint)
     186             :   // <group>
     187             :   SkyComponent& applyVP(SkyComponent& in,
     188             :                         SkyComponent& out,
     189             :                         const casacore::MDirection& sp,
     190             :                         const casacore::Quantity frequency,
     191             :                         const casacore::Quantity parAngle = casacore::Quantity(0.0,"deg"),
     192             :                         const BeamSquint::SquintType doSquint = BeamSquint::NONE,
     193             :                         casacore::Bool inverse = false,
     194             :                         casacore::Bool conjugate = false,
     195             :                         casacore::Float cutoff = 0.01,
     196             :                         casacore::Bool forward = true);
     197             :   SkyComponent& applyPB(SkyComponent& in,
     198             :                         SkyComponent& out,
     199             :                         const casacore::MDirection& sp,
     200             :                         const casacore::Quantity frequency,
     201             :                         const casacore::Quantity parAngle = casacore::Quantity(0.0,"deg"),
     202             :                         const BeamSquint::SquintType doSquint = BeamSquint::NONE,
     203             :                         casacore::Bool inverse = false,
     204             :                         casacore::Float cutoff = 0.01,
     205             :                         casacore::Bool forward = true);
     206             :   SkyComponent& applyPB2(SkyComponent& in,
     207             :                          SkyComponent& out,
     208             :                          const casacore::MDirection& sp,
     209             :                          const casacore::Quantity frequency,
     210             :                          const casacore::Quantity parAngle = casacore::Quantity(0.0,"deg"),
     211             :                          const BeamSquint::SquintType doSquint = BeamSquint::NONE);
     212             :   // </group>
     213             : 
     214             :   // Which PBClass is this one?
     215             :   virtual PBClass whichPBClass() = 0;
     216             :   
     217             :   // Convert PBClass enumeration into PBClass String
     218             :   void namePBClass(casacore::String & name);
     219             : 
     220             :   // Convert enumeration into a string
     221             :   static void namePBClass(const PBMathInterface::PBClass iPB,  casacore::String & str);
     222             : 
     223             :   // Fit an azimuthally symmetric beam to the squinted or otherwise 2-D beam
     224             :   // for casacore::Stokes I?
     225           0 :   virtual void setUseSymmetric(casacore::Bool useSym=true) { useSymmetricBeam_p = useSym; }
     226             : 
     227             :   // Get value of useSymmetric
     228           0 :   virtual casacore::Bool getUseSymmetric() { return useSymmetricBeam_p; }
     229             : 
     230             :   // Get the casacore::ImageRegion of the primary beam on an Image for a given pointing
     231             :   // Note: casacore::ImageRegion is not necesarily constrained to lie within the
     232             :   // image region (for example, if the pointing center is near the edge of the
     233             :   // image).  fPad: fractional padding for extra support beyond PB.
     234             :   // (note: we do not properly treat squint yet, this will cover it for now)
     235             :   // iChan: frequency channel to take: lowest frequency channel is safe for all
     236             :   //
     237             :   // Potential problem: this casacore::ImageRegion includes all casacore::Stokes and Frequency Channels
     238             :   // present in the input image.
     239             :   virtual casacore::ImageRegion*  extent (const casacore::ImageInterface<casacore::Complex>& im, const casacore::MDirection& pointing,
     240             :                                 const casacore::Int row, const casacore::Float fPad,  const casacore::Int iChan,  
     241             :                                 const SkyJones::SizeType) = 0;
     242             :   virtual casacore::ImageRegion*  extent (const casacore::ImageInterface<casacore::Float>& im, const casacore::MDirection& pointing,
     243             :                                 const casacore::Int row, const casacore::Float fPad,  const casacore::Int iChan,  
     244             :                                 const SkyJones::SizeType) = 0;
     245             : 
     246             : 
     247             : 
     248             :   virtual casacore::Int support (const casacore::CoordinateSystem& cs)=0;
     249             : 
     250             :   // Summarize the Voltage Pattern;
     251             :   // For PBMath1D, list nValues worth of the PB array
     252             :   virtual void summary(casacore::Int nValues=0);
     253             : 
     254             :   // Is state of PBMath object OK?
     255             :   virtual casacore::Bool ok()=0;
     256             : 
     257           0 :   virtual void setBandOrFeedName(const casacore::String elnamo){
     258           0 :          bandOrFeedName_p=elnamo; 
     259           0 :   };
     260             : protected:
     261             :  
     262             :   // Dumb constructor: protected, as it won't do you any good!
     263             :   PBMathInterface();
     264             : 
     265             :   // lower level helping apply methods
     266             :   // <group>
     267             : 
     268             :   virtual 
     269             :   casacore::ImageInterface<casacore::Complex>& 
     270             :   apply(const casacore::ImageInterface<casacore::Complex>& in,
     271             :         casacore::ImageInterface<casacore::Complex>& out,
     272             :         const casacore::MDirection& sp,
     273             :         const casacore::Quantity parAngle,       
     274             :         const BeamSquint::SquintType doSquint,
     275             :         casacore::Bool Inverse,
     276             :         casacore::Bool Conjugate,
     277             :         casacore::Int ipower,  // ie, 1=VP, 2=PB
     278             :         casacore::Float cutoff,
     279             :         casacore::Bool forward) =0;   
     280             : 
     281             :   virtual 
     282             :   casacore::ImageInterface<casacore::Float>& 
     283             :   apply(const casacore::ImageInterface<casacore::Float>& in,
     284             :         casacore::ImageInterface<casacore::Float>& out,
     285             :         const casacore::MDirection& sp,
     286             :         const casacore::Quantity parAngle,       
     287             :         const BeamSquint::SquintType doSquint,
     288             :         casacore::Float cutoff, const casacore::Int ipower=4) =0;   
     289             : 
     290             :   virtual SkyComponent& 
     291             :   apply(SkyComponent& in,
     292             :         SkyComponent& out,
     293             :         const casacore::MDirection& sp,
     294             :         const casacore::Quantity frequency,
     295             :         const casacore::Quantity parAngle,          
     296             :         const BeamSquint::SquintType doSquint,
     297             :         casacore::Bool Inverse,
     298             :         casacore::Bool Conjugate,
     299             :         casacore::Int ipower,  // ie, 1=VP, 2=PB, 4=PB^2
     300             :         casacore::Float cutoff,
     301             :         casacore::Bool forward)  =0; 
     302             :   //  </group>
     303             :   
     304             : 
     305             :   // Functions to deal with conversions to Float
     306             :   // <group>
     307             :   static casacore::Float asFloat(const casacore::Complex & value) {return value.real(); }
     308             :   static casacore::Float asFloat(const casacore::DComplex & value){return (casacore::Float) value.real(); }
     309             :   static casacore::Float asFloat(const casacore::Float & value) {return value; }
     310             :   static casacore::Float asFloat(const casacore::Double & value) {return (casacore::Float) value; }
     311             :   
     312             :   // </group>
     313             : 
     314             :   
     315             :   
     316             :   // Are the parameters being provided in the derived class constructor
     317             :   // describing a Voltage Pattern or a Primary Beam?  The default is Voltage
     318             :   // Pattern, and we keep it internally as a voltage pattern
     319             :   casacore::Bool isThisVP_p;
     320             : 
     321             :   // Beam squint: convention is AZ-EL offset of the
     322             :   // casacore::Stokes RR beam w.r.t. pointing position 
     323             :   // casacore::Stokes LL will be at -squint_p
     324             :   // Southern observatories have the same AZ-EL and PA definitions as Northern
     325             :   BeamSquint squint_p;
     326             :   
     327             :   // Should we use the effective az-symmetrical primary beam?
     328             :   // Otherwise, use squinted beam; if no squint, no difference
     329             :   casacore::Bool useSymmetricBeam_p;
     330             :   
     331             :   casacore::String bandOrFeedName_p;
     332             : 
     333             : private:
     334             : 
     335             : };
     336             :  
     337             : 
     338             : } //# NAMESPACE CASA - END
     339             : 
     340             : #endif
     341             : 

Generated by: LCOV version 1.16