casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BeamSkyJones.h
Go to the documentation of this file.
1 //# BeamSkyJones.h: Definitions of interface for BeamSkyJones
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_TRANSFORM2_BEAMSKYJONES_H
30 #define SYNTHESIS_TRANSFORM2_BEAMSKYJONES_H
31 
32 #include <casa/aips.h>
33 #include <casa/Containers/Block.h>
34 #include <casa/Exceptions/Error.h>
36 #include <measures/Measures.h>
41 
42 namespace casacore{
43 
44 class ImageRegion;
45 class String;
46 template <typename T> class Vector;
47 }
48 
49 namespace casa {
50 //#forward
51 //# Need forward declaration for Solve in the Jones Matrices
52 
53 class SkyModel;
54 
55 namespace refim { //# namespace for refactoring
56 
57 
58 // <summary> beam-like sky-plane effects for the SkyEquation </summary>
59 
60 // <use visibility=export>
61 
62 // <reviewed reviewer="" date="" tests="" demos="">
63 
64 // <prerequisite>
65 // <li> <linkto class="SkyEquation">SkyEquation</linkto> class
66 // <li> <linkto class="SkyJones">SkyJones</linkto> class
67 // <li> <linkto class="PBMathInterface">PBMathInterface</linkto> class
68 // </prerequisite>
69 //
70 // <etymology>
71 // BeamSkyJones, derived from SkyJones, describes an interface to
72 // beam-based SkyJones objects. Like SkyJones, it too is an Abstract
73 // Base Class, but implements the beam-related methods.
74 // </etymology>
75 //
76 // <synopsis>
77 //
78 // <motivation>
79 // The properties of sky-plane based calibration effects must be described
80 // for the <linkto class="SkyEquation">SkyEquation</linkto>; this class
81 // encapsulates the antenna beam-based aspects which are present in at least
82 // a few other specific SkyJones (VPSkyJones and DBeamSkyJones).
83 // </motivation>
84 //
85 // <todo asof="98/11/01">
86 // <li> Solvable part needs implementation: we need to derive an
87 // image of gradients of the elements of the Jones matrix. See VisJones
88 // for how to do this.
89 // <li> The casacore::MS, version II, will have a beam subtable, which will have PBMaths
90 // for each antenna. Until this becomes available, we need to do some
91 // fudging; for example, we
92 // </todo>
93 
94 class BeamSkyJones : virtual public SkyJones {
95 
96 public:
97 
98  // Eventually, the casacore::MS will have all the beam information in its Beam Subtable.
99  // Till then, we either guess the PB to use or explicitly define it upon construction.
100  // Construct from a Measurement Set, figure out the most appropriate PBMath object
101  // from casacore::MS information
102  BeamSkyJones(const casacore::Quantity &parallacticAngleIncrement = casacore::Quantity(720.0, "deg"), // def= 1 PA interval
103  BeamSquint::SquintType doSquint = BeamSquint::NONE, // def= no beam squint offsets
104  const casacore::Quantity &skyPositionThreshold = casacore::Quantity(180,"deg")); // def= assume there is no change of
105  // this operator due to position offset
106 
107 
108  // Virtual destructor (this is a virtual base class)
109  virtual ~BeamSkyJones() = 0;
110 
111  // Print out information concerning the state of this object
112  virtual void showState(casacore::LogIO& os);
113 
114  // Apply Jones matrix to an image (and adjoint)
115  // No "applyInverse" is available from the SkyJones classes,
116  // you can get them directly from PBMath or you can get
117  // the equivalent effect by dividing by grad grad Chi^2
118  // in ImageSkyModel.
119  // <group>
122  const vi::VisBuffer2& vb, casacore::Int row,
123  casacore::Bool forward=true);
126  const vi::VisBuffer2& vb, casacore::Int row);
127 
130  const vi::VisBuffer2& vb, casacore::Int row);
131  // </group>
132 
133  // Apply Jones matrix to a sky component (and adjoint)
134  // <group>
136  SkyComponent& out,
137  const vi::VisBuffer2& vb, casacore::Int row,
138  casacore::Bool forward = true);
140  SkyComponent& out,
141  const vi::VisBuffer2& vb, casacore::Int row);
142  // </group>
143 
144  // Understand if things have changed since last PB application
145  // <group>
146 
147  // Reset to pristine state
148  virtual void reset();
149 
150  // Has this operator changed since the last Application?
151  // (or more properly, since the last update() )
152  virtual casacore::Bool changed(const vi::VisBuffer2& vb, casacore::Int row);
153 
154  // Does the operator change in this visbuffer or since the last call?
155  // May not be useful -- check it out: m.a.h. Dec 30 1999
156  virtual casacore::Bool change(const vi::VisBuffer2& vb);
157 
158  // Does this operator changed in this VisBuffer,
159  // starting with row1?
160  // If yes, we return in row2, the last row that has the
161  // same SkyJones as row1.
162  // NOTE: need to first call changed(const VisBuffer& vb, casacore::Int row) and
163  // shield the user from the case where the fieldID has changed
164  // (which only changes in blocks)
166 
167  // Update the FieldID, Telescope, pointingDirection, Parallactic angle info
168  void update(const vi::VisBuffer2& vb, casacore::Int row);
169 
170  // if (changed) {update()}
171  virtual void assure (const vi::VisBuffer2& vb, casacore::Int row);
172  // </group>
173 
174  // Return the type of this Jones matrix (actual type of derived class).
176 
177  // Apply gradient
180  casacore::Int row);
181 
182  virtual SkyComponent&
183  applyGradient(SkyComponent& result, const vi::VisBuffer2& vb,
184  casacore::Int row);
185 
186  // Is this solveable?
187  virtual casacore::Bool isSolveable() {return false;};
188 
189  // Initialize for gradient search
190  virtual void initializeGradients();
191 
192  // Finalize for gradient search
193  virtual void finalizeGradients();
194 
195  // Add to Gradient Chisq
196  virtual void addGradients(const vi::VisBuffer2& vb, casacore::Int row, const casacore::Float sumwt,
199 
200  // Solve
201  //virtual casacore::Bool solve (SkyEquation& se);
202 
203  // Manage the PBMath objects
204  // <group>
205  // set the PB based on telescope name, antennaID and feedID
206  // If antennaID or feedID is -1, the PBMath object is set for
207  // all antennae or feeds, respectively. These are the default
208  // values to retain the previous interface.
209  //
210  // Note. It would be nice to change the interface and make antennaID
211  // and feedID the second and the third parameter, respectively.
212  void setPBMath(const casacore::String &telescope, PBMath &myPBmath,
213  const casacore::Int &antennaID = -1, const casacore::Int &feedID = -1);
214 
215  // get the PBMath object; returns false if that one doesn't exist,
216  // true if it does exist and is OK
217  // whichAnt is an index into an array of PBMaths, which is different
218  // for all telescope/antenna/feed combinations
219  // Not sure why we need such a low-level method declared as public,
220  // retained to preserve old interface
221  casacore::Bool getPBMath(casacore::uInt whichAnt, PBMath &myPBMath) const;
222 
223  // get the PBMath object; returns false if that one doesn't exist,
224  // true if it does exist and is OK
225  // antennaID and feedID default to -1 to preserve the old interface
226  // TODO: change the interface and make antennaID and feedID the
227  // second and third parameter respectively to have a better looking code
229  const casacore::Int &antennaID = -1, const casacore::Int &feedID = -1) const;
230 
232 
234 
235  // Return true if all antennas share a common VP
237  //</group>
238 
239  // Get the casacore::ImageRegion of the primary beam on an Image for a given pointing
240  // Note: casacore::ImageRegion is not necesarily constrained to lie within the
241  // image region (for example, if the pointing center is near the edge of the
242  // image). fPad: extra padding over the primary beam supporrt,
243  // fractional (ie, 1.2 for 20% padding), in all directions.
244  // (note: we do not properly treat squint yet, this will cover it for now)
245  // iChan: frequency channel to take: lowest frequency channel is safe for all
246  //
247  // Potential problem: this casacore::ImageRegion includes all casacore::Stokes and Frequency Channels
248  // present in the input image.
249  //COMMENTING out for now as this depend on PBMathInterface and which depends
250  //back on SkyJones::sizeType
252  const vi::VisBuffer2& vb,
253  const casacore::Int irow=-1,
254  const casacore::Float fPad=1.2,
255  const casacore::Int iChan=0,
257 
259  const vi::VisBuffer2& vb, const casacore::Int irow=-1,
260  const casacore::Float fPad=1.2, const casacore::Int iChan=0,
262 
263  // summarize the PBMaths contained here.
264  // n = -1 => terse table
265  // n = 0 => table plus constructor values
266  // n = m => plot m samples of the PB profile
267  virtual void summary(casacore::Int n=0);
268 
269  //return the telescope it is on at this state
271 
272  //Get an idea of the support of the PB in number of pixels
273  virtual casacore::Int support(const vi::VisBuffer2& vb, const casacore::CoordinateSystem& cs);
274 
275 private:
276 
277 
279 
281 
283 
287 
288  casacore::Double parallacticAngleIncrement_p; // a parallactic angle threshold
289  // beyond which the operator is considered to be
290  // changed (in radians)
291  casacore::Double skyPositionThreshold_p; // a sky position threshold beyond
292  // which the operator is considered to be changed
293  // (in radians)
295  // used when the operator was applied last time.
296  // One value in radians for each beam model in PBMaths.
297  // A zero-length block means that the operator
298  // has never been applied
300  // used when the operator was applied last time.
301  // One element for each beam model in PBMaths.
302  // A zero-length block means that the operator
303  // has never been applied
304 
305  // One or more PBMaths (a common one for the
306  // entire array, or one for each antenna)
307  // This requires some sorting out for heterogeneous arrays!
309  // Names of telescopes (parralel with PBMaths
311 
312  // Antenna IDs (parallel with PBMaths)
314  // Feed IDs (parallel with PBMaths)
316 
317  // cache of the indices to the PBMaths container for antenna/feed 1 and 2
318  mutable casacore::CountedPtr<vi::VisBuffer2> lastUpdateVisBuffer_p; // to ensure that the cache
319  // is filled for the correct
320  // VisBuffer. The value is used
321  // for comparison only
322  mutable casacore::Int lastUpdateRow_p; // to ensure that the cache is filled for
323  // correct row in the VisBuffer
324  mutable casacore::Int lastUpdateIndex1_p; // index of the first antenna/feed
325  mutable casacore::Int lastUpdateIndex2_p; // index of the second antenna/feed
326  //
327 
328  mutable casacore::Bool hasBeenApplied; // true if the operator has been applied at least once
329 
330  // update the indices cache. This method could be made protected in the
331  // future (need access functions for lastUpdateIndex?_p to benefit from it)
332  // Cache will be valid for a given VisBuffer and row
333  void updatePBMathIndices(const vi::VisBuffer2 &vb, casacore::Int row) const;
334 
335 protected:
336  // return true if two directions are close enough to consider the
337  // operator unchanged, false otherwise
339  const casacore::MDirection &dir2) const throw(casacore::AipsError);
340 
341  // return index of compareTelescope, compareAntenna and compareFeed in
342  // myTelescopes_p, myAntennaIDs and myFeedIDs; -1 if not found
343  // if compareAntenna or compareTelescope is -1, this means that the
344  // PBMath class is the same for all antennae/feeds. An exception will
345  // be raised, if separate PBMath objects have been assigned by setPBMath
346  // for different feeds/antennae but -1 is used for query.
347  //
348  // It would be good to rename this function to indexBeams as this name
349  // is more appropriate.
350  //
351  casacore::Int indexTelescope(const casacore::String & compareTelescope,
352  const casacore::Int &compareAntenna=-1,
353  const casacore::Int &compareFeed=-1) const;
356 
357 };
358 
359 } //# end of namespace refim
360 
361 } // end namespace casa
362 
363 #endif
364 
virtual void assure(const vi::VisBuffer2 &vb, casacore::Int row)
if (changed) {update()}
A Measure: astronomical direction.
Definition: MDirection.h:174
int Int
Definition: aipstype.h:50
virtual void summary(casacore::Int n=0)
summarize the PBMaths contained here.
virtual casa::SkyJones::Type type()
Return the type of this Jones matrix (actual type of derived class).
Definition: BeamSkyJones.h:175
std::vector< double > Vector
Definition: ds9context.h:24
virtual ~BeamSkyJones()=0
this operator due to position offset
virtual void addGradients(const vi::VisBuffer2 &vb, casacore::Int row, const casacore::Float sumwt, const casacore::Float chisq, const casacore::Matrix< casacore::Complex > &c, const casacore::Matrix< casacore::Float > &f)
Add to Gradient Chisq.
casacore::Int lastUpdateIndex1_p
correct row in the VisBuffer
Definition: BeamSkyJones.h:324
Quantum< Double > Quantity
Definition: Quantum.h:38
casacore::Block< casacore::Int > myAntennaIDs_p
Antenna IDs (parallel with PBMaths)
Definition: BeamSkyJones.h:313
casacore::ImageRegion * extent(const casacore::ImageInterface< casacore::Complex > &im, const vi::VisBuffer2 &vb, const casacore::Int irow=-1, const casacore::Float fPad=1.2, const casacore::Int iChan=0, const casa::SkyJones::SizeType sizeType=casa::SkyJones::COMPOSITE)
Get the casacore::ImageRegion of the primary beam on an Image for a given pointing Note: casacore::Im...
casacore::ImageInterface< casacore::Complex > & apply(const casacore::ImageInterface< casacore::Complex > &in, casacore::ImageInterface< casacore::Complex > &out, const vi::VisBuffer2 &vb, casacore::Int row, casacore::Bool forward=true)
Apply Jones matrix to an image (and adjoint) No &quot;applyInverse&quot; is available from the SkyJones classes...
casacore::CountedPtr< VisBufferUtil > vbutil_p
Definition: BeamSkyJones.h:355
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
ostream-like interface to creating log messages.
Definition: LogIO.h:167
casacore::ImageInterface< casacore::Float > & applySquare(const casacore::ImageInterface< casacore::Float > &in, casacore::ImageInterface< casacore::Float > &out, const vi::VisBuffer2 &vb, casacore::Int row)
virtual casacore::Bool changedBuffer(const vi::VisBuffer2 &vb, casacore::Int row1, casacore::Int &row2)
Does this operator changed in this VisBuffer, starting with row1? If yes, we return in row2...
void setPBMath(const casacore::String &telescope, PBMath &myPBmath, const casacore::Int &antennaID=-1, const casacore::Int &feedID=-1)
Solve virtual casacore::Bool solve (SkyEquation&amp; se);
Types
Types of known MDirections Warning: The order defines the order in the translation matrix FromTo in ...
Definition: MDirection.h:188
casacore::String telescope()
return the telescope it is on at this state
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
casacore::Double parallacticAngleIncrement_p
Definition: BeamSkyJones.h:288
casacore::Bool getPBMath(casacore::uInt whichAnt, PBMath &myPBMath) const
get the PBMath object; returns false if that one doesn&#39;t exist, true if it does exist and is OK which...
double Double
Definition: aipstype.h:55
casacore::Double lastTime_p
Definition: BeamSkyJones.h:285
casacore::String telescope_p
Definition: BeamSkyJones.h:278
casacore::Bool hasBeenApplied
Definition: BeamSkyJones.h:328
casacore::Block< casacore::String > myTelescopes_p
Names of telescopes (parralel with PBMaths.
Definition: BeamSkyJones.h:310
beam-like sky-plane effects for the SkyEquation
Definition: BeamSkyJones.h:94
casacore::Int lastArrayId_p
Definition: BeamSkyJones.h:282
void update(const vi::VisBuffer2 &vb, casacore::Int row)
Update the FieldID, Telescope, pointingDirection, Parallactic angle info.
BeamSkyJones(const casacore::Quantity &parallacticAngleIncrement=casacore::Quantity(720.0,"deg"), BeamSquint::SquintType doSquint=BeamSquint::NONE, const casacore::Quantity &skyPositionThreshold=casacore::Quantity(180,"deg"))
Eventually, the casacore::MS will have all the beam information in its Beam Subtable.
virtual void showState(casacore::LogIO &os)
Print out information concerning the state of this object.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Int lastUpdateIndex2_p
Definition: BeamSkyJones.h:325
float Float
Definition: aipstype.h:54
virtual void initializeGradients()
Initialize for gradient search.
casacore::Block< casacore::Int > myFeedIDs_p
Feed IDs (parallel with PBMaths)
Definition: BeamSkyJones.h:315
virtual void reset()
Understand if things have changed since last PB application.
Sky Jones: Model sky-plane instrumental effects for the SkyEquation.
Definition: SkyJones.h:174
virtual casacore::ImageInterface< casacore::Complex > & applyGradient(casacore::ImageInterface< casacore::Complex > &result, const vi::VisBuffer2 &vb, casacore::Int row)
Apply gradient.
Class to hold a region of interest in an image.
Definition: ImageRegion.h:86
casacore::Block< casacore::Double > lastParallacticAngles_p
which the operator is considered to be changed (in radians)
Definition: BeamSkyJones.h:294
casacore::Int lastFieldId_p
Definition: BeamSkyJones.h:280
casacore::Bool isHomogeneous() const
Return true if all antennas share a common VP.
VisBuffer2s encapsulate one chunk of visibility data for processing.
Definition: VisBuffer2.h:141
virtual casacore::Bool isSolveable()
Is this solveable?
Definition: BeamSkyJones.h:187
Base class for all Casacore library errors.
Definition: Error.h:134
void updatePBMathIndices(const vi::VisBuffer2 &vb, casacore::Int row) const
update the indices cache.
virtual casacore::Int support(const vi::VisBuffer2 &vb, const casacore::CoordinateSystem &cs)
Get an idea of the support of the PB in number of pixels.
const Double c
Fundamental physical constants (SI units):
A component of a model of the sky.
Definition: SkyComponent.h:130
virtual void finalizeGradients()
Finalize for gradient search.
virtual casacore::Bool change(const vi::VisBuffer2 &vb)
Does the operator change in this visbuffer or since the last call? May not be useful – check it out: ...
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Int indexTelescope(const casacore::String &compareTelescope, const casacore::Int &compareAntenna=-1, const casacore::Int &compareFeed=-1) const
return index of compareTelescope, compareAntenna and compareFeed in myTelescopes_p, myAntennaIDs and myFeedIDs; -1 if not found if compareAntenna or compareTelescope is -1, this means that the PBMath class is the same for all antennae/feeds.
casacore::Quantity getSkyPositionThreshold()
Definition: BeamSkyJones.h:233
casacore::MDirection convertDir(const vi::VisBuffer2 &vb, const casacore::MDirection &inDir, const casacore::MDirection::Types outType)
casacore::CountedPtr< vi::VisBuffer2 > lastUpdateVisBuffer_p
cache of the indices to the PBMaths container for antenna/feed 1 and 2
Definition: BeamSkyJones.h:318
casacore::Double skyPositionThreshold_p
beyond which the operator is considered to be changed (in radians)
Definition: BeamSkyJones.h:291
virtual casacore::Bool changed(const vi::VisBuffer2 &vb, casacore::Int row)
Has this operator changed since the last Application? (or more properly, since the last update()) ...
casacore::Block< PBMath > myPBMaths_p
used when the operator was applied last time.
Definition: BeamSkyJones.h:308
Interconvert pixel and world coordinates.
casacore::Bool directionsCloseEnough(const casacore::MDirection &dir1, const casacore::MDirection &dir2) const
return true if two directions are close enough to consider the operator unchanged, false otherwise
casacore::Quantity getPAIncrement()
Definition: BeamSkyJones.h:231
casacore::Block< casacore::MDirection > lastDirections_p
used when the operator was applied last time.
Definition: BeamSkyJones.h:299
Type
Allowed types of VisJones matrices.
Definition: SkyJones.h:176
unsigned int uInt
Definition: aipstype.h:51
casacore::Int lastUpdateRow_p
is filled for the correct VisBuffer.
Definition: BeamSkyJones.h:322
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42
BeamSquint::SquintType doSquint_p
Definition: BeamSkyJones.h:286