casa
$Rev:20696$
|
00001 //# PBMathInterface.h: Definitions of interface for PBMath objects 00002 //# Copyright (C) 1996,1997,1998,1999,2000,2003 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be adressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# 00027 //# $Id$ 00028 00029 #ifndef SYNTHESIS_PBMATHINTERFACE_H 00030 #define SYNTHESIS_PBMATHINTERFACE_H 00031 00032 #include <casa/aips.h> 00033 #include <synthesis/TransformMachines/BeamSquint.h> 00034 #include <images/Images/ImageInterface.h> 00035 #include <components/ComponentModels/Flux.h> 00036 #include <components/ComponentModels/ComponentShape.h> 00037 #include <casa/BasicSL/Complex.h> 00038 #include <synthesis/TransformMachines/SkyJones.h> 00039 00040 namespace casa { //# NAMESPACE CASA - BEGIN 00041 00042 //Forward declaration 00043 class Table; 00044 class MDirection; 00045 class CoordinateSystem; 00046 class SkyComponent; 00047 class ImageRegion; 00048 class String; 00049 00050 // <summary> Virtual base class defining the Primary Beam interface </summary> 00051 00052 00053 // <use visibility=export> 00054 00055 // <reviewed reviewer="" date="" tests="" demos=""> 00056 00057 // <prerequisite> 00058 // <li> <linkto class="SkyJones">SkyJones</linkto> class 00059 // <li> <linkto class="BeamSkyJones">BeamSkyJones</linkto> class 00060 // </prerequisite> 00061 // 00062 // <etymology> 00063 // PBMathInterface defines the interface to PB Math objects, the 00064 // encapsulations of the PB mathematical functioning 00065 // </etymology> 00066 // 00067 // <synopsis> 00068 // PBMathInterface is a virtual base class that defines the 00069 // PBMath interface. The big thing that it does is to define 00070 // the applyPB, applyVP, and applyPB2 methods, which call a polymorphic 00071 // low level apply method depending upon whether the PBMath type is a 00072 // 1D or 2D type. 00073 // 00074 // PBMathInterface - there are many forms the primary beam can 00075 // take, each of which will be derived from this virtual class which 00076 // defines the generic interface to the multitude of PBMath objects. 00077 // The main part of that interface is application of the PB to 00078 // images, which is defined by PBMathInterface. 00079 // 00080 // PBMathInterface is the virtual base class, and 00081 // PBMath is an envelope type which is derived from 00082 // PBMathInterface. The two letter classes currently 00083 // envisioned are PBMath1D and PBMath2D. 00084 // 00085 // PBMath can function independent of MeasurementSets. 00086 // PBMath is used by the BeamSkyJones classes VPSkyJones and 00087 // DBeamSkyJones. 00088 // </synopsis> 00089 // 00090 // 00091 // <example> 00092 // <srcblock> 00093 00094 // </srcblock> 00095 // </example> 00096 // 00097 // <motivation> 00098 // The SkyJones classes are all tied up with the MS or VisBuffers. This class 00099 // encapsulates the raw mathematical functionality of the PB from the 00100 // BeamSkyJones-derived classes which deal with the MS/VisBuff's. 00101 // Also, several different BeamSkyJones objects and effects can be treated 00102 // with the same PBMath heirarchy objects. 00103 // </motivation> 00104 // 00105 // <todo asof="98/10/21"> 00106 // <li> summary() 00107 // </todo> 00108 00109 00110 class PBMathInterface { 00111 public: 00112 00113 // required so PBMath can see the protected "apply" method 00114 // Other derivatives of PBMathInterface, such as PBMath2D, will 00115 // also require friend class PBMath; 00116 friend class PBMath; 00117 00118 // Allowed PBMath Classes. 00119 // Currently, COMMONPB, Airy, Gauss, Poly, Ipoly, CosPoly, Numerical 00120 // are all implemented; Image and Zernike (2D PB's) are not. 00121 // This enumeration order becomes locked in when we get permanent 00122 // PB's in the MeasurementSet Tables. 00123 // 00124 // COMMPNPB is not really a PB Class, but is here for consistency with 00125 // glish code in vpmanager 00126 enum PBClass{NONE, COMMONPB, AIRY, GAUSS, POLY, IPOLY, COSPOLY, 00127 NUMERIC, IMAGE, ZERNIKE}; 00128 00129 // Number of different classes in PBClass enumeration 00130 enum { 00131 NumberOfPBClasses=10 00132 }; 00133 00134 // Useful constructor 00135 PBMathInterface(Bool isThisVP, 00136 BeamSquint squint, 00137 Bool useSymmetricBeam); 00138 00139 // virtual destructor 00140 virtual ~PBMathInterface() = 0; 00141 00142 // Apply Jones matrix to an image (and adjoint) 00143 // <group> 00144 00145 ImageInterface<Complex>& applyVP(const ImageInterface<Complex>& in, 00146 ImageInterface<Complex>& out, 00147 const MDirection& sp, 00148 const Quantity parAngle = Quantity(0.0,"deg"), 00149 const BeamSquint::SquintType doSquint = BeamSquint::NONE, 00150 Bool inverse = False, 00151 Bool conjugate = False, 00152 Float cutoff = 0.01, 00153 Bool forward=True); 00154 00155 ImageInterface<Complex>& applyPB(const ImageInterface<Complex>& in, 00156 ImageInterface<Complex>& out, 00157 const MDirection& sp, 00158 const Quantity parAngle = Quantity(0.0,"deg"), 00159 const BeamSquint::SquintType doSquint = BeamSquint::NONE, 00160 Bool inverse = False, 00161 Float cutoff = 0.01, 00162 Bool forward=True); 00163 00164 ImageInterface<Float>& applyPB(const ImageInterface<Float>& in, 00165 ImageInterface<Float>& out, 00166 const MDirection& sp, 00167 const Quantity parAngle = Quantity(0.0,"deg"), 00168 const BeamSquint::SquintType doSquint = BeamSquint::NONE, 00169 Float cutoff = 0.01); 00170 00171 // This has a very specialized role (in SkyEquation) and should 00172 // not be used elsewhere 00173 ImageInterface<Float>& applyPB2(const ImageInterface<Float>& in, 00174 ImageInterface<Float>& out, 00175 const MDirection& sp, 00176 const Quantity parAngle = Quantity(0.0,"deg"), 00177 const BeamSquint::SquintType doSquint = BeamSquint::NONE, 00178 Float cutoff=0.01); 00179 // </group> 00180 00181 // Apply Jones matrix to a sky component (and adjoint) 00182 // <group> 00183 SkyComponent& applyVP(SkyComponent& in, 00184 SkyComponent& out, 00185 const MDirection& sp, 00186 const Quantity frequency, 00187 const Quantity parAngle = Quantity(0.0,"deg"), 00188 const BeamSquint::SquintType doSquint = BeamSquint::NONE, 00189 Bool inverse = False, 00190 Bool conjugate = False, 00191 Float cutoff = 0.01, 00192 Bool forward = True); 00193 SkyComponent& applyPB(SkyComponent& in, 00194 SkyComponent& out, 00195 const MDirection& sp, 00196 const Quantity frequency, 00197 const Quantity parAngle = Quantity(0.0,"deg"), 00198 const BeamSquint::SquintType doSquint = BeamSquint::NONE, 00199 Bool inverse = False, 00200 Float cutoff = 0.01, 00201 Bool forward = True); 00202 SkyComponent& applyPB2(SkyComponent& in, 00203 SkyComponent& out, 00204 const MDirection& sp, 00205 const Quantity frequency, 00206 const Quantity parAngle = Quantity(0.0,"deg"), 00207 const BeamSquint::SquintType doSquint = BeamSquint::NONE); 00208 // </group> 00209 00210 // Which PBClass is this one? 00211 virtual PBClass whichPBClass() = 0; 00212 00213 // Convert PBClass enumeration into PBClass String 00214 void namePBClass(String & name); 00215 00216 // Convert enumeration into a string 00217 static void namePBClass(const PBMathInterface::PBClass iPB, String & str); 00218 00219 // Fit an azimuthally symmetric beam to the squinted or otherwise 2-D beam 00220 // for Stokes I? 00221 virtual void setUseSymmetric(Bool useSym=True) { useSymmetricBeam_p = useSym; } 00222 00223 // Get value of useSymmetric 00224 virtual Bool getUseSymmetric() { return useSymmetricBeam_p; } 00225 00226 // Get the ImageRegion of the primary beam on an Image for a given pointing 00227 // Note: ImageRegion is not necesarily constrained to lie within the 00228 // image region (for example, if the pointing center is near the edge of the 00229 // image). fPad: fractional padding for extra support beyond PB. 00230 // (note: we do not properly treat squint yet, this will cover it for now) 00231 // iChan: frequency channel to take: lowest frequency channel is safe for all 00232 // 00233 // Potential problem: this ImageRegion includes all Stokes and Frequency Channels 00234 // present in the input image. 00235 virtual ImageRegion* extent (const ImageInterface<Complex>& im, const MDirection& pointing, 00236 const Int row, const Float fPad, const Int iChan, 00237 const SkyJones::SizeType) = 0; 00238 virtual ImageRegion* extent (const ImageInterface<Float>& im, const MDirection& pointing, 00239 const Int row, const Float fPad, const Int iChan, 00240 const SkyJones::SizeType) = 0; 00241 00242 00243 00244 virtual Int support (const CoordinateSystem& cs)=0; 00245 00246 // Summarize the Voltage Pattern; 00247 // For PBMath1D, list nValues worth of the PB array 00248 virtual void summary(Int nValues=0); 00249 00250 // Is state of PBMath object OK? 00251 virtual Bool ok()=0; 00252 00253 protected: 00254 00255 // Dumb constructor: protected, as it won't do you any good! 00256 PBMathInterface(); 00257 00258 // lower level helping apply methods 00259 // <group> 00260 00261 virtual 00262 ImageInterface<Complex>& 00263 apply(const ImageInterface<Complex>& in, 00264 ImageInterface<Complex>& out, 00265 const MDirection& sp, 00266 const Quantity parAngle, 00267 const BeamSquint::SquintType doSquint, 00268 Bool Inverse, 00269 Bool Conjugate, 00270 Int ipower, // ie, 1=VP, 2=PB 00271 Float cutoff, 00272 Bool forward) =0; 00273 00274 virtual 00275 ImageInterface<Float>& 00276 apply(const ImageInterface<Float>& in, 00277 ImageInterface<Float>& out, 00278 const MDirection& sp, 00279 const Quantity parAngle, 00280 const BeamSquint::SquintType doSquint, 00281 Float cutoff, const Int ipower=4) =0; 00282 00283 virtual SkyComponent& 00284 apply(SkyComponent& in, 00285 SkyComponent& out, 00286 const MDirection& sp, 00287 const Quantity frequency, 00288 const Quantity parAngle, 00289 const BeamSquint::SquintType doSquint, 00290 Bool Inverse, 00291 Bool Conjugate, 00292 Int ipower, // ie, 1=VP, 2=PB, 4=PB^2 00293 Float cutoff, 00294 Bool forward) =0; 00295 // </group> 00296 00297 00298 // Functions to deal with conversions to Float 00299 // <group> 00300 static Float asFloat(const Complex & value) {return value.real(); } 00301 static Float asFloat(const DComplex & value){return (Float) value.real(); } 00302 static Float asFloat(const Float & value) {return value; } 00303 static Float asFloat(const Double & value) {return (Float) value; } 00304 // </group> 00305 00306 00307 00308 // Are the parameters being provided in the derived class constructor 00309 // describing a Voltage Pattern or a Primary Beam? The default is Voltage 00310 // Pattern, and we keep it internally as a voltage pattern 00311 Bool isThisVP_p; 00312 00313 // Beam squint: convention is AZ-EL offset of the 00314 // Stokes RR beam w.r.t. pointing position 00315 // Stokes LL will be at -squint_p 00316 // Southern observatories have the same AZ-EL and PA definitions as Northern 00317 BeamSquint squint_p; 00318 00319 // Should we use the effective az-symmetrical primary beam? 00320 // Otherwise, use squinted beam; if no squint, no difference 00321 Bool useSymmetricBeam_p; 00322 00323 private: 00324 00325 }; 00326 00327 00328 } //# NAMESPACE CASA - END 00329 00330 #endif 00331