casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SkyComponent.h
Go to the documentation of this file.
1 //# SkyComponent.h: this defines SkyComponent.h
2 //# Copyright (C) 1996,1997,1998,1999,2000,2001,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: SkyComponent.h 21292 2012-11-28 14:58:19Z gervandiepen $
28 
29 #ifndef COMPONENTS_SKYCOMPONENT_H
30 #define COMPONENTS_SKYCOMPONENT_H
31 
32 #include <casa/aips.h>
38 
39 namespace casacore{
40 
41 class MDirection;
42 class MFrequency;
43 class MVAngle;
44 class MVDirection;
45 class MVFrequency;
46 class RecordInterface;
47 class String;
48 class Unit;
49 class GaussianBeam;
50 template<class Ms> class MeasRef;
51 template<class T> class Cube;
52 template<class T> class Vector;
53 template<class T> class Quantum;
54 }
55 
56 namespace casa { //# NAMESPACE CASA - BEGIN
57 
58 class ComponentShape;
59 class SkyCompRep;
60 class SpectralModel;
61 template<class T> class Flux;
62 
63 // <summary>A component of a model of the sky </summary>
64 
65 // <use visibility=export>
66 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
67 // </reviewed>
68 
69 // <prerequisite>
70 // <li> <linkto class=Flux>Flux</linkto>
71 // <li> <linkto class=ComponentShape>ComponentShape</linkto>
72 // <li> <linkto class=SpectralModel>SpectralModel</linkto>
73 // </prerequisite>
74 
75 // <synopsis>
76 
77 // This class is concrete implementation of a class that represents a component
78 // of a model of the sky brightness.
79 
80 // The base class (<linkto class="SkyCompBase">SkyCompBase</linkto>) contains a
81 // description of components and all the member functions used to manipulate
82 // them and hence will not be discussed here. But the base class does not
83 // include any constructors or a description of the copy semantics. This will
84 // be discussed below.
85 
86 // A SkyComponent is an "envelope" class in the sense that it can contain one
87 // of a variety of different component shapes and spectral models. It is
88 // necessary to specify the which shape and spectral model you want at
89 // construction time. This can be done either with enumerators or by
90 // constructing the classes derived from ComponentShape & SpectralModel and
91 // supplying them as construction arguments.
92 
93 // This class uses reference semantics for both the copy constructor and the
94 // assignment operator. Becuase of this the only way to make a true copy of a
95 // SkyComponent is to use the <src>copy</src> member function.
96 
97 // </synopsis>
98 
99 // <example>
100 // These examples are coded in the tSkyCompRep.h file.
101 // <h4>Example 1:</h4>
102 // In this example a SkyCompRep object is created and used to calculate the
103 // ...
104 // <srcblock>
105 // </srcblock>
106 // </example>
107 //
108 // <motivation>
109 // Model fitting is an important part of astronomical data
110 // reduction/interpretation. This class defines a model component. Many
111 // components can be strung together (using the ComponentList class) to
112 // construct a model. It is expected that this class will eventually allow you
113 // to solve for parameters of the model.
114 // </motivation>
115 
116 // <thrown>
117 // <li> casacore::AipsError - If an internal inconsistancy is detected, when compiled in
118 // debug mode only.
119 // </thrown>
120 //
121 // <todo asof="1998/05/22">
122 // <li> Add time variability
123 // <li> Add the ability to solve for component parameters.
124 // </todo>
125 
126 // <linkfrom anchor="SkyComponent" classes="SkyCompRep SkyCompBase">
127 // <here>SkyComponent</here> - Models the sky brightness (reference semantics)
128 // </linkfrom>
129 
131 {
132 public:
133  // The default SkyComponent is a point source with a constant spectrum. See
134  // the default constructors in the PointShape, ConstantSpectrum and Flux
135  // classes for the default values for the flux, shape and spectrum.
136  SkyComponent();
137 
138  // Construct a SkyCompRep of the specified shape. The resultant component
139  // has a constant spectrum and a shape given by the default constructor of
140  // the specified ComponentShape class.
142 
143  // Construct a SkyCompRep with the user specified model for the shape and
144  // spectrum. The resultant component has a shape given by the default
145  // constructor of the specified ComponentShape class and a spectrum given by
146  // the default constructor of the specified SpectralModel class
147  SkyComponent(const ComponentType::Shape & shape,
148  const ComponentType::SpectralShape & spectralModel);
149 
150  // Construct a SkyComponent with a fully specified model for the shape,
151  // spectrum and flux.
153  const ComponentShape & shape,
154  const SpectralModel & spectrum);
155 
156  // The copy Constructor uses reference semantics
157  SkyComponent(const SkyComponent & other);
158 
159  // the destructor does nothing obvious (its all done by the casacore::CountedPtr)
160  virtual ~SkyComponent();
161 
162  // The assignment operator uses reference semantics
163  SkyComponent & operator=(const SkyComponent & other);
164 
165  // See the corresponding functions in the
166  // <linkto class="SkyCompBase">SkyCompBase</linkto>
167  // class for a description of these functions.
168  // <group>
169  virtual Flux<casacore::Double> & flux();
170  virtual const Flux<casacore::Double> & flux() const;
171  // </group>
172 
173  // See the corresponding functions in the
174  // <linkto class="SkyCompBase">SkyCompBase</linkto>
175  // class for a description of these functions.
176  // <group>
177  virtual const ComponentShape & shape() const;
178  virtual ComponentShape & shape();
179  virtual void setShape(const ComponentShape & newShape);
180  // </group>
181 
182  // See the corresponding functions in the
183  // <linkto class="SkyCompBase">SkyCompBase</linkto>
184  // class for a description of these functions.
185  // <group>
186  virtual const SpectralModel & spectrum() const;
187  virtual SpectralModel & spectrum();
188  virtual void setSpectrum(const SpectralModel & newSpectrum);
189  // </group>
190 
191  // See the corresponding functions in the
192  // <linkto class="SkyCompBase">SkyCompBase</linkto>
193  // class for a description of these functions.
194  // <group>
195  virtual casacore::String & label();
196  virtual const casacore::String & label() const;
197  // </group>
198 
199  // See the corresponding functions in the
200  // <linkto class="SkyCompBase">SkyCompBase</linkto>
201  // class for a description of these functions.
202  // <group>
205  // </group>
206 
207  // See the corresponding function in the
208  // <linkto class="SkyCompBase">SkyCompBase</linkto>
209  // class for a description of this function.
210  virtual casacore::Bool isPhysical() const;
211 
212  // See the corresponding functions in the
213  // <linkto class="SkyCompBase">SkyCompBase</linkto>
214  // class for a description of this function.
215  virtual Flux<casacore::Double> sample(const casacore::MDirection & direction,
216  const casacore::MVAngle & pixelLatSize,
217  const casacore::MVAngle & pixelLongSize,
218  const casacore::MFrequency & centerFrequency) const;
219 
220  // See the corresponding function in the
221  // <linkto class="SkyCompBase">SkyCompBase</linkto>
222  // class for a description of this function.
223  virtual void sample(casacore::Cube<casacore::Double>& samples,
224  const casacore::Unit& reqUnit,
225  const casacore::Vector<casacore::MVDirection>& directions,
227  const casacore::MVAngle& pixelLatSize,
228  const casacore::MVAngle& pixelLongSize,
229  const casacore::Vector<casacore::MVFrequency>& frequencies,
230  const casacore::MeasRef<casacore::MFrequency>& freqRef) const;
231 
232  // See the corresponding function in the
233  // <linkto class="SkyCompBase">SkyCompBase</linkto>
234  // class for a description of this function.
236  const casacore::Double & frequency) const;
237 
238  // See the corresponding function in the
239  // <linkto class="SkyCompBase">SkyCompBase</linkto>
240  // class for a description of this function.
241  virtual void visibility(casacore::Cube<casacore::DComplex>& visibilities,
243  const casacore::Vector<casacore::Double>& frequencies) const;
244 
245  // See the corresponding functions in the
246  // <linkto class="SkyCompBase">SkyCompBase</linkto>
247  // class for a description of these functions.
248  // <group>
249  virtual casacore::Bool fromRecord(casacore::String & errorMessage,
250  const casacore::RecordInterface & record);
251  virtual casacore::Bool toRecord(casacore::String & errorMessage,
252  casacore::RecordInterface & record) const;
253  // </group>
254 
255  // Return a distinct copy of this component. As both the assignment operator
256  // and the copy constructor use reference semantics this is the only way to
257  // get a real copy.
258  SkyComponent copy() const;
259 
260  // See the corresponding functions in the
261  // <linkto class="SkyCompBase">SkyCompBase</linkto>
262  // class for a description of this function.
263  casacore::Bool ok() const;
264 
265  // Convert from and to pixel vectors. See the SkyCompRep class for details.
266  // <group>
268  const casacore::GaussianBeam& restoringBeam,
269  const casacore::CoordinateSystem& cSys,
270  casacore::Stokes::StokesTypes stokes) const;
271  void fromPixel (casacore::Double& fluxRatio, const casacore::Vector<casacore::Double>& parameters,
272  const casacore::Unit& brightnessUnitIn,
273  const casacore::GaussianBeam& restoringBeam,
274  const casacore::CoordinateSystem& cSys,
275  ComponentType::Shape componentShape,
277 
278  // </group>
279 
280  // Get a nicely formatted string summarizing the component. If longErrOnGreatCircle is
281  // true, the longitude error is interpreted as lying
282  // along the great circle that is tangent to the center position, rather than along the
283  // circle of constant longitude. In this case, the longitude error presented as a time has
284  // been multiplied by 1/cos(latitude), but the associated angle reported as an angular measure
285  // will not have this factor applied to it, nor will the error reported in pixels.
286  virtual casacore::String summarize(
287  const casacore::DirectionCoordinate *const &dc = 0, casacore::Bool longErrOnGreatCircle=false
288  ) const;
289 
290  // If the <src>dc</src> parameter is specified, also return the corresponding world
291  // coordinates, and the pixel coordinates will be returned in the <src>pixelCoords</src>
292  // parameter (otherwise it is set to nullptr). If longErrOnGreatCircle is true, the
293  // longitude error is interpreted as lying along the great circle that is tangent to the center
294  // position, rather than along the circle of constant latitude. In this case, the longitude error
295  // presented as a time has been multiplied by 1/cos(latitude), but the associated angle reported
296  // as an angular measure will not have this factor applied to it, nor will the error reported in
297  // pixels.
299  std::shared_ptr<casacore::Vector<casacore::Double>>& pixelCoords,
300  const casacore::DirectionCoordinate *const &dc=nullptr, casacore::Bool longErrOnGreatCircle=false
301  ) const;
302 
303 private:
305 
306  static std::pair<casacore::String, casacore::String> _axisLabels(
307  const casacore::DirectionCoordinate *const &dc
308  );
309 
310 };
311 
312 } //# NAMESPACE CASA - END
313 
314 #endif
virtual casacore::String & label()
See the corresponding functions in the SkyCompBase class for a description of these functions...
A Measure: astronomical direction.
Definition: MDirection.h:174
casacore::CountedPtr< SkyCompRep > itsCompPtr
Definition: SkyComponent.h:304
casacore::Bool ok() const
See the corresponding functions in the SkyCompBase class for a description of this function...
std::vector< double > Vector
Definition: ds9context.h:24
virtual ~SkyComponent()
the destructor does nothing obvious (its all done by the casacore::CountedPtr)
virtual casacore::Vector< casacore::Double > & optionalParameters()
See the corresponding functions in the SkyCompBase class for a description of these functions...
Shape
The shapes of all the components.
SkyComponent copy() const
Return a distinct copy of this component.
Base class for model components of the sky brightness.
Definition: SkyCompBase.h:168
casacore::String positionToString(std::shared_ptr< casacore::Vector< casacore::Double >> &pixelCoords, const casacore::DirectionCoordinate *const &dc=nullptr, casacore::Bool longErrOnGreatCircle=false) const
If the dc parameter is specified, also return the corresponding world coordinates, and the pixel coordinates will be returned in the pixelCoords parameter (otherwise it is set to nullptr).
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...
static std::pair< casacore::String, casacore::String > _axisLabels(const casacore::DirectionCoordinate *const &dc)
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
virtual const SpectralModel & spectrum() const
See the corresponding functions in the SkyCompBase class for a description of these functions...
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 functions in the SkyCompBase class for a description of this function...
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
Base class for component shapes.
Interconvert pixel positions and directions (e.g. RA/DEC).
virtual void setSpectrum(const SpectralModel &newSpectrum)
double Double
Definition: aipstype.h:55
SkyComponent & operator=(const SkyComponent &other)
The assignment operator uses reference semantics.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Base class for spectral models.
virtual Flux< casacore::Double > & flux()
See the corresponding functions in the SkyCompBase class for a description of these functions...
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)
SpectralShape
The different functional forms for the spectral variation.
SkyComponent()
The default SkyComponent is a point source with a constant spectrum.
virtual casacore::String summarize(const casacore::DirectionCoordinate *const &dc=0, casacore::Bool longErrOnGreatCircle=false) const
Get a nicely formatted string summarizing the component.
A component of a model of the sky.
Definition: SkyComponent.h:130
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual void setShape(const ComponentShape &newShape)
Abstract base class for Record classes.
virtual const ComponentShape & shape() const
See the corresponding functions in the SkyCompBase class for a description of these functions...
virtual casacore::Bool isPhysical() const
See the corresponding function in the SkyCompBase class for a description of this function...
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...
Class to handle angle type conversions and I/O.
Definition: MVAngle.h:245
virtual casacore::Bool toRecord(casacore::String &errorMessage, casacore::RecordInterface &record) const
Convert the class to an Record representation.
Interconvert pixel and world coordinates.
casacore::Vector< casacore::Double > toPixel(const casacore::Unit &brightnessUnitIn, const casacore::GaussianBeam &restoringBeam, const casacore::CoordinateSystem &cSys, casacore::Stokes::StokesTypes stokes) const
Convert from and to pixel vectors.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42