casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SkyComponent.h
Go to the documentation of this file.
00001 //# SkyComponent.h: this defines SkyComponent.h
00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 //# $Id: SkyComponent.h 21292 2012-11-28 14:58:19Z gervandiepen $
00028 
00029 #ifndef COMPONENTS_SKYCOMPONENT_H
00030 #define COMPONENTS_SKYCOMPONENT_H
00031 
00032 #include <casa/aips.h>
00033 #include <casa/Utilities/CountedPtr.h>
00034 #include <coordinates/Coordinates/CoordinateSystem.h>
00035 #include <components/ComponentModels/ComponentType.h>
00036 #include <components/ComponentModels/SkyCompBase.h>
00037 #include <measures/Measures/Stokes.h>
00038 
00039 namespace casa { //# NAMESPACE CASA - BEGIN
00040 
00041 class ComponentShape;
00042 class MDirection;
00043 class MFrequency;
00044 class MVAngle;
00045 class MVDirection;
00046 class MVFrequency;
00047 class RecordInterface;
00048 class SkyCompRep;
00049 class SpectralModel;
00050 class String;
00051 class Unit;
00052 class GaussianBeam;
00053 template<class Ms> class MeasRef;
00054 template<class T> class Flux;
00055 template<class T> class Cube;
00056 template<class T> class Vector;
00057 template<class T> class Quantum;
00058 
00059 // <summary>A component of a model of the sky </summary>
00060 
00061 // <use visibility=export>
00062 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00063 // </reviewed>
00064 
00065 // <prerequisite> 
00066 // <li> <linkto class=Flux>Flux</linkto>
00067 // <li> <linkto class=ComponentShape>ComponentShape</linkto>
00068 // <li> <linkto class=SpectralModel>SpectralModel</linkto>
00069 // </prerequisite>
00070 
00071 // <synopsis> 
00072 
00073 // This class is concrete implementation of a class that represents a component
00074 // of a model of the sky brightness. 
00075 
00076 // The base class (<linkto class="SkyCompBase">SkyCompBase</linkto>) contains a
00077 // description of components and all the member functions used to manipulate
00078 // them and hence will not be discussed here. But the base class does not
00079 // include any constructors or a description of the copy semantics. This will
00080 // be discussed below.
00081 
00082 // A SkyComponent is an "envelope" class in the sense that it can contain one
00083 // of a variety of different component shapes and spectral models. It is
00084 // necessary to specify the which shape and spectral model you want at
00085 // construction time. This can be done either with enumerators or by
00086 // constructing the classes derived from ComponentShape & SpectralModel and
00087 // supplying them as construction arguments.
00088 
00089 // This class uses reference semantics for both the copy constructor and the
00090 // assignment operator. Becuase of this the only way to make a true copy of a
00091 // SkyComponent is to use the <src>copy</src> member function.
00092 
00093 // </synopsis>
00094 
00095 // <example>
00096 // These examples are coded in the tSkyCompRep.h file.
00097 // <h4>Example 1:</h4>
00098 // In this example a SkyCompRep object is created and used to calculate the
00099 // ...
00100 // <srcblock>
00101 // </srcblock>
00102 // </example>
00103 //
00104 // <motivation>
00105 // Model fitting is an important part of astronomical data
00106 // reduction/interpretation. This class defines a model component. Many
00107 // components can be strung together (using the ComponentList class) to
00108 // construct a model. It is expected that this class will eventually allow you
00109 // to solve for parameters of the model.
00110 // </motivation>
00111 
00112 // <thrown>
00113 // <li> AipsError - If an internal inconsistancy is detected, when compiled in 
00114 // debug mode only.
00115 // </thrown>
00116 //
00117 // <todo asof="1998/05/22">
00118 //   <li> Add time variability
00119 //   <li> Add the ability to solve for component parameters.
00120 // </todo>
00121 
00122 // <linkfrom anchor="SkyComponent" classes="SkyCompRep SkyCompBase">
00123 //  <here>SkyComponent</here> - Models the sky brightness (reference semantics)
00124 // </linkfrom>
00125  
00126 class SkyComponent: public SkyCompBase
00127 {
00128 public:
00129   // The default SkyComponent is a point source with a constant spectrum. See
00130   // the default constructors in the PointShape, ConstantSpectrum and Flux
00131   // classes for the default values for the flux, shape and spectrum.
00132   SkyComponent();
00133 
00134   // Construct a SkyCompRep of the specified shape. The resultant component
00135   // has a constant spectrum and a shape given by the default constructor of
00136   // the specified ComponentShape class.
00137   SkyComponent(const ComponentType::Shape & shape);
00138   
00139   // Construct a SkyCompRep with the user specified model for the shape and
00140   // spectrum. The resultant component has a shape given by the default
00141   // constructor of the specified ComponentShape class and a spectrum given by
00142   // the default constructor of the specified SpectralModel class
00143   SkyComponent(const ComponentType::Shape & shape, 
00144                const ComponentType::SpectralShape & spectralModel);
00145   
00146   // Construct a SkyComponent with a fully specified model for the shape, 
00147   // spectrum and flux.
00148   SkyComponent(const Flux<Double> & flux,
00149                const ComponentShape & shape, 
00150                const SpectralModel & spectrum);
00151 
00152   // The copy Constructor uses reference semantics
00153   SkyComponent(const SkyComponent & other);
00154 
00155   // the destructor does nothing obvious (its all done by the CountedPtr)
00156   virtual ~SkyComponent();
00157 
00158   // The assignment operator uses reference semantics
00159   SkyComponent & operator=(const SkyComponent & other);
00160 
00161   // See the corresponding functions in the
00162   // <linkto class="SkyCompBase">SkyCompBase</linkto>
00163   // class for a description of these functions.
00164   // <group>
00165   virtual Flux<Double> & flux();
00166   virtual const Flux<Double> & flux() const;
00167   // </group>
00168 
00169   // See the corresponding functions in the
00170   // <linkto class="SkyCompBase">SkyCompBase</linkto>
00171   // class for a description of these functions.
00172   // <group>
00173   virtual const ComponentShape & shape() const;
00174   virtual ComponentShape & shape();
00175   virtual void setShape(const ComponentShape & newShape);
00176   // </group>
00177   
00178   // See the corresponding functions in the
00179   // <linkto class="SkyCompBase">SkyCompBase</linkto>
00180   // class for a description of these functions.
00181   // <group>
00182   virtual const SpectralModel & spectrum() const;
00183   virtual SpectralModel & spectrum();
00184   virtual void setSpectrum(const SpectralModel & newSpectrum);
00185   // </group>
00186   
00187   // See the corresponding functions in the
00188   // <linkto class="SkyCompBase">SkyCompBase</linkto>
00189   // class for a description of these functions.
00190   // <group>
00191   virtual String & label();
00192   virtual const String & label() const;
00193   // </group>
00194 
00195   // See the corresponding functions in the
00196   // <linkto class="SkyCompBase">SkyCompBase</linkto>
00197   // class for a description of these functions.
00198   // <group>
00199   virtual Vector<Double> & optionalParameters();
00200   virtual const Vector<Double> & optionalParameters() const;
00201   // </group>
00202 
00203   // See the corresponding function in the
00204   // <linkto class="SkyCompBase">SkyCompBase</linkto>
00205   // class for a description of this function.
00206   virtual Bool isPhysical() const;
00207   
00208   // See the corresponding functions in the
00209   // <linkto class="SkyCompBase">SkyCompBase</linkto>
00210   // class for a description of this function.
00211   virtual Flux<Double> sample(const MDirection & direction, 
00212                               const MVAngle & pixelLatSize, 
00213                               const MVAngle & pixelLongSize, 
00214                               const MFrequency & centerFrequency) const;
00215 
00216   // See the corresponding function in the
00217   // <linkto class="SkyCompBase">SkyCompBase</linkto>
00218   // class for a description of this function.
00219   virtual void sample(Cube<Double>& samples,
00220                       const Unit& reqUnit,
00221                       const Vector<MVDirection>& directions, 
00222                       const MeasRef<MDirection>& dirRef, 
00223                       const MVAngle& pixelLatSize, 
00224                       const MVAngle& pixelLongSize, 
00225                       const Vector<MVFrequency>& frequencies,
00226                       const MeasRef<MFrequency>& freqRef) const;
00227 
00228   // See the corresponding function in the
00229   // <linkto class="SkyCompBase">SkyCompBase</linkto>
00230   // class for a description of this function.
00231   virtual Flux<Double> visibility(const Vector<Double> & uvw,
00232                                   const Double & frequency) const;
00233 
00234   // See the corresponding function in the
00235   // <linkto class="SkyCompBase">SkyCompBase</linkto>
00236   // class for a description of this function.
00237   virtual void visibility(Cube<DComplex>& visibilities,
00238                           const Matrix<Double>& uvws,
00239                           const Vector<Double>& frequencies) const;
00240 
00241   // See the corresponding functions in the
00242   // <linkto class="SkyCompBase">SkyCompBase</linkto>
00243   // class for a description of these functions.
00244   // <group>
00245   virtual Bool fromRecord(String & errorMessage, 
00246                           const RecordInterface & record);
00247   virtual Bool toRecord(String & errorMessage, 
00248                         RecordInterface & record) const;
00249   // </group>
00250 
00251   // Return a distinct copy of this component. As both the assignment operator
00252   // and the copy constructor use reference semantics this is the only way to
00253   // get a real copy.
00254   SkyComponent copy() const;
00255 
00256   // See the corresponding functions in the
00257   // <linkto class="SkyCompBase">SkyCompBase</linkto>
00258   // class for a description of this function.
00259   Bool ok() const;
00260 
00261   // Convert from and to pixel vectors. See the SkyCompRep class for details.
00262   // <group>
00263    Vector<Double> toPixel (const Unit& brightnessUnitIn,
00264                            const GaussianBeam& restoringBeam,
00265                            const CoordinateSystem& cSys,
00266                            Stokes::StokesTypes stokes) const;
00267   void fromPixel (Double& fluxRatio, const Vector<Double>& parameters,
00268                   const Unit& brightnessUnitIn,
00269                   const GaussianBeam& restoringBeam,
00270                   const CoordinateSystem& cSys,
00271                   ComponentType::Shape componentShape,
00272                   Stokes::StokesTypes stokes);
00273 
00274   // </group>
00275 
00276   // Get a nicely formatted string summarizing the component.
00277   virtual String summarize(const CoordinateSystem *const &coordinates = 0) const;
00278 
00279   // If the <src>coordinates</src> parameter is specified, also return the corresponding world
00280   // coordinates.
00281   String positionToString(const CoordinateSystem *const &coordinates = 0) const;
00282 
00283 
00284 private:
00285   CountedPtr<SkyCompRep> itsCompPtr;
00286 
00287 };
00288 
00289 } //# NAMESPACE CASA - END
00290 
00291 #endif