casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SkyCompBase.h
Go to the documentation of this file.
1 //# SkyCompBase.h: Base class for model components of the sky brightness
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 addressed 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: SkyCompBase.h 18093 2004-11-30 17:51:10Z ddebonis $
28 
29 #ifndef COMPONENTS_SKYCOMPBASE_H
30 #define COMPONENTS_SKYCOMPBASE_H
31 
32 #include <casa/aips.h>
36 
37 namespace casacore{
38 
39 class MFrequency;
40 class MVFrequency;
41 class MDirection;
42 class MVDirection;
43 class MVAngle;
44 class RecordInterface;
45 class String;
46 class Unit;
47 template <class T> class Vector;
48 template <class T> class Matrix;
49 template <class T> class Cube;
50 template <class Ms> class MeasRef;
51 }
52 
53 namespace casa { //# NAMESPACE CASA - BEGIN
54 
55 class ComponentShape;
56 class SpectralModel;
57 template <class T> class Flux;
58 
59 // <summary>Base class for model components of the sky brightness</summary>
60 
61 // <use visibility=export>
62 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
63 // </reviewed>
64 
65 // <prerequisite>
66 // <li> <linkto class=Flux>Flux</linkto>
67 // <li> <linkto class=ComponentShape>ComponentShape</linkto>
68 // <li> <linkto class=SpectralModel>SpectralModel</linkto>
69 // </prerequisite>
70 //
71 
72 // <synopsis>
73 // This abstract base class defines the interface for classes that model the
74 // sky brightness.
75 
76 // A model of the sky brightness is defined by three properties.
77 // <dl>
78 // <dt><em>A Flux</em>
79 // <dd> This is the integrated brightness of the component.
80 // <dt><em>A Shape</em>
81 // <dd> This defines how the sky brightness varies as a function of position on
82 // the sky. Currently two shapes are supported,
83 // <linkto class=PointShape>points</linkto> and
84 // <linkto class=GaussianShape>Gaussians</linkto>.
85 // <dt><em>A Spectrum</em>
86 // <dd> This defines how the component flux varies as a function of frequency.
87 // Currently two spectral models are supported. The simplest assumes the
88 // spectrum is <linkto class=ConstantSpectrum>constant</linkto> with
89 // frequency. Alternatively a
90 // <linkto class=SpectralIndex>spectral index</linkto> model can be used.
91 // </dl>
92 
93 // These three properties of a component can be obtained using the
94 // <src>flux</src>, <src>shape</src> or <src>spectrum</src> functions defined
95 // in this interface. Each of these properties is represented by an object that
96 // contains functions for manipulating the parameters associated with that
97 // property. eg. to set the direction of the component you would use:
98 // <srcblock> SkyComponent comp; comp.shape().setRefDirection(newDirection);
99 // </srcblock> See the <linkto class=Flux>Flux</linkto>,
100 // <linkto class=ComponentShape>ComponentShape</linkto> or
101 // <linkto class=SpectralModel>SpectralModel</linkto> classes for more
102 // information on these properties and how to manipulate them.
103 
104 // Besides these three properties the <src>label</src> functions are provided
105 // to associate a text string with the component.
106 
107 // A model of the sky brightness is by itself not very useful unless you can do
108 // something with it. This class contains functions for deriving information
109 // from the components. These functions are:
110 // <dl>
111 // <dt><src>sample</src>
112 // <dd> This function will return the the flux in an specified pixel, at a
113 // specified direction at a specified frequency.
114 // <dt><src>project</src>
115 // <dd> This function will generate an image of the component, given a user
116 // specified casacore::ImageInterface object.
117 // <dt><src>visibility</src>
118 // <dd> This function will return the visibility (spatial coherence) that would
119 // be measured if the component was at the field centre of an
120 // interferometer with a specified (u,v,w) coordinates and observation
121 // frequency.
122 // </dl>
123 
124 // The <src>toRecord</src> & <src>fromRecord</src> functions are used to
125 // convert between a SkyCompBase object and a record representation. This is
126 // primarily so that a component can be represented in Glish.
127 
128 // </synopsis>
129 
130 // <example>
131 // Because SpectralModel is an abstract base class, an actual instance of this
132 // class cannot be constructed. However the interface it defines can be used
133 // inside a function. This is always recommended as it allows functions which
134 // have SkyCompBase's as arguments to work for any derived class.
135 // These examples are coded in the dSkyCompBase.cc file.
136 // <h4>Example 1:</h4>
137 // In this example the printComp function prints out the some basic information
138 // on the spatial, spectral and flux properties of the component.
139 // <srcblock>
140 // void printComponent(const SkyCompBase & comp) {
141 // cout << "This component has a flux of "
142 // << comp.flux().value()
143 // << " " << comp.flux().unit().getName() << endl;
144 // cout << "and a " << ComponentType::name(comp.flux().pol())
145 // << " polarisation" << endl;
146 // cout << "This component has a "
147 // << ComponentType::name(comp.shape().type()) << " shape" << endl;
148 // cout << "with a reference direction of "
149 // << comp.shape().refDirection().getAngle("deg") << endl;
150 // cout << "This component has a "
151 // << ComponentType::name(comp.spectrum().type()) << " spectrum" << endl;
152 // cout << "with a reference frequency of "
153 // << comp.spectrum().refFrequency().get("GHz") << endl;
154 // }
155 // </srcblock>
156 // </example>
157 //
158 // <motivation>
159 // I wanted to force the interfaces of the SkyCompRep and the SkyComponent
160 // classes to be the same. The best way I found was the introduction of a
161 // base class that these other classes would derive from.
162 // </motivation>
163 
164 // <todo asof="1998/05/20">
165 // <li> Nothing I hope!
166 // </todo>
167 
169 {
170 public:
171 
172  // The destructor does not anything
173  virtual ~SkyCompBase();
174 
175  // return a reference to the flux of the component. Because this is a
176  // reference, manipulation of the flux values is performed through the
177  // functions in the Flux class. eg.,
178  // <src>comp.flux().setValue(newVal)</src>. If the component flux varies with
179  // frequency then the flux set using this function is the value at the
180  // reference frequency.
181  // <group>
182  virtual const Flux<casacore::Double>& flux() const = 0;
183  virtual Flux<casacore::Double>& flux() = 0;
184  // </group>
185 
186  // return a reference to the shape of the component. Because this is a
187  // reference, manipulation of the shape of the component is performed through
188  // the functions in the ComponentShape (or derived) class. eg.,
189  // <src>comp.shape().setRefDirection(newVal)</src>. To change the shape to a
190  // different type you must use the <src>setShape</src> function.
191  // <group>
192  virtual const ComponentShape& shape() const = 0;
193  virtual ComponentShape& shape() = 0;
194  virtual void setShape(const ComponentShape& newShape) = 0;
195  // </group>
196 
197  // return a reference to the spectrum of the component. Because this is a
198  // reference, manipulation of the spectrum of the component is performed
199  // through the functions in the SpectralModel (or derived) class. eg.,
200  // <src>refFreq = comp.spectrum().refFrequency()</src>. Touse a different
201  // spectral model you must use the <src>setSpectrum</src> function.
202  // <group>
203  virtual const SpectralModel& spectrum() const = 0;
204  virtual SpectralModel& spectrum() = 0;
205  virtual void setSpectrum(const SpectralModel& newSpectrum) = 0;
206  // </group>
207 
208  // return a reference to the label associated with this component. The label
209  // is a text string for general use.
210  // <group>
211  virtual casacore::String& label() = 0;
212  virtual const casacore::String& label() const = 0;
213  // </group>
214 
215  // return a reference to the label associated with this component. The label
216  // is a text string for general use.
217  // <group>
219  virtual const casacore::Vector<casacore::Double>& optionalParameters() const = 0;
220  // </group>
221 
222  // Return true if the component parameters are physically plausable. This
223  // checks that I, Q, U, & V are all real numbers and if
224  // I^2 >= Q^2 + U^2 + U^2
225  virtual casacore::Bool isPhysical() const = 0;
226 
227  // Calculate the flux at the specified direction & frequency, in a pixel of
228  // specified x & y size.
229  virtual Flux<casacore::Double> sample(const casacore::MDirection& direction,
230  const casacore::MVAngle& pixelLatSize,
231  const casacore::MVAngle& pixelLongSize,
232  const casacore::MFrequency& centerFrequency) const = 0;
233 
234  // Same as the previous function except that many directions & frequencies
235  // are done at once. The flux is added into the values supplied in the
236  // samples argument and this cube must have dimensions of [4, nDirs,
237  // nFreqs]. The polarisations are always [I, Q, U, V] and units of the flux
238  // added are specified with the reqUnits arguments.
239  virtual void sample(casacore::Cube<casacore::Double>& samples,
240  const casacore::Unit& reqUnit,
241  const casacore::Vector<casacore::MVDirection>& directions,
243  const casacore::MVAngle& pixelLatSize,
244  const casacore::MVAngle& pixelLongSize,
245  const casacore::Vector<casacore::MVFrequency>& frequencies,
246  const casacore::MeasRef<casacore::MFrequency>& freqRef) const = 0;
247 
248  // Return the Fourier transform of the component at the specified point in
249  // the spatial frequency domain. The point is specified by a 3-element vector
250  // (u,v,w) that has units of meters and the frequency of the observation, in
251  // Hertz. These two quantities can be used to derive the required spatial
252  // frequency <src>(s = uvw*freq/c)</src>. The w component is not used in
253  // these functions.
254 
255  // The "origin" of the transform is the reference direction of the
256  // component. This means, for symmetric components where the reference
257  // direction is at the centre, that the Fourier transform will always be
258  // real.
260  const casacore::Double& frequency) const = 0;
261 
262  // Same as the previous function except that many (u,v,w) points are done at
263  // once. The visibilities are returned in the first argument which must have
264  // dimensions of [4, nChan, nVis]. The points to sample are specified in the
265  // second argument which must have dimensions of [3, nVis], and the
266  // frequencies to sample are specified by the third argument which must have
267  // a length of nChan. The units and polarisation of the returned visibilities
268  // are the same as the flux of this object, and can be queried using the
269  // <src>flux().units()</src> & <src>flux().pol()</src> functions.
270  virtual void visibility(casacore::Cube<casacore::DComplex>& visibilities,
272  const casacore::Vector<casacore::Double>& frequencies) const = 0;
273 
274  // This functions convert between a record and a component. Derived classes
275  // can interpret fields in the record in a class specific way. These
276  // functions define how a component is represented in glish. They return
277  // false if the record is malformed and append an error message to the
278  // supplied string giving the reason.
279  // <group>
280  virtual casacore::Bool fromRecord(casacore::String& errorMessage,
281  const casacore::RecordInterface& record) = 0;
282  virtual casacore::Bool toRecord(casacore::String& errorMessage,
283  casacore::RecordInterface& record) const = 0;
284  // </group>
285 
286  // casacore::Function which checks the internal data of this class for correct
287  // dimensionality and consistant values. Returns true if everything is fine
288  // otherwise returns false.
289  virtual casacore::Bool ok() const = 0;
290 };
291 
292 } //# NAMESPACE CASA - END
293 
294 #endif
A Measure: astronomical direction.
Definition: MDirection.h:174
std::vector< double > Vector
Definition: ds9context.h:24
virtual Flux< casacore::Double > sample(const casacore::MDirection &direction, const casacore::MVAngle &pixelLatSize, const casacore::MVAngle &pixelLongSize, const casacore::MFrequency &centerFrequency) const =0
Calculate the flux at the specified direction &amp; frequency, in a pixel of specified x &amp; y size...
virtual Flux< casacore::Double > visibility(const casacore::Vector< casacore::Double > &uvw, const casacore::Double &frequency) const =0
Return the Fourier transform of the component at the specified point in the spatial frequency domain...
virtual casacore::Vector< casacore::Double > & optionalParameters()=0
return a reference to the label associated with this component.
virtual casacore::String & label()=0
return a reference to the label associated with this component.
virtual ~SkyCompBase()
The destructor does not anything.
virtual casacore::Bool toRecord(casacore::String &errorMessage, casacore::RecordInterface &record) const =0
Convert the class to an Record representation.
Interface class for converting to/from records.
Base class for model components of the sky brightness.
Definition: SkyCompBase.h:168
virtual void setShape(const ComponentShape &newShape)=0
virtual const SpectralModel & spectrum() const =0
return a reference to the spectrum of the component.
virtual casacore::Bool ok() const =0
casacore::Function which checks the internal data of this class for correct dimensionality and consis...
defines physical units
Definition: Unit.h:189
A Measure: wave characteristics.
Definition: MFrequency.h:161
Base class for component shapes.
A class that represents the Flux (reference semantics)
Definition: SkyCompBase.h:57
virtual casacore::Bool isPhysical() const =0
Return true if the component parameters are physically plausable.
double Double
Definition: aipstype.h:55
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Base class for spectral models.
virtual const ComponentShape & shape() const =0
return a reference to the shape of the component.
virtual casacore::Bool fromRecord(casacore::String &errorMessage, const casacore::RecordInterface &record)=0
This functions convert between a record and a component.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Abstract base class for Record classes.
virtual const Flux< casacore::Double > & flux() const =0
return a reference to the flux of the component.
Class to handle angle type conversions and I/O.
Definition: MVAngle.h:245
virtual void setSpectrum(const SpectralModel &newSpectrum)=0
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42