casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PBMath1D.h
Go to the documentation of this file.
1 //# PBMath1D.h: Definitions of interface for 1-D 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: 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_PBMATH1D_H
30 #define SYNTHESIS_PBMATH1D_H
31 
32 #include <casa/aips.h>
34 
35 namespace casacore{
36 
37 class Table;
38 class ImageRegion;
39 class CoordinateSystem;
40 }
41 
42 namespace casa { //# NAMESPACE CASA - BEGIN
43 
44 //#forward
45 class SkyComponent;
46 
47 // <summary> base class for 1D PBMath objects </summary>
48 
49 
50 // <use visibility=export>
51 
52 // <reviewed reviewer="" date="" tests="" demos="">
53 
54 // <prerequisite>
55 // <li> <linkto class="SkyJones">SkyJones</linkto> class
56 // <li> <linkto class="BeamSkyJones">BeamSkyJones</linkto> class
57 // <li> <linkto class="PBMathInterface">PBMathInterface</linkto> class
58 // </prerequisite>
59 //
60 // <etymology>
61 // PBMath types do the mathematical operations of the PB's or VP's.
62 // This is the base class for the 1D (ie, rotationally symmetric) PB's.
63 // </etymology>
64 //
65 // <synopsis>
66 // PBMath1D, the virtual base class for 1D PBMath objects, is
67 // derived from PBMathInterface. Its cousin, PBMath2D, can deal with
68 // inherently 2D voltage patterns or primary beams. PBMath1D can deal
69 // with beam squint, (ie, the offset of the LL and RR beams on opposite
70 // sides of the pointing center) which rotates on the sky with parallactic angle.
71 //
72 // The 1D PB philosophy is to specify the Voltage pattern or Primary Beam
73 // via a small number of
74 // parameters via one of the derived types (PBMath1DGauss, for example). The
75 // derived type knows how to instantiate itself from a row in a beam subTable,
76 // and how to convert itself into a lookup vector. The lookup vector is
77 // fine enough that no interpolation need be done when finding the nearest
78 // PB or VP value for a particular pixel (currently, there are 1e+4 elements
79 // in the lookup vector, so on average, an error on order of 1e-4 is made
80 // when applying the primary beam).
81 //
82 // There are two ways of creating the derived PB types:
83 // 1) explicitly create one of the babies. You have control
84 // over the details such as PB size and total extent, the reference
85 // frequency at which this size is true (the size scales inversely
86 // with wavelength), the squint orientation, and whether a mean
87 // symmetrized beam will be calculated from the squinted beam.
88 // (Nice defaults can reduce the arguments in most cases.)
89 // <example>
90 // <srcblock>
91 // PBMath1DGauss myPB (casacore::Quantity(1.0, "'"), casacore::Quantity(3.0, "'"), casacore::Quantity(1.0, "GHz"),
92 // false, // these are PB parameters, not VP
93 // BeamSquint(casacore::MDirection(casacore::Quantity(2.0, "\""),
94 // casacore::Quantity(0.0, "\""),
95 // casacore::MDirection::Ref(casacore::MDirection::AZEL)),
96 // casacore::Quantity(2.0, "GHz")),
97 // false);
98 // PBMath1DGauss myPB2 (casacore::Quantity(1.0, "'"), casacore::Quantity(3.0, "'"), casacore::Quantity(1.0, "GHz"));
99 //
100 // </srcblock>
101 // </example>
102 // 2) via the envelope class PBMath's enumerated CommonPB type. This is much simpler,
103 // and will deal with a majority of the cases required:
104 // <example>
105 // <srcblock>
106 // PBMath wsrtPB(PBMath::WSRT);
107 // PBMath vla_LPB(PBMath::VLA_L); // has L band squint built in
108 // </srcblock>
109 // </example>
110 //
111 // The main thing you want to do with a primary beam or voltage pattern is
112 // to apply it to an image. The top level "apply" methods are defined in
113 // PBMathInterface. They are applyPB, applyPB2, applyVP. These top level
114 // apply's then call a lower level private polymorphic apply, which are defined
115 // in PBMath1D and in PBMath2D. These two different apply's deal with the
116 // different details of 1D and 2D primary beam application.
117 // <example>
118 // <srcblock>
119 //
120 // casacore::PagedImage<casacore::Float> in;
121 // casacore::PagedImage<casacore::Complex> out;
122 // casacore::MDirection pointingDir(casacore::Quantity(135.0, "deg"), casacore::Quantity(60.0, "deg"),
123 // casacore::MDirection::Ref(casacore::MDirection::J2000));
124 // casacore::Quantity parallacticAngle(26.5, "deg");
125 // PBMath wsrtPB(PBMath::WSRT_LOW);
126 // wsrtPB.applyPB(in, out, pointingDir); // multiply by primary beam
127 // wsrtPB.applyPB(in, out, pointingDir, parallacticAngle, BeamSquint::GOFIGURE,
128 // true, 0.02); // divide by primary beam
129 // wsrtPB.applyVP(in, out, pointingDir); // multiply by voltage pattern
130 //
131 // </srcblock>
132 // </example>
133 // </synopsis>
134 //
135 // <motivation>
136 // All of the 1-D PB types have everything in common except for the
137 // details of their parameterization.
138 // </motivation>
139 //
140 // lower level helping apply methods: reduce code by this bundling
141 // <thrown>
142 // <li> casacore::AipsError - in apply(Image...), if in and out images are
143 // inconsistent in shape or coordinates
144 // <li> casacore::AipsError - in apply(SkyComponent...), if doSqiont==RR or LL
145 // </thrown>
146 // <todo asof="98/010/21">
147 // <li> SymmetrizeBeam doesn't do anything yet. (It should calculate
148 // the mean symmetric beam about the pointing center when
149 // squint is present, slightly larger than the symmetric beam
150 // about the squint position.
151 // </todo>
152 
153 
154 class PBMath1D : public PBMathInterface {
155 public:
156 
157  // required so PBMath can see the protected "apply" method
158  // Other derivatives of PBMathInterface, such as PBMath2D, will
159  // also require friend class PBMath;
160  friend class PBMath;
161 
162  PBMath1D(casacore::Quantity maximumRadius,
163  casacore::Quantity refFreq,
164  casacore::Bool isThisVP,
165  BeamSquint squint,
166  casacore::Bool useSymmetricBeam);
167 
168  virtual ~PBMath1D() = 0;
169 
170  // Get the PB in a vector to look at
171  // Concerning n_elements: they are evenly spaced between 0 and maxradius.
172  // r is in units of arcminutes at 1 GHz
174  casacore::Int n_elements, const casacore::Double freq=1.0e9);
175 
176  // Summarize the Voltage Pattern;
177  // For PBMath1D, list nValues worth of the VP array
178  virtual void summary(casacore::Int nValues=0);
179 
180  // Is state of PBMath OK?
181  virtual casacore::Bool ok();
182 
183  // Get the casacore::ImageRegion of the primary beam on an Image for a given pointing
184  // Note: casacore::ImageRegion is not necesarily constrained to lie within the
185  // image region (for example, if the pointing center is near the edge of the
186  // image). fPad: extra fractional padding, beyond Primary Beam support
187  // (note: we do not properly treat squint yet, this will cover it for now)
188  // iChan: frequency channel to take: lowest frequency channel is safe for all
189  //
190  // Potential problem: this casacore::ImageRegion includes all casacore::Stokes and Frequency Channels
191  // present in the input image.
193  const casacore::MDirection& pointing,
194  const casacore::Int irow,
195  const casacore::Float fPad,
196  const casacore::Int iChan,
197  const SkyJones::SizeType sizeType);
199  const casacore::MDirection& pointing,
200  const casacore::Int irow,
201  const casacore::Float fPad,
202  const casacore::Int iChan,
203  const SkyJones::SizeType sizeType);
204 
205 
207 
208 
209 protected:
210 
211  // Protect default constructor: this will do you no good
212  PBMath1D();
213 
214  // calculate the limited box of the Primary Beam model's support,
215  // return in blc and trc (which are NOT contrained to be inside
216  // the image
217  void extentguts (const casacore::CoordinateSystem& coords, const casacore::MDirection& pointing,
219 
220  // push blc lower, trc higher such that they define an image which is
221  // a power of 2 in size.
222 
223  // Adjust blc and trc such that they are within the image and such that they
224  // create an image with power of 2 (SkyJones::POWEROF2) shape or
225  // composite number (SkyJones::COMPOSITE) shape
228 
229 
232  const casacore::MDirection& sp,
233  const casacore::Quantity parAngle,
234  const BeamSquint::SquintType doSquint,
237  casacore::Int ipower, // ie, 1=VP, 2=PB, 4=PB^2
238  casacore::Float cutoff,
239  casacore::Bool forward);
240 
241 
244  const casacore::MDirection& sp,
245  const casacore::Quantity parAngle,
246  const BeamSquint::SquintType doSquint,
247  casacore::Float cutoff,
248  const casacore::Int ipower=4); //only 2 values allowed 2 and 4
249  //PB and PB^2
250 
252  SkyComponent& out,
253  const casacore::MDirection& sp,
254  const casacore::Quantity frequency,
255  const casacore::Quantity parAngle,
256  const BeamSquint::SquintType doSquint,
259  casacore::Int ipower, // ie, 1=VP, 2=PB, 4=PB^2
260  casacore::Float cutoff,
261  casacore::Bool forward);
262 
263 
264  // Fill in PB_p array from construction parameters, rescale construction
265  // parameters to the 1 GHz internal reference frequency
266  // Eventually: create it as its needed; we've got 4 arrays to fill;
267  // only create and store as they are required
268  // Right now: just construct all arrays
269  virtual void fillPBArray()=0;
270 
272 
273  virtual void nearestVPArray(double freq, bool printINFO=true);
274 
275 
276  // Helper method to fit a circularly symmetric beam to the
277  // squinted RR + LL beam. Called upon construction. Build this later.
278  // PB' = azimuthal fit to: ( VP(x+s)**2 + VP(x-s)**2 )/2
279  // VP' = sqrt(PB')
280  void symmetrizeSquintedBeam();
281 
282  void applyXLine(const casacore::Complex*& in, casacore::Complex*& out, casacore::Float*& rx2, casacore::Complex*& vp, const casacore::Float ry2, const casacore::Int ipower, const casacore::Bool conjugate, const casacore::Bool inverse, const casacore::Bool forward, const casacore::Int nx, const casacore::Int iy, const casacore::Double rmax2, const casacore::Double factor, const casacore::Double inverseIncrementRadius, const casacore::Float cutoff);
283  // The parameterized representation is for the VP, not the PB.
284  // Internally, a reference frequency of 1 GHz is used, and the
285  // radius is in units of arcminutes.
286  // That said, you can specify the voltage pattern in any
287  // units, at any frequency, but they will be converted
288  // into (1 GHz * arcminutes) for storage and internal use.
289  // We fill in the lookup vectors VP, PB, esVP, esPB,
290  // as they are asked for
291  // <group>
292  // Tabulated voltage pattern
294 
295  // Tabulated effective az-symmetrical voltage pattern
296  // ( optional, depending upon useSymmetric_p )
298  // </group>
299 
300  // Tabulated voltage pattern for wide band feed
301  // First axis is radius, 2nd axis is frequency
303 
304  // Switch to use wideband beam fits
306 
307  // Wideband beam fit frequencies.
308  // Equally spaced beam fits across frequency range of the feed
310 
311  // Maximum radius allowed in tabulated model
313 
314  // reference frequency: used for squint and other
315  // beam paramaters such as width, found in derived types.
316  // Internally, we rescale everything
317  // to a reference frequency of 1 GHz
319 
320  // internal scaling from refFreq_p to 1GHz; used during construction
322 
323  // Increment in radius
325 
326  // Scale to convert to tabulated units
328 
329  // casacore::CompositeNumber (for beam application and the like)
331 
332 private:
333 
334 };
335 
336 
337 } //# NAMESPACE CASA - END
338 
339 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
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, casacore::Bool forward)
lower level helping apply methods
A Measure: astronomical direction.
Definition: MDirection.h:174
virtual casacore::Int support(const casacore::CoordinateSystem &cs)
int Int
Definition: aipstype.h:50
casacore::CompositeNumber composite_p
casacore::CompositeNumber (for beam application and the like)
Definition: PBMath1D.h:330
casacore::Quantity maximumRadius_p
Maximum radius allowed in tabulated model.
Definition: PBMath1D.h:312
encapsulates beam squint (RR and LL beams at different directions)
Definition: BeamSquint.h:101
base class for 1D PBMath objects
Definition: PBMath1D.h:154
This class generates composite numbers.
casacore::Double scale_p
Scale to convert to tabulated units.
Definition: PBMath1D.h:327
casacore::Vector< casacore::Complex > esvp_p
Tabulated effective az-symmetrical voltage pattern (optional, depending upon useSymmetric_p) ...
Definition: PBMath1D.h:297
void refineSize(casacore::Vector< casacore::Float > &blc, casacore::Vector< casacore::Float > &trc, const casacore::IPosition &shape, SkyJones::SizeType)
push blc lower, trc higher such that they define an image which is a power of 2 in size...
void extentguts(const casacore::CoordinateSystem &coords, const casacore::MDirection &pointing, const casacore::Float fPad, const casacore::Int iChan, casacore::Vector< casacore::Float > &blc, casacore::Vector< casacore::Float > &trc)
calculate the limited box of the Primary Beam model&#39;s support, return in blc and trc (which are NOT c...
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
void viewPB(casacore::Vector< casacore::Float > &r, casacore::Vector< casacore::Float > &PB, casacore::Int n_elements, const casacore::Double freq=1.0e9)
Get the PB in a vector to look at Concerning n_elements: they are evenly spaced between 0 and maxradi...
void symmetrizeSquintedBeam()
Helper method to fit a circularly symmetric beam to the squinted RR + LL beam.
casacore::Vector< casacore::Double > wFreqs_p
Wideband beam fit frequencies.
Definition: PBMath1D.h:309
casacore::Double inverseIncrementRadius_p
Increment in radius.
Definition: PBMath1D.h:324
casacore::Matrix< T > inverse(const casacore::Matrix< T > &A)
double Double
Definition: aipstype.h:55
casacore::Bool wideFit_p
Switch to use wideband beam fits.
Definition: PBMath1D.h:305
virtual void summary(casacore::Int nValues=0)
Summarize the Voltage Pattern; For PBMath1D, list nValues worth of the VP array.
For wideband beams fill the tabulated vp_p by the interpolated beam at the freq *virtual void nearestVPArray(double freq, bool printINFO=true)
void applyXLine(const casacore::Complex *&in, casacore::Complex *&out, casacore::Float *&rx2, casacore::Complex *&vp, const casacore::Float ry2, const casacore::Int ipower, const casacore::Bool conjugate, const casacore::Bool inverse, const casacore::Bool forward, const casacore::Int nx, const casacore::Int iy, const casacore::Double rmax2, const casacore::Double factor, const casacore::Double inverseIncrementRadius, const casacore::Float cutoff)
virtual casacore::Bool ok()
Is state of PBMath OK?
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void fillPBArray()=0
Fill in PB_p array from construction parameters, rescale construction parameters to the 1 GHz interna...
float Float
Definition: aipstype.h:54
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
Class to hold a region of interest in an image.
Definition: ImageRegion.h:86
PBMath1D()
Protect default constructor: this will do you no good.
A component of a model of the sky.
Definition: SkyComponent.h:130
casacore::Double fScale_p
internal scaling from refFreq_p to 1GHz; used during construction
Definition: PBMath1D.h:321
casacore::Quantity refFreq_p
reference frequency: used for squint and other beam paramaters such as width, found in derived types...
Definition: PBMath1D.h:318
casacore::Matrix< casacore::Complex > wbvp_p
Tabulated voltage pattern for wide band feed First axis is radius, 2nd axis is frequency.
Definition: PBMath1D.h:302
Virtual base class defining the Primary Beam interface.
casacore::ImageRegion * extent(const casacore::ImageInterface< casacore::Complex > &in, const casacore::MDirection &pointing, const casacore::Int irow, const casacore::Float fPad, const casacore::Int iChan, const SkyJones::SizeType sizeType)
Get the casacore::ImageRegion of the primary beam on an Image for a given pointing Note: casacore::Im...
casacore::Vector< casacore::Complex > vp_p
The parameterized representation is for the VP, not the PB.
Definition: PBMath1D.h:293
Matrix< casacore::Complex > conjugate(const casacore::Matrix< casacore::Complex > &A)
complex space function specifications
Interconvert pixel and world coordinates.
virtual ~PBMath1D()=0
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42