casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PBMath.h
Go to the documentation of this file.
1 //# PBMath.h: Envelope class for PBMath1D and PBMath2D types
2 //# Copyright (C) 1996,1997,1998,1999,2000,2002,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: 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_PBMATH_H
30 #define SYNTHESIS_PBMATH_H
31 
32 #include <casa/aips.h>
43 #include <measures/Measures.h>
45 
46 namespace casacore{
47 
48 class Table;
49 class ImageRegion;
50 class RecordInterface;
51 class CoordinateSystem;
52 }
53 
54 namespace casa { //# NAMESPACE CASA - BEGIN
55 
56 //#forward
57 // <summary> Primary beam envelope class, derived from PBMathInterface </summary>
58 
59 // <use visibility=export>
60 
61 // <reviewed reviewer="" date="" tests="" demos="">
62 
63 // <prerequisite>
64 // <li> <linkto class="SkyJones">SkyJones</linkto> class
65 // <li> <linkto class="BeamSkyJones">BeamSkyJones</linkto> class
66 // <li> <linkto class="PBMathInterface">PBMathInterface</linkto> class
67 // </prerequisite>
68 //
69 // <etymology>
70 // PBMath types do the mathematical operations of the Primary Beamss or
71 // Voltage patterns. This envelope class's name was designed for simplicity.
72 // </etymology>
73 //
74 // <synopsis>
75 // PBMath is an envelope class for the various types of 1D and 2D primary
76 // beam/voltage pattern objects. They all have a common interface defined
77 // by PBMathInterface. The PBMath object has a counted pointer to the
78 // actual PB type; hence, the PBMath object is lightweight and can
79 // be passed around by value in other classes.
80 //
81 // Construct a PBMath via PBMath's enumerated CommonPB type.
82 // <example>
83 // <srcblock>
84 // PBMath wsrtPB(PBMath::WSRT);
85 // PBMath vla_LPB(PBMath::VLA_L); // has L band squint built in
86 // </srcblock>
87 // </example>
88 //
89 // A PBMath can also be constructed by the complete argument list for
90 // the type of PB it holds. Since different PB types can have the same
91 // argument list (PBMath1DPoly and PBMath1DIPoly, for example), the exact
92 // type also needs to be specified via the PBMathInterface::PBClass.
93 //
94 // The main thing you want to do with a primary beam or voltage pattern is
95 // to apply it to an image. The PBMath object forwards its low level
96 // "apply" calls to the letter class's "apply" calls.
97 // <example>
98 // <srcblock>
99 //
100 // casacore::PagedImage<casacore::Float> in;
101 // casacore::PagedImage<casacore::Complex> out;
102 // casacore::MDirection pointingDir(casacore::Quantity(135.0, "deg"), casacore::Quantity(60.0, "deg"),
103 // casacore::MDirection::Ref(casacore::MDirection::J2000));
104 // casacore::Quantity parallacticAngle(26.5, "deg");
105 // PBMath wsrtPB(PBMath::WSRT_LOW);
106 // wsrtPB.applyPB(in, out, pointingDir); // multiply by primary beam
107 // wsrtPB.applyPB(in, out, pointingDir, parallacticAngle, BeamSquint::GOFIGURE,
108 // true, 0.02); // divide by primary beam
109 // wsrtPB.applyVP(in, out, pointingDir); // multiply by voltage pattern
110 // </srcblock>
111 // </example>
112 //
113 // </synopsis>
114 //
115 //
116 // <motivation>
117 // This Envelope class allows the user to create a PBMath object which
118 // can display all the polymorphic traits of PBMath1D classes or
119 // PBMath2D classes.
120 // </motivation>
121 //
122 // <todo asof="98/010/21">
123 // </todo>
124 
125 
126 class PBMath {
127 public:
128 
129  // This enumeration provides a simple way to instantiate the
130  // common primary beam models. They are each represented by one of
131  // the more fundamental PBMath1D types
132  //
133  // New CommonPB Types must go to the end
136  GBT,
146  };
147 
148  enum {
150 
151  // Default constructor, required for casacore::Block<PBMath>
152  PBMath();
153 
154  // Make a PB of common type
155  explicit PBMath(PBMath::CommonPB myPBType, casacore::Bool useSymmetricBeam=false);
156 
157  //Make a PB from a telescopename and frequency
158 
159  PBMath(casacore::String& telescopeName, casacore::Bool useSymmetricBeam=false,
160  casacore::Quantity freq=casacore::Quantity(0.0, "Hz"));
161 
162  //Make a PB by dish diameter
163  PBMath(casacore::Double dishDiam, casacore::Bool useSymmetricBeam, casacore::Quantity freq);
164 
165  // Make a PB from a RecordInterface
166  explicit PBMath(const casacore::RecordInterface& myrec);
167 
168  // Make a Gaussian Primary beam
170  casacore::Quantity maxRad, casacore::Quantity refFreq,
171  casacore::Bool isThisVP=false,
173  casacore::Quantity(0.0, "deg"),
175  casacore::Quantity(1.0, "GHz")),
176  casacore::Bool useSymmetricBeam=false);
177 
178 
179  // Make a casacore::Polynomial, Inverse casacore::Polynomial, or Numeric Primary beam
180  // (These three have identical calling signatures, they can only be distinguished
181  // by the PBClass enumeration)
183  casacore::Quantity maxRad, casacore::Quantity refFreq,
184  casacore::Bool isThisVP=false,
186  casacore::Quantity(0.0, "deg"),
188  casacore::Quantity(1.0, "GHz")),
189  casacore::Bool useSymmetricBeam=false);
190 
191 
192 
193  // Make a Numeric Primary beam (FLOAT!)
195  casacore::Quantity maxRad, casacore::Quantity refFreq,
196  casacore::Bool isThisVP=false,
198  casacore::Quantity(0.0, "deg"),
200  casacore::Quantity(1.0, "GHz")),
201  casacore::Bool useSymmetricBeam=false);
202 
203 
204  // Make a CosPolynomial beam type
207  casacore::Quantity maxRad, casacore::Quantity refFreq,
208  casacore::Bool isThisVP=false,
210  casacore::Quantity(0.0, "deg"),
212  casacore::Quantity(1.0, "GHz")),
213  casacore::Bool useSymmetricBeam=false);
214 
215  // Make an Airy beam type
216  PBMath(PBMathInterface::PBClass theclass, casacore::Quantity dishDiam, casacore::Quantity blockageDiam,
217  casacore::Quantity maxRad, casacore::Quantity refFreq,
219  casacore::Quantity(0.0, "deg"),
221  casacore::Quantity(1.0, "GHz")),
222  casacore::Bool useSymmetricBeam=false);
223 
224  // Make an Image-based beam
230 
231  // Instantiate from a Table
232  // PBMath(const casacore::Table& theTable, casacore::Int row);
233 
234 
235  // copy ctor: copies the reference counted pointer
236  PBMath(const PBMath &other);
237 
238  // destructor
239  virtual ~PBMath();
240 
241  //operator= returns a reference to the PBMath; reference counted pointer
242  PBMath& operator=(const PBMath& other);
243 
244  // comparison operator: just checks that the objects are same
245  // (could have two different objects with identical data, these are treated
246  // as !=)
247  casacore::Bool operator==(const PBMath& other) const;
248 
249  // comparison operator: just checks that the objects are different
250  // (could have two different objects with identical data, these are treated
251  // as !=)
252  casacore::Bool operator!=(const PBMath& other) const;
253 
254  // copy() returns a copy of the PBMath
255  // PBMath copy() const;
256 
257 
258  // Apply Jones matrix to an image (and adjoint)
259  // <group>
260 
263  const casacore::MDirection& sp,
264  const casacore::Quantity parAngle = casacore::Quantity(0.0,"deg"),
265  const BeamSquint::SquintType doSquint = BeamSquint::NONE,
266  casacore::Bool inverse = false,
267  casacore::Bool conjugate = false,
268  casacore::Float cutoff = 0.01,
269  casacore::Bool forward=true);
270 
273  const casacore::MDirection& sp,
274  const casacore::Quantity parAngle = casacore::Quantity(0.0,"deg"),
275  const BeamSquint::SquintType doSquint = BeamSquint::NONE,
276  casacore::Bool inverse = false,
277  casacore::Float cutoff = 0.01,
278  casacore::Bool forward = true);
279 
282  const casacore::MDirection& sp,
283  const casacore::Quantity parAngle = casacore::Quantity(0.0,"deg"),
284  const BeamSquint::SquintType doSquint = BeamSquint::NONE,
285  casacore::Float cutoff = 0.01);
286 
287 
290  const casacore::MDirection& sp,
291  const casacore::Quantity parAngle = casacore::Quantity(0.0,"deg"),
292  const BeamSquint::SquintType doSquint = BeamSquint::NONE,
293  casacore::Float cutoff=0.01);
294  // </group>
295 
296  // Apply Jones matrix to a sky component (and adjoint)
297  // <group>
299  SkyComponent& out,
300  const casacore::MDirection& sp,
301  const casacore::Quantity frequency,
302  const casacore::Quantity parAngle = casacore::Quantity(0.0,"deg"),
303  const BeamSquint::SquintType doSquint = BeamSquint::NONE,
304  casacore::Bool inverse = false,
305  casacore::Bool conjugate = false,
306  casacore::Float cutoff = 0.01,
307  casacore::Bool forward = true);
308 
310  SkyComponent& out,
311  const casacore::MDirection& sp,
312  const casacore::Quantity frequency,
313  const casacore::Quantity parAngle = casacore::Quantity(0.0,"deg"),
314  const BeamSquint::SquintType doSquint = BeamSquint::NONE,
315  casacore::Bool inverse = false,
316  casacore::Float cutoff = 0.01,
317  casacore::Bool forward = true);
318 
320  SkyComponent& out,
321  const casacore::MDirection& sp,
322  const casacore::Quantity frequency,
323  const casacore::Quantity parAngle = casacore::Quantity(0.0,"deg"),
324  const BeamSquint::SquintType doSquint = BeamSquint::NONE);
325  // </group>
326 
327 
328 
329 
330 
331 
332  // Fit an azimuthally symmetric beam to the squinted or otherwise 2-D beam
333  // for casacore::Stokes I?
334  void setUseSymmetric(casacore::Bool useSym=true) { pb_pointer_p->setUseSymmetric(useSym); }
335 
336  // Get value of useSymmetric
337  casacore::Bool getUseSymmetric() { return pb_pointer_p->getUseSymmetric(); }
338 
339  // Get the type of PB this is
340  PBMathInterface::PBClass whichPBClass() { return pb_pointer_p->whichPBClass(); }
341 
342  // Summarize the Voltage Pattern;
343  void summary(casacore::Int nValues=0);
344 
345  // Is the state of the PBMath OK?
346  casacore::Bool ok() const;
347 
348  // Get the BLC, TRC of the primary beam on an Image for a given pointing
349  // Note: BLC and TRC are not necesarily constrained to lie within the
350  // image region (for example, if the pointing center is near the edge of the
351  // image). fPad: extra fractional padding above PB support
352  // (note: we do not properly treat squint yet, this will cover it for now)
353  // iChan: frequency channel to take: lowest frequency channel is safe for all
355  const casacore::MDirection& pointing,
356  const casacore::Int row,
357  const casacore::Float fPad,
358  const casacore::Int iChan,
359  const SkyJones::SizeType);
361  const casacore::MDirection& pointing,
362  const casacore::Int row,
363  const casacore::Float fPad,
364  const casacore::Int iChan,
365  const SkyJones::SizeType);
366 
368 
369  // given the Telescope name and the frequency, guess the most approrpiate
370  // CommonPB primary beam type and the band
371  static void whichCommonPBtoUse (casacore::String &telescope, casacore::Quantity &freq,
372  casacore::String &band, PBMath::CommonPB &whichPB,
373  casacore::String &pbName);
374 
375  // converts the enumrated type into a string
376  static void nameCommonPB(const PBMath::CommonPB iPB, casacore::String & str);
377 
378  // converts the PB casacore::String into an enumrated type
379  static void enumerateCommonPB(const casacore::String & str, PBMath::CommonPB &ipb);
380 
381 
382  // return a PBMathInteface for a commonPB ; caller needs to delete pointer
383  static PBMathInterface* pbMathInterfaceForCommonPB(const PBMath::CommonPB ipb, bool useSymmetricBeam);
384 
385  // return a PBMathInteface from a Vpmanager record ; caller needs to delete pointer
387  // gives the name of the PB Class that has been used
388  void namePBClass(casacore::String & name) { pb_pointer_p->namePBClass(name); }
389 
390 
391  // Gradient stuff: this needs more thought, as it is not
392  // really connected with the stuff in VPSkyJones and all.
393  // This will return the partial derivatives of chi^2 w.r.t
394  // the beam model parameters, represented here as a vector.
395  // Not implemented yet.
396  // void parameterGradient(casacore::Vector<casacore::Float> grad);
397 
398  // Flush the construction parameters to disk
399  // This is a public method because this class doesn't know what Table
400  // it is to be stored in
401 
402  //virtual casacore::Bool flushToTable(casacore::Table& beamSubTable, casacore::Int iRow);
403 
404 
405 protected:
406 
407  // polymorphic lower level helping apply methods
408  // <group>
411  const casacore::MDirection& sp,
412  const casacore::Quantity parAngle,
413  const BeamSquint::SquintType doSquint,
416  casacore::Int ipower, // ie, 1=VP, 2=PB
417  casacore::Float cutoff=0.01,
418  casacore::Bool forward=true);
419 
421  SkyComponent& out,
422  const casacore::MDirection& sp,
423  const casacore::Quantity frequency,
424  const casacore::Quantity parAngle,
425  const BeamSquint::SquintType doSquint,
428  casacore::Int ipower, // ie, 1=VP, 2=PB, 4=PB^2
429  casacore::Float cutoff=0.01,
430  casacore::Bool forward=true);
431  // </group>
432 
433 
434 private:
435 
437 
438 
439  // These should probably move to casacore::RecordInterface when we are happy with their performance
440  // <group>
441 
443  casacore::Quantity& returnedQuantity) ;
445  casacore::MDirection& returnedMDirection);
446  //casacore::Function to initialize the state of the tool
447  void initByTelescope(PBMath::CommonPB myPBType, casacore::Bool useSymmetricBeam=false,
448  casacore::Double frequency=0.0);
449 
450  //casacore::Function to initialize the by dish diameter
451  void initByDiameter(casacore::Double diam, casacore::Bool useSymmetricBeam, casacore::Double freq);
452 
453  // </group>
454 
455 };
456 
457 
458 
459 } //# NAMESPACE CASA - END
460 
461 #endif
static casacore::Bool getMDirection(const casacore::RecordInterface &rec, const casacore::String &item, casacore::MDirection &returnedMDirection)
casacore::ImageInterface< casacore::Complex > & applyVP(const casacore::ImageInterface< casacore::Complex > &in, casacore::ImageInterface< casacore::Complex > &out, const casacore::MDirection &sp, const casacore::Quantity parAngle=casacore::Quantity(0.0,"deg"), const BeamSquint::SquintType doSquint=BeamSquint::NONE, casacore::Bool inverse=false, casacore::Bool conjugate=false, casacore::Float cutoff=0.01, casacore::Bool forward=true)
copy() returns a copy of the PBMath PBMath copy() const;
A Measure: astronomical direction.
Definition: MDirection.h:174
CommonPB
This enumeration provides a simple way to instantiate the common primary beam models.
Definition: PBMath.h:134
int Int
Definition: aipstype.h:50
static void nameCommonPB(const PBMath::CommonPB iPB, casacore::String &str)
converts the enumrated type into a string
casacore::Bool operator==(const PBMath &other) const
comparison operator: just checks that the objects are same (could have two different objects with ide...
encapsulates beam squint (RR and LL beams at different directions)
Definition: BeamSquint.h:101
static void whichCommonPBtoUse(casacore::String &telescope, casacore::Quantity &freq, casacore::String &band, PBMath::CommonPB &whichPB, casacore::String &pbName)
given the Telescope name and the frequency, guess the most approrpiate CommonPB primary beam type and...
static void enumerateCommonPB(const casacore::String &str, PBMath::CommonPB &ipb)
converts the PB casacore::String into an enumrated type
Primary beam envelope class, derived from PBMathInterface.
Definition: PBMath.h:126
SquintType
Allowed Squints: NONE = no squint: PB is centered on the pointing center RR = PB is shifted from poin...
Definition: BeamSquint.h:109
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
PBClass
Allowed PBMath Classes.
PBMathInterface::PBClass whichPBClass()
Get the type of PB this is.
Definition: PBMath.h:340
void initByTelescope(PBMath::CommonPB myPBType, casacore::Bool useSymmetricBeam=false, casacore::Double frequency=0.0)
casacore::Function to initialize the state of the tool
casacore::ImageRegion * extent(const casacore::ImageInterface< casacore::Complex > &im, const casacore::MDirection &pointing, const casacore::Int row, const casacore::Float fPad, const casacore::Int iChan, const SkyJones::SizeType)
Get the BLC, TRC of the primary beam on an Image for a given pointing Note: BLC and TRC are not neces...
casacore::ImageInterface< casacore::Complex > & apply(const casacore::ImageInterface< casacore::Complex > &in, casacore::ImageInterface< casacore::Complex > &out, const casacore::MDirection &sp, const casacore::Quantity parAngle, const BeamSquint::SquintType doSquint, casacore::Bool inverse, casacore::Bool conjugate, casacore::Int ipower, casacore::Float cutoff=0.01, casacore::Bool forward=true)
Gradient stuff: this needs more thought, as it is not really connected with the stuff in VPSkyJones a...
casacore::ImageInterface< casacore::Float > & applyPB2(const casacore::ImageInterface< casacore::Float > &in, casacore::ImageInterface< casacore::Float > &out, const casacore::MDirection &sp, const casacore::Quantity parAngle=casacore::Quantity(0.0,"deg"), const BeamSquint::SquintType doSquint=BeamSquint::NONE, casacore::Float cutoff=0.01)
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
PBMath()
Default constructor, required for casacore::Block&lt;PBMath&gt;
casacore::Matrix< T > inverse(const casacore::Matrix< T > &A)
PBMath & operator=(const PBMath &other)
operator= returns a reference to the PBMath; reference counted pointer
double Double
Definition: aipstype.h:55
void namePBClass(casacore::String &name)
gives the name of the PB Class that has been used
Definition: PBMath.h:388
casacore::CountedPtr< PBMathInterface > pb_pointer_p
Definition: PBMath.h:436
casacore::Bool getUseSymmetric()
Get value of useSymmetric.
Definition: PBMath.h:337
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
float Float
Definition: aipstype.h:54
virtual ~PBMath()
destructor
Class to hold a region of interest in an image.
Definition: ImageRegion.h:86
void initByDiameter(casacore::Double diam, casacore::Bool useSymmetricBeam, casacore::Double freq)
casacore::Function to initialize the by dish diameter
void setUseSymmetric(casacore::Bool useSym=true)
Fit an azimuthally symmetric beam to the squinted or otherwise 2-D beam for casacore::Stokes I...
Definition: PBMath.h:334
A component of a model of the sky.
Definition: SkyComponent.h:130
static PBMathInterface * pbMathInterfaceForCommonPB(const PBMath::CommonPB ipb, bool useSymmetricBeam)
return a PBMathInteface for a commonPB ; caller needs to delete pointer
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Virtual base class defining the Primary Beam interface.
Abstract base class for Record classes.
Matrix< casacore::Complex > conjugate(const casacore::Matrix< casacore::Complex > &A)
complex space function specifications
virtual casacore::Int support(const casacore::CoordinateSystem &cs)
static casacore::Bool getQuantity(const casacore::RecordInterface &rec, const casacore::String &item, casacore::Quantity &returnedQuantity)
These should probably move to casacore::RecordInterface when we are happy with their performance...
casacore::Bool ok() const
Is the state of the PBMath OK?
casacore::ImageInterface< casacore::Complex > & applyPB(const casacore::ImageInterface< casacore::Complex > &in, casacore::ImageInterface< casacore::Complex > &out, const casacore::MDirection &sp, const casacore::Quantity parAngle=casacore::Quantity(0.0,"deg"), const BeamSquint::SquintType doSquint=BeamSquint::NONE, casacore::Bool inverse=false, casacore::Float cutoff=0.01, casacore::Bool forward=true)
casacore::Bool operator!=(const PBMath &other) const
comparison operator: just checks that the objects are different (could have two different objects wit...
Interconvert pixel and world coordinates.
void summary(casacore::Int nValues=0)
Summarize the Voltage Pattern;.
static PBMathInterface * pbMathInterfaceFromRecord(const casacore::RecordInterface &rec)
return a PBMathInteface from a Vpmanager record ; caller needs to delete pointer
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42