casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SkyCompRep.h
Go to the documentation of this file.
1 //# SkyCompRep.h: A model component of the sky brightness
2 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002
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: SkyCompRep.h 21292 2012-11-28 14:58:19Z gervandiepen $
28 
29 #ifndef COMPONENTS_SKYCOMPREP_H
30 #define COMPONENTS_SKYCOMPREP_H
31 
32 #include <casa/aips.h>
37 #include <casa/BasicSL/String.h>
39 
40 namespace casacore{
41 
42 class CoordinateSystem;
43 class DirectionCoordinate;
44 class LogIO;
45 class MDirection;
46 class MFrequency;
47 class MVAngle;
48 class MVDirection;
49 class MVFrequency;
50 class RecordInterface;
51 class Unit;
52 class GaussianBeam;
53 template <class Ms> class MeasRef;
54 template <class T> class Cube;
55 template <class T> class Vector;
56 template <class T> class Quantum;
57 }
58 
59 namespace casa { //# NAMESPACE CASA - BEGIN
60 
61 class ComponentShape;
62 class SpectralModel;
63 class TwoSidedShape;
64 
65 
66 
67 // <summary>A model component of the sky brightness</summary>
68 
69 // <use visibility=export>
70 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tSkyCompRep" demos="">
71 // </reviewed>
72 
73 // <prerequisite>
74 // <li> <linkto class=Flux>Flux</linkto>
75 // <li> <linkto class=ComponentShape>ComponentShape</linkto>
76 // <li> <linkto class=SpectralModel>SpectralModel</linkto>
77 // </prerequisite>
78 //
79 // <synopsis>
80 
81 // This class is concrete implementation of a class that represents a component
82 // of a model of the sky brightness.
83 
84 // The base class (<linkto class="SkyCompBase">SkyCompBase</linkto>) contains a
85 // description of components and all the member functions used to manipulate
86 // them and hence will not be discussed here. But the base class does not
87 // include any constructors or a description of the copy semantics. This will
88 // be discussed below.
89 
90 // A SkyCompRep is an "envelope" class in the sense that it can contain one of
91 // a variety of different component shapes and spectral models. It is necessary
92 // to specify the which shape and spectral model you want at construction
93 // time. This can be done either with enumerators or by constructing the
94 // classes derived from ComponentShape & SpectralModel and supplying them as
95 // construction arguments.
96 
97 // This class uses copy semantics for both the copy constructor and the
98 // assignment operator.
99 
100 // </synopsis>
101 
102 // <example>
103 // These examples are coded in the tSkyCompRep.h file.
104 // <h4>Example 1:</h4>
105 // In this example a SkyCompRep object is created and used to calculate the
106 // ...
107 // <srcblock>
108 // </srcblock>
109 // </example>
110 //
111 // <motivation>
112 // Model fitting is an important part of astronomical data
113 // reduction/interpretation. This class defines a model component. Many
114 // components can be strung together (using the ComponentList class) to
115 // construct a model. It is expected that this class will eventually allow you
116 // to solve for parameters of the model.
117 // </motivation>
118 
119 // <thrown>
120 // <li> casacore::AipsError - If an internal inconsistancy is detected, when compiled in
121 // debug mode only.
122 // </thrown>
123 //
124 // <todo asof="1998/05/22">
125 // <li> Add time variability
126 // <li> Add the ability to solve for component parameters.
127 // </todo>
128 
129 // <linkfrom anchor="SkyCompRep" classes="SkyComponent SkyCompBase">
130 // <here>SkyCompRep</here> - Models the sky brightness (copy semantics)
131 // </linkfrom>
132 
133 class SkyCompRep: public SkyCompBase
134 {
135 public:
136  // The default SkyCompRep is a point source with a constant spectrum. See
137  // the default constructors in the PointShape, ConstantSpectrum and Flux
138  // classes for the default values for the flux, shape and spectrum.
139  SkyCompRep();
140 
141  // Construct a SkyCompRep of the specified shape. The resultant component
142  // has a constant spectrum and a shape given by the default constructor of
143  // the specified ComponentShape class.
144  // <thrown>
145  // <li> casacore::AipsError - if the shape is UNKNOWN_SHAPE or NUMBER_SHAPES
146  // </thrown>
148 
149  // Construct a SkyCompRep with the user specified model for the shape and
150  // spectrum. The resultant component has a shape given by the default
151  // constructor of the specified ComponentShape class and a spectrum given by
152  // the default constructor of the specified SpectralModel class
153  // <thrown>
154  // <li> casacore::AipsError - if the shape is UNKNOWN_SHAPE or NUMBER_SHAPES
155  // <li> casacore::AipsError - if the spectrum is UNKNOWN_SPECTRAL_SHAPE or
156  // NUMBER_SPECTRAL_SHAPES
157  // </thrown>
158  SkyCompRep(const ComponentType::Shape& shape,
160 
161  // Construct a SkyCompRep with a fully specified model for the shape,
162  // spectrum and flux.
164  const ComponentShape& shape,
165  const SpectralModel& spectrum);
166 
167  // The copy constructor uses copy semantics
168  SkyCompRep(const SkyCompRep& other);
169 
170  // The destructor does not appear to do much
171  virtual ~SkyCompRep();
172 
173  // The assignment operator uses copy semantics.
174  SkyCompRep& operator=(const SkyCompRep& other);
175 
176  // See the corresponding functions in the
177  // <linkto class="SkyCompBase">SkyCompBase</linkto>
178  // class for a description of these functions.
179  // <group>
180  virtual const Flux<casacore::Double>& flux() const;
181  virtual Flux<casacore::Double>& flux();
182  // </group>
183 
184  // See the corresponding functions in the
185  // <linkto class="SkyCompBase">SkyCompBase</linkto>
186  // class for a description of these functions.
187  // <group>
188  virtual const ComponentShape& shape() const;
189  virtual ComponentShape& shape();
190  virtual void setShape(const ComponentShape& newShape);
191  // </group>
192 
193  // See the corresponding functions in the
194  // <linkto class="SkyCompBase">SkyCompBase</linkto>
195  // class for a description of these functions.
196  // <group>
197  virtual const SpectralModel& spectrum() const;
198  virtual SpectralModel& spectrum();
199  virtual void setSpectrum(const SpectralModel& newSpectrum);
200  // </group>
201 
202  // See the corresponding functions in the
203  // <linkto class="SkyCompBase">SkyCompBase</linkto>
204  // class for a description of these functions.
205  // <group>
206  virtual casacore::String& label();
207  virtual const casacore::String& label() const;
208  // </group>
209 
210  // See the corresponding functions in the
211  // <linkto class="SkyCompBase">SkyCompBase</linkto>
212  // class for a description of these functions.
213  // <group>
216  // </group>
217 
218  // See the corresponding function in the
219  // <linkto class="SkyCompBase">SkyCompBase</linkto>
220  // class for a description of this function.
221  virtual casacore::Bool isPhysical() const;
222 
223  // See the corresponding function in the
224  // <linkto class="SkyCompBase">SkyCompBase</linkto>
225  // class for a description of this function.
226  virtual Flux<casacore::Double> sample(const casacore::MDirection& direction,
227  const casacore::MVAngle& pixelLatSize,
228  const casacore::MVAngle& pixelLongSize,
229  const casacore::MFrequency& centerFrequency) const;
230 
231  // See the corresponding function in the
232  // <linkto class="SkyCompBase">SkyCompBase</linkto>
233  // class for a description of this function.
234  virtual void sample(casacore::Cube<casacore::Double>& samples,
235  const casacore::Unit& reqUnit,
236  const casacore::Vector<casacore::MVDirection>& directions,
238  const casacore::MVAngle& pixelLatSize,
239  const casacore::MVAngle& pixelLongSize,
240  const casacore::Vector<casacore::MVFrequency>& frequencies,
241  const casacore::MeasRef<casacore::MFrequency>& freqRef) const;
242 
243  // See the corresponding function in the
244  // <linkto class="SkyCompBase">SkyCompBase</linkto>
245  // class for a description of this function.
247  const casacore::Double& frequency) const;
248 
249  // See the corresponding function in the
250  // <linkto class="SkyCompBase">SkyCompBase</linkto>
251  // class for a description of this function.
252  virtual void visibility(casacore::Cube<casacore::DComplex>& visibilities,
254  const casacore::Vector<casacore::Double>& frequencies) const;
255 
256  // See the corresponding functions in the
257  // <linkto class="SkyCompBase">SkyCompBase</linkto>
258  // class for a description of these functions.
259  // <group>
260  virtual casacore::Bool fromRecord(casacore::String& errorMessage,
261  const casacore::RecordInterface& record);
262  virtual casacore::Bool toRecord(casacore::String& errorMessage,
263  casacore::RecordInterface& record) const;
264  // </group>
265 
266  // Convert the SkyComponent to a vector of Doubles
267  // for the specified casacore::Stokes type (others are lost).
268  // The first three elements of the returned vector are : flux for given
269  // casacore::Stokes (in the units you specify), longitude location (absolute pixels), and
270  // latitude location (absolute pixels). For DISK and GAUSSIAN shapes,
271  // the next three elements are major axis (absolute pixels)
272  // minor axis (absolute pixels), and position angle (N->E; radians).
273  // You must specify the brightness units to which the integral flux stored
274  // in the SkyComponent should be converted. So as to be able to handle
275  // /beam units, the restoring beam must also be suppluied. It can be obtained
276  // from the casacore::ImageInfo class. It should be of length 3 or 0 (no beam).
277  // A constant spectrum is used so any spectral index information in
278  // the component is lost.
280  const casacore::Unit& brightnessUnitOut,
281  const casacore::GaussianBeam& restoringBeam,
282  const casacore::CoordinateSystem& cSys,
284  ) const;
285 
286  // Take a vector Doubles and fill the SkyComponent from the values.
287  // The first three elements of the given vector are : flux for given
288  // casacore::Stokes (in the units you specify), longitude location (absolute pixels), and
289  // latitude location (absolute pixels). For DISK and GAUSSIAN shapes,
290  // the next three elements are major axis (absolute pixels)
291  // minor axis (absolute pixels), and position angle (N->E; radians).
292  // You must specify the brightness units in which the flux is stored
293  // in the vector. It will be converted to an integral reprentation
294  // internally for the SkyComponent. So as to be able to handle
295  // /beam units, the restoring beam must also be supplied. It can be obtained
296  // from the casacore::ImageInfo class. It should be of length 3 or 0 (no beam).
297  // Multiplying by fluxRatio converts the brightness units to Jy/whatever (e.g. mJy/beam
298  // to Jy/beam). You must specify the type of shape to convert to.
299  // The SkyComponent is given a constant spectrum.
300  void fromPixel (casacore::Double& fluxRatio, const casacore::Vector<casacore::Double>& parameters,
301  const casacore::Unit& brightnessUnitIn,
302  const casacore::GaussianBeam& restoringBeam,
303  const casacore::CoordinateSystem& cSys,
304  ComponentType::Shape componentShape,
306 
307  // See the corresponding function in the
308  // <linkto class="SkyCompBase">SkyCompBase</linkto>
309  // class for a description of this function.
310  virtual casacore::Bool ok() const;
311 
312 
313 // Find the factor that converts whatever per whatevers (e.g. mJy per beam)
314 // to Jy per whatevers (e.g. Jy per beam)
315  static casacore::Double convertToJy (const casacore::Unit& brightnessUnit);
316 
317  // Convert a peak flux density to integral flux density
319  const casacore::DirectionCoordinate& dirCoord,
320  const ComponentType::Shape componentShape,
321  const casacore::Quantum<casacore::Double>& peakFlux,
322  const casacore::Quantum<casacore::Double>& majorAxis,
323  const casacore::Quantum<casacore::Double>& minorAxis,
324  const casacore::GaussianBeam& restoringBeam
325  );
326 
327  // Convert an integral flux density to peak flux density. The brightness unit
328  // of the output quantum (e.g. mJy/beam) is specified by <src>brightnessUnit</src>
329  // Throws an exception if the units of <src>integralFlux</src> do not conform to Jy.
331  const casacore::DirectionCoordinate& dirCoord,
332  const ComponentType::Shape componentShape,
333  const casacore::Quantity& integralFlux,
334  const casacore::Unit& brightnessUnit,
335  const casacore::Quantity& majorAxis,
336  const casacore::Quantity& minorAxis,
337  const casacore::GaussianBeam& restoringBeam
338  );
339 
340 private:
346 
347 
348  // Make definitions to handle "/beam" and "/pixel" units. The restoring beam
349  // is provided in a vector of quanta (major, minor, position angle). Should
350  // be length 0 or 3. It can be obtained from class ImageInfo
352  casacore::LogIO& os, const casacore::Unit& brightnessUnitIn,
353  const casacore::DirectionCoordinate& dirCoord,
354  const casacore::GaussianBeam& restoringBeam,
355  const casacore::Bool integralIsJy
356  );
357 
358  // Remove the user defined "/beam" and "/pixel" definitions
359  static void undefineBrightnessUnits();
360 
361 };
362 
363 } //# NAMESPACE CASA - END
364 
365 #endif
A model component of the sky brightness.
Definition: SkyCompRep.h:133
A Measure: astronomical direction.
Definition: MDirection.h:174
virtual const SpectralModel & spectrum() const
See the corresponding functions in the SkyCompBase class for a description of these functions...
virtual void setShape(const ComponentShape &newShape)
std::vector< double > Vector
Definition: ds9context.h:24
virtual casacore::Bool toRecord(casacore::String &errorMessage, casacore::RecordInterface &record) const
Convert the class to an Record representation.
Shape
The shapes of all the components.
virtual Flux< casacore::Double > visibility(const casacore::Vector< casacore::Double > &uvw, const casacore::Double &frequency) const
See the corresponding function in the SkyCompBase class for a description of this function...
virtual const ComponentShape & shape() const
See the corresponding functions in the SkyCompBase class for a description of these functions...
casacore::Vector< casacore::Double > toPixel(const casacore::Unit &brightnessUnitOut, const casacore::GaussianBeam &restoringBeam, const casacore::CoordinateSystem &cSys, casacore::Stokes::StokesTypes stokes) const
Convert the SkyComponent to a vector of Doubles for the specified casacore::Stokes type (others are l...
Base class for model components of the sky brightness.
Definition: SkyCompBase.h:168
virtual Flux< casacore::Double > sample(const casacore::MDirection &direction, const casacore::MVAngle &pixelLatSize, const casacore::MVAngle &pixelLongSize, const casacore::MFrequency &centerFrequency) const
See the corresponding function in the SkyCompBase class for a description of this function...
SkyCompRep & operator=(const SkyCompRep &other)
The assignment operator uses copy semantics.
casacore::String itsLabel
Definition: SkyCompRep.h:344
ostream-like interface to creating log messages.
Definition: LogIO.h:167
Flux< casacore::Double > itsFlux
Definition: SkyCompRep.h:343
static casacore::Unit defineBrightnessUnits(casacore::LogIO &os, const casacore::Unit &brightnessUnitIn, const casacore::DirectionCoordinate &dirCoord, const casacore::GaussianBeam &restoringBeam, const casacore::Bool integralIsJy)
Make definitions to handle &quot;/beam&quot; and &quot;/pixel&quot; units.
casacore::Vector< casacore::Double > itsOptParms
Definition: SkyCompRep.h:345
static casacore::Quantity integralToPeakFlux(const casacore::DirectionCoordinate &dirCoord, const ComponentType::Shape componentShape, const casacore::Quantity &integralFlux, const casacore::Unit &brightnessUnit, const casacore::Quantity &majorAxis, const casacore::Quantity &minorAxis, const casacore::GaussianBeam &restoringBeam)
Convert an integral flux density to peak flux density.
Represents a Gaussian restoring beam associated with an image.
Definition: GaussianBeam.h:68
StokesTypes
The Stokes types are defined by this enum.
Definition: Stokes.h:66
defines physical units
Definition: Unit.h:189
A Measure: wave characteristics.
Definition: MFrequency.h:161
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
Base class for component shapes.
virtual void setSpectrum(const SpectralModel &newSpectrum)
SkyCompRep()
The default SkyCompRep is a point source with a constant spectrum.
Interconvert pixel positions and directions (e.g. RA/DEC).
double Double
Definition: aipstype.h:55
static casacore::Double convertToJy(const casacore::Unit &brightnessUnit)
Find the factor that converts whatever per whatevers (e.g.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Base class for spectral models.
virtual casacore::Bool isPhysical() const
See the corresponding function in the SkyCompBase class for a description of this function...
static casacore::Quantity peakToIntegralFlux(const casacore::DirectionCoordinate &dirCoord, const ComponentType::Shape componentShape, const casacore::Quantum< casacore::Double > &peakFlux, const casacore::Quantum< casacore::Double > &majorAxis, const casacore::Quantum< casacore::Double > &minorAxis, const casacore::GaussianBeam &restoringBeam)
Convert a peak flux density to integral flux density.
casacore::CountedPtr< SpectralModel > itsSpectrumPtr
Definition: SkyCompRep.h:342
virtual const Flux< casacore::Double > & flux() const
See the corresponding functions in the SkyCompBase class for a description of these functions...
virtual casacore::Bool fromRecord(casacore::String &errorMessage, const casacore::RecordInterface &record)
See the corresponding functions in the SkyCompBase class for a description of these functions...
SpectralShape
The different functional forms for the spectral variation.
virtual casacore::Vector< casacore::Double > & optionalParameters()
See the corresponding functions in the SkyCompBase class for a description of these functions...
virtual ~SkyCompRep()
The destructor does not appear to do much.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Abstract base class for Record classes.
virtual casacore::Bool ok() const
See the corresponding function in the SkyCompBase class for a description of this function...
void fromPixel(casacore::Double &fluxRatio, const casacore::Vector< casacore::Double > &parameters, const casacore::Unit &brightnessUnitIn, const casacore::GaussianBeam &restoringBeam, const casacore::CoordinateSystem &cSys, ComponentType::Shape componentShape, casacore::Stokes::StokesTypes stokes)
Take a vector Doubles and fill the SkyComponent from the values.
virtual casacore::String & label()
See the corresponding functions in the SkyCompBase class for a description of these functions...
Class to handle angle type conversions and I/O.
Definition: MVAngle.h:245
static void undefineBrightnessUnits()
Remove the user defined &quot;/beam&quot; and &quot;/pixel&quot; definitions.
Interconvert pixel and world coordinates.
casacore::CountedPtr< ComponentShape > itsShapePtr
Definition: SkyCompRep.h:341
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42