casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Flux.h
Go to the documentation of this file.
00001 //# Flux.h:
00002 //# Copyright (C) 1998,1999,2000,2001
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: Flux.h 21130 2011-10-18 07:39:05Z gervandiepen $
00028 
00029 #ifndef COMPONENTS_FLUX_H
00030 #define COMPONENTS_FLUX_H
00031 
00032 #include <casa/aips.h>
00033 #include <casa/Arrays/Vector.h>
00034 #include <scimath/Mathematics/NumericTraits.h>
00035 #include <measures/Measures/Stokes.h>
00036 #include <casa/Quanta/Unit.h>
00037 #include <casa/Utilities/CountedPtr.h>
00038 #include <components/ComponentModels/ComponentType.h>
00039 
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 
00042 class RecordInterface;
00043 template <class Qtype> class Quantum;
00044 
00045 // <summary>A class that represents the Flux (copy semantics)</summary>
00046 
00047 // <use visibility=export>
00048 
00049 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00050 // </reviewed>
00051 
00052 // <prerequisite>
00053 //   <li> <linkto class="Vector">Vector</linkto>
00054 //   <li> <linkto class="Unit">Unit</linkto>
00055 // </prerequisite>
00056 //
00057 // <etymology>
00058 // This class actually contains the flux values as distinct from the Flux class
00059 // which is a pointer to this class. Hence this class name is a shortening of
00060 // "Flux Representation". The Flux class is probably of more general user
00061 // utility as its reference semantics can cut down on the number of temporary
00062 // objects that get constructed.
00063 // </etymology>
00064 //
00065 // <synopsis>
00066 // This class encapsulates three quantities that are needed to more completely
00067 // represent the polarised flux of a component. These quantities are:
00068 // <dl>
00069 // <dt> Flux values.
00070 // <dd> These are four numbers which are the numerical value of the flux in all
00071 //      four polarisations. The values can be represented in either single or
00072 //      double precision depending on the template type.
00073 // <dt> Flux units.
00074 // <dd> These are the units for the flux values. The units must have dimensions
00075 //      of W/m^2/Hz and are represented using the
00076 //      <linkto class="Unit">Unit</linkto> class. The most common unit is "Jy".
00077 // <dt> Polarisation representation.
00078 // <dd> This describes how the polarised flux is represented. It can be one of
00079 //      the following:
00080 //      <dl compact><dt>Stokes<dd>
00081 //      The flux is representing using the Stokes I, Q, U, V components
00082 //      respectively.
00083 //      <dt>Linear<dd>
00084 //      The flux is representing using the XX,XY,YX,YY correlation products
00085 //      resp. X and Y is the signal from linear feeds at zero parallactic
00086 //      angle.
00087 //      <dt>Circular<dd>
00088 //      The flux is representing using the RR,RL,LR,LL correlation products
00089 //      resp. R and L is the signal from right and left handed circular feeds.
00090 //      </dl>
00091 // </dl>
00092 // This class is templated but only two templated types are valid. These are:
00093 // <ul> 
00094 // <li> T = Float
00095 // <li> T = Double
00096 // </ul>
00097 // The template type defines the precision of the Flux Values.
00098 //
00099 // This class uses functions in the Flux class which convert between the
00100 // different polarisation representations. They assume (until a decision has
00101 // been made on this) that the total intensity is the average of the linear or
00102 // circular correlation products. ie., <src>I = (RR+LL)/2 = (XX+YY)/2</src>.
00103 //
00104 // In order to represent the Flux using the circular or linear representations
00105 // the Flux values need to be complex (eg.,<src>XY = I + iV, YX = I - iV</src>)
00106 // This class does not require, or check a number of constraints such as
00107 // <src>XY = conj(YX)</src> and hence it is possible to define a flux using a
00108 // linear or circular representation that cannot be completely represented
00109 // using the Stokes representation. Because this class stores the flux values
00110 // as complex numbers there is no loss of accuracy when converting between
00111 // different polarisation representations. But it discards the imaginary
00112 // component of the flux when externally representing the flux using with a
00113 // Stokes representation (eg., when calling the <src>value(Vector<T>&)</src>
00114 // function).
00115 //
00116 // Because this class using Complex numbers with a precision that depends on
00117 // the template type many of the function arguments are of type
00118 // <src>NumericTraits<T></src>. This simply a type that maps to Complex if T is
00119 // Float and DComplex if T is a Double. Because of problems with the the gnu
00120 // compiler functions which use this type as an argument MUST be
00121 // inline. Hopefully this problem will go away sometime.
00122 // </synopsis>
00123 //
00124 // <example>
00125 // The following example creates a FluxRep object using a Stokes representation
00126 // and converts it to "WU" (Westerbork Units). After printing out the converted
00127 // I flux it converts the Flux to a linear representation and prints out a
00128 // Vector with the [XX,XY,YX,YY] values (still in "WU")
00129 // <srcblock>
00130 // FluxRep<Double> flux(1.0, 0.0, 0.0, 0.1); // I = 1.0, V = 0.1
00131 // flux.convertUnit("WU");
00132 // cout << "The I flux (in WU is)" << flux.value(0) << endl;
00133 // flux.convertPol(ComponentType::LINEAR);
00134 // cout << "The XX,XY,YX,YY flux (in WU is)" << flux.value() << endl;
00135 // </srcblock>
00136 // </example>
00137 //
00138 // <motivation>
00139 // This class was needed to contain the flux in the ComponentModels module and
00140 // centralizes a lot of code that would otherwise be duplicated in disparate
00141 // places. 
00142 // </motivation>
00143 //
00144 // <thrown>
00145 //    <li> AipsError, When the Vectors are not of length 4 or when indices are
00146 //          greater than 4
00147 // </thrown>
00148 //
00149 // <todo asof="1998/03/11">
00150 //   <li> get this class reviewed.
00151 // </todo>
00152 
00153 template<class T> class FluxRep
00154 {
00155 public:
00156 
00157   // The default constructor makes an object with <src>I = 1, Q=U=V=0</src>,
00158   // a Stokes representation, and units of "Jy".
00159   FluxRep();
00160 
00161   // This constructor makes an object where I is specified and
00162   // <src>Q=U=V=0</src>. It assumes a Stokes representation, and units of "Jy".
00163   FluxRep(T i);
00164 
00165   // This constructor makes an object where I,Q,U,V are all specified. It
00166   // assumes a Stokes representation, and units of "Jy".
00167   FluxRep(T i, T q, T u, T v);
00168 
00169   // This constructor makes an object where the flux values and polarisation
00170   // representation are specified. It assumes the units are "Jy".
00171   FluxRep(typename NumericTraits<T>::ConjugateType xx,
00172           typename NumericTraits<T>::ConjugateType xy,
00173           typename NumericTraits<T>::ConjugateType yx,
00174           typename NumericTraits<T>::ConjugateType yy,
00175           ComponentType::Polarisation pol);
00176   
00177   // This constructor makes an object where I,Q,U,V are all specified by a
00178   // Vector that must have four elements. It assumes a Stokes representation,
00179   // and units of "Jy".
00180   FluxRep(const Vector<T>& flux);
00181 
00182   // This constructor makes an object where the flux values are all specified
00183   // by a Vector that must have four elements. The polarisation representation
00184   // must also be specified. It assumes the units are "Jy".
00185   FluxRep(const Vector<typename NumericTraits<T>::ConjugateType>& flux,
00186           ComponentType::Polarisation pol);
00187   
00188   // This constructor makes an object where the flux values are all specified
00189   // by a Quantum<Vector> that must have four elements.  The Quantum must have
00190   // units that are dimensionally equivalent to the "Jy" and these are the
00191   // units of the FluxRep object. A Stokes polarisation representation is
00192   // assumed.
00193   FluxRep(const Quantum<Vector<T> >& flux);
00194 
00195   // This constructor makes an object where the flux values are all specified
00196   // by a Quantum<Vector> that must have four elements. The Quantum must have
00197   // units that are dimensionally equivalent to the "Jy" and these are the
00198   // units of the FluxRep object. The polarisation representation must also be
00199   // specified.
00200   FluxRep(const
00201           Quantum<Vector<typename NumericTraits<T>::ConjugateType> >& flux,
00202           ComponentType::Polarisation pol);
00203 
00204   // The copy constructor uses copy semantics.
00205   FluxRep(const FluxRep<T>& other);
00206 
00207   // The destructor is trivial
00208   ~FluxRep();
00209 
00210   // The assignment operator uses copy semantics.
00211   FluxRep<T>& operator=(const FluxRep<T>& other);
00212 
00213   // These two functions return the current units
00214   // <group>
00215   const Unit& unit() const;
00216   void unit(Unit& unit) const;
00217   // </group>
00218 
00219   // This function sets the current unit. It does NOT convert the flux values
00220   // to correspond to the new unit. The new unit must be dimensionally
00221   // equivalent to the "Jy".
00222   void setUnit(const Unit& unit);
00223 
00224   // This function sets the current units to the supplied value and
00225   // additionally converts the internal flux values to the correspond to the
00226   // new unit.
00227   void convertUnit(const Unit& unit);
00228 
00229   // These two functions return the current polarisation representation.
00230   // <group>
00231   ComponentType::Polarisation pol() const;
00232   void pol(ComponentType::Polarisation& pol) const;
00233   // </group>
00234 
00235   // This function sets the current polarisation representation. It does NOT
00236   // convert the flux values.
00237   void setPol(ComponentType::Polarisation pol);
00238 
00239   // This function sets the current polarisation representation to the supplied
00240   // value and additionally converts the internal flux values to the correspond
00241   // to the new polarisation representation.
00242   void convertPol(ComponentType::Polarisation pol);
00243 
00244   // This function returns the flux values. The polarisation representation and
00245   // units are in whatever is current.
00246   const Vector<typename NumericTraits<T>::ConjugateType>& value() const;
00247 
00248   // This function returns the specified component of the flux values.
00249   // The polarisation representation and units are in whatever is current.
00250   const typename NumericTraits<T>::ConjugateType& value(uInt p) const;
00251 
00252   // This function returns the flux values after converting it to the Stokes
00253   // representation. The units of the returned Vector are the current units.
00254   void value(Vector<T>& value);
00255 
00256   // This function returns the flux values. The polarisation representation and
00257   // units are in whatever is current.
00258   void value(Vector<typename NumericTraits<T>::ConjugateType>& value) const;
00259 
00260   // This function returns the flux values after converting it to the Stokes
00261   // representation. The units of the returned Quantum are the current units of
00262   // the FluxRep object. The length of the Vector in the Quantum will be
00263   // resized to 4 elements if it is not already that length.
00264   void value(Quantum<Vector<T> >& value);
00265 
00266   // This function returns the flux values. The units of the returned Quantum
00267   // are the current units of the FluxRep object. Similarly the polarisation
00268   // representation of the returned Quantum is the current polarisation
00269   // representation. The length of the Vector in the Quantum will be resized to
00270   // 4 elements if it is not already that length.
00271   void value(Quantum
00272              <Vector<typename NumericTraits<T>::ConjugateType> >& value) const;
00273 
00274   // Return the flux value in a Quantum for the specified Stokes.  Can convert
00275   // to Jy if requested.  
00276   Quantum<T> value (Stokes::StokesTypes stokes, Bool toJy=True);
00277 
00278   // This function sets the Flux values assuming the supplied value represents
00279   // the Stokes I flux in the current units. The other Stokes parameters are
00280   // set to zero.
00281   void setValue(T value);
00282  
00283   // This function sets the Flux values assuming the supplied values represent
00284   // the flux in the Stokes representation and is in the current units. The
00285   // Vector must have four elements.
00286   void setValue(const Vector<T>& value); 
00287 
00288   // This function sets the Flux values assuming the supplied values represent
00289   // the flux in the current representation and units. The Vector must have
00290   // four elements.
00291   void setValue(const Vector<typename NumericTraits<T>::ConjugateType>& value);
00292 
00293   // This function sets the flux values and units assuming the supplied values
00294   // represent the flux in the Stokes representation. The units of the Quantum
00295   // must be dimensionally equivalent to the "Jy" and the Vector must have four
00296   // elements.
00297   void setValue(const Quantum<Vector<T> >& value);
00298 
00299   // This function sets the flux values, units and polarisation assuming the
00300   // supplied values represent the flux in the specified representation. The
00301   // units of the Quantum must be dimensionally equivalent to the "Jy" and the
00302   // Vector must have four elements.
00303   void setValue(const
00304                 Quantum<Vector<typename NumericTraits<T>::ConjugateType> >& value,
00305                 ComponentType::Polarisation pol);
00306 
00307   // Set flux for given Stokes from Quantum. 
00308   void setValue (const Quantum<T>& value, Stokes::StokesTypes stokes);
00309 
00310   // Scale the Flux value by the specified amount. These functions multiply the
00311   // flux values irrespective of the current polarisation representation. If
00312   // only one scale factor is supplied then only the first component of the
00313   // flux is scaled.
00314   // <group>
00315   void scaleValue(const T& factor);
00316   void scaleValue(const T& factor0, const T& factor1,
00317                   const T& factor2, const T& factor3);
00318   void scaleValue(const typename NumericTraits<T>::ConjugateType& factor);
00319   void scaleValue(const typename NumericTraits<T>::ConjugateType& factor0,
00320                   const typename NumericTraits<T>::ConjugateType& factor1,
00321                   const typename NumericTraits<T>::ConjugateType& factor2,
00322                   const typename NumericTraits<T>::ConjugateType& factor3);
00323   // </group>
00324 
00325   // Set/get the errors in the flux
00326   // <group>
00327   void setErrors(const typename NumericTraits<T>::ConjugateType& error0,
00328                  const typename NumericTraits<T>::ConjugateType& error1,
00329                  const typename NumericTraits<T>::ConjugateType& error2,
00330                  const typename NumericTraits<T>::ConjugateType& error3);
00331 
00332   void setErrors(const Vector<typename NumericTraits<T>::ConjugateType>& errors);
00333 
00334   const Vector<typename NumericTraits<T>::ConjugateType>& errors() const;
00335   // </group>
00336 
00337   // This functions convert between a RecordInterface and a FluxRep object and
00338   // define how the FluxRep is represented in glish.  They return False if the
00339   // RecordInterface is malformed and append an error message to the supplied
00340   // string giving the reason.
00341   // <group>
00342   Bool fromRecord(String& errorMessage, const RecordInterface& record);
00343   Bool toRecord(String& errorMessage, RecordInterface& record) const;
00344   // </group>
00345 
00346   // Function which checks the internal data of this class for correct
00347   // dimensionality and consistent values. Returns True if everything is fine
00348   // otherwise returns False.
00349   Bool ok() const;
00350 
00351   // in addition to Jy, allow these "flux" units. Useful when images have "flux-like"
00352   // units such as Jy.km/s
00353   static void setAllowedUnits(const Vector<String>& allowedUnits);
00354 
00355   // clear all allowed units set by setAllowedUnits
00356   static void clearAllowedUnits();
00357 
00358 private:
00359   Vector<typename NumericTraits<T>::ConjugateType> itsVal;
00360   ComponentType::Polarisation itsPol;
00361   Unit itsUnit;
00362   Vector<typename NumericTraits<T>::ConjugateType> itsErr;
00363   static Vector<String> _allowedUnits;
00364 };
00365 
00366 // <summary>A class that represents the Flux (reference semantics)</summary>
00367 
00368 // <use visibility=export>
00369 
00370 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00371 // </reviewed>
00372 
00373 // <prerequisite>
00374 //   <li> <linkto class="Vector">Vector</linkto>
00375 //   <li> <linkto class="Unit">Unit</linkto>
00376 //   <li> <linkto class="FluxRep">FluxRep</linkto>
00377 // </prerequisite>
00378 //
00379 // <etymology>
00380 // The Flux class is used to represent the flux of a component on the sky
00381 // </etymology>
00382 //
00383 // <synopsis>
00384 
00385 // This class is nearly identical to the <linkto
00386 // class="FluxRep">FluxRep</linkto> class and the reader is referred to the
00387 // documentation of this class for a general explanation of this class.  Most
00388 // of the functions in this class just call the functions in the FluxRep class.
00389 
00390 // There are two important differences between the Flux class and the FluxRep
00391 // class. 
00392 // <ul>
00393 // <li> This class uses reference semantics rather than copy semantics. This
00394 // aids in cutting down on the number of temporary objects that need to be
00395 // constructed. An example of this is illustrated in the examples section
00396 // below.
00397 // <li> This class contains functions for converting between different
00398 // polarisation representations. 
00399 // </ul>
00400 // The functions for converting between different polarisation representations
00401 // require that the supplied and returned vector have all four polarisations.
00402 // In the Stokes representation the order of the elements is I,Q,U,V, in the
00403 // linear representation it is XX,XY,YX,YY, and in the circular representation
00404 // it is RR,RL,LR,LL.
00405 //
00406 // These functions will correctly convert between Linear/Circular
00407 // representations and the Stokes representation even if the linear or circular
00408 // polarisation cannot represent a physically realisable polarisation (eg if
00409 // <src>XY != conj(YX)</src>). In these cases the stokes representation will
00410 // have an imaginary component and be complex. When converting the complex
00411 // Stokes representation to a real one the imaginary components are simply
00412 // discarded.
00413 // </synopsis>
00414 //
00415 // <example>
00416 // The function in this example calculates the total flux of all the
00417 // components in a list. It accumulates the flux in a Vector after ensuring
00418 // that the flux is in the appropriate units and Polarisation. It then returns
00419 // the sum as a Flux object. Because this class uses reference semantics the
00420 // returned object is passed by reference and hence this is a relatively cheap
00421 // operation.
00422 // <srcblock>
00423 // Flux<Double> totalFlux(ComponentList& list) {
00424 //   Vector<DComplex> sum(4, DComplex(0.0, 0.0));
00425 //   for (uInt i = 0; i < list.nelements(); i++) {
00426 //     list.component(i).flux().convertPol(ComponentType::STOKES);
00427 //     list.component(i).flux().convertUnit("Jy");
00428 //     sum += list.component(i).flux().value()
00429 //   }
00430 //   return Flux<Double>(value, ComponentType::STOKES);
00431 // }
00432 // </srcblock>
00433 // </example>
00434 //
00435 // <motivation>
00436 // This class was needed to contain the flux in the ComponentModels class. It
00437 // centralizes a lot of code that would otherwise be duplicated. The reference
00438 // semantics further simplify the interface that the component classes use.
00439 // </motivation>
00440 //
00441 // <thrown>
00442 //    <li> AipsError, When the Vectors are not of length 4 or when indices are
00443 //          greater than 4
00444 // </thrown>
00445 //
00446 // <todo asof="1998/03/11">
00447 //   <li> get this class reviewed.
00448 // </todo>
00449 
00450 template<class T> class Flux
00451 {
00452 public:
00453   // The default constructor makes an object with <src>I = 1, Q=U=V=0</src>,
00454   // a Stokes representation, and units of "Jy".
00455   Flux();
00456 
00457   // The default constructor makes an object with <src>I = 1, Q=U=V=0</src>,
00458   // a Stokes representation, and units of "Jy".
00459    Flux(T i);
00460 
00461   // This constructor makes an object where I,Q,U,V are all specified. It
00462   // assumes a Stokes representation, and units of "Jy".
00463   Flux(T i, T q, T u, T v);
00464 
00465   // This constructor makes an object where the flux values and polarisation
00466   // representation are specified. It assumes the units are "Jy".
00467   Flux(typename NumericTraits<T>::ConjugateType xx,
00468        typename NumericTraits<T>::ConjugateType xy,
00469        typename NumericTraits<T>::ConjugateType yx,
00470        typename NumericTraits<T>::ConjugateType yy, 
00471        ComponentType::Polarisation pol);
00472 
00473   // This constructor makes an object where I,Q,U,V are all specified by a
00474   // Vector that must have four elements. It assumes a Stokes representation,
00475   // and units of "Jy".
00476   Flux(const Vector<T>& flux);
00477 
00478   // This constructor makes an object where the flux values are all specified
00479   // by a Vector that must have four elements. The polarisation representation
00480   // must also be specified. It assumes the units are "Jy".
00481   Flux(const Vector<typename NumericTraits<T>::ConjugateType>& flux,
00482        ComponentType::Polarisation pol);
00483   
00484   // This constructor makes an object where the flux values are all specified
00485   // by a Quantum<Vector> that must have four elements.  The Quantum must have
00486   // units that are dimensionally equivalent to the "Jy" and these are the
00487   // units of the FluxRep object. A Stokes polarisation representation is
00488   // assumed.
00489   Flux(const Quantum<Vector<T> >& flux);
00490 
00491   // This constructor makes an object where the flux values are all specified
00492   // by a Quantum<Vector> that must have four elements. The Quantum must have
00493   // units that are dimensionally equivalent to the "Jy" and these are the
00494   // units of the FluxRep object. The polarisation representation must also be
00495   // specified.
00496   Flux(const Quantum<Vector<typename NumericTraits<T>::ConjugateType> >& flux,
00497        ComponentType::Polarisation pol);
00498 
00499   // The copy constructor uses reference semantics.
00500   Flux(const Flux<T>& other);
00501 
00502   // The destructor is trivial
00503   ~Flux();
00504 
00505   // The assignment operator uses reference semantics.
00506   Flux<T>& operator=(const Flux<T>& other);
00507 
00508   // Return a distinct copy of this flux. As both the assignment operator
00509   // and the copy constructor use reference semantics this is the only way to
00510   // get a real copy.
00511   Flux<T> copy() const;
00512 
00513   // These two functions return the current units.
00514   // <group>
00515   const Unit& unit() const;
00516   void unit(Unit& unit) const;
00517   // </group>
00518 
00519   // This function sets the current unit. It does NOT convert the flux values
00520   // to correspond to the new unit. The new unit must be dimensionally
00521   // equivalent to the "Jy".
00522   void setUnit(const Unit& unit);
00523 
00524   // This function sets the current units to the supplied value and
00525   // additionally converts the internal flux values to the correspond to the
00526   // new unit.
00527   void convertUnit(const Unit& unit);
00528 
00529   // These two functions return the current polarisation representation.
00530   // <group>
00531   ComponentType::Polarisation pol() const;
00532   void pol(ComponentType::Polarisation& pol) const;
00533   // </group>
00534 
00535   // This function sets the current polarisation representation. It does NOT
00536   // convert the flux values.
00537   void setPol(ComponentType::Polarisation pol);
00538 
00539   // This function sets the current polarisation representation to the supplied
00540   // value and additionally converts the internal flux values to the correspond
00541   // to the new polarisation representation.
00542   void convertPol(ComponentType::Polarisation pol);
00543 
00544   // This function returns the flux values. The polarisation representation and
00545   // units are in whatever is current.
00546   const Vector<typename NumericTraits<T>::ConjugateType>& value() const;
00547 
00548   // This function returns the specified component of the flux values.
00549   // The polarisation representation and units are in whatever is current.
00550   const typename NumericTraits<T>::ConjugateType& value(uInt p) const;
00551 
00552   // This function returns the flux values after converting it to the Stokes
00553   // representation. The units of the returned Vector are the current units.
00554   void value(Vector<T>& value);
00555 
00556   // This function returns the flux values. The polarisation representation and
00557   // units are in whatever is current.
00558   void value(Vector<typename NumericTraits<T>::ConjugateType>& value) const;
00559 
00560   // This function returns the flux values after converting it to the Stokes
00561   // representation. The units of the returned Quantum are the current units of
00562   // the FluxRep object. The length of the Vector in the Quantum will be
00563   // resized to 4 elements if it is not already that length.
00564   void value(Quantum<Vector<T> >& value);
00565 
00566   // This function returns the flux values. The units of the returned Quantum
00567   // are the current units of the FluxRep object. Similarly the polarisation
00568   // representation of the returned Quantum is the current polarisation
00569   // representation. The length of the Vector in the Quantum will be resized to
00570   // 4 elements if it is not already that length.
00571   void value(Quantum
00572              <Vector<typename NumericTraits<T>::ConjugateType> >& value) const;
00573 
00574   // Return the flux value in a Quantum for the specified Stokes. Can convert
00575   // to Jy if requested.  
00576    Quantum<T> value (Stokes::StokesTypes stokes, Bool toJy=True);
00577 
00578   // This function sets the Flux values assuming the supplied value represents
00579   // the Stokes I flux in the current units. The other Stokes parameters are
00580   // set to zero.
00581   void setValue(T value);
00582 
00583   // This function sets the Flux values assuming the supplied values represent
00584   // the flux in the Stokes representation and is in the current units. The
00585   // Vector must have four elements.
00586   void setValue(const Vector<T>& value); 
00587 
00588   // This function sets the Flux values assuming the supplied values represent
00589   // the flux in the current representation and units. The Vector must have
00590   // four elements.
00591   void setValue(const Vector<typename NumericTraits<T>::ConjugateType>& value);
00592 
00593   // This function sets the flux values and units assuming the supplied values
00594   // represent the flux in the Stokes representation. The units of the Quantum
00595   // must be dimensionally equivalent to the "Jy" and the Vector must have four
00596   // elements.
00597   void setValue(const Quantum<Vector<T> >& value);
00598 
00599   // This function sets the flux values, units and polarisation assuming the
00600   // supplied values represent the flux in the specified representation. The
00601   // units of the Quantum must be dimensionally equivalent to the "Jy" and the
00602   // Vector must have four elements.
00603   void setValue(const
00604                 Quantum<Vector<typename NumericTraits<T>::ConjugateType> >& value,
00605                 ComponentType::Polarisation pol);
00606 
00607 // Set flux for given Stokes from Quantum. 
00608   void setValue (const Quantum<T>& value, Stokes::StokesTypes stokes);
00609 
00610   // Scale the Flux value by the specified amount. These functions multiply the
00611   // flux values irrespective of the current polarisation representation. If
00612   // only one scale factor is supplied then only the first component of the
00613   // flux is scaled.
00614   // <group>
00615   void scaleValue(const T& factor);
00616   void scaleValue(const T& factor0, const T& factor1,
00617                   const T& factor2, const T& factor3);
00618   void scaleValue(const typename NumericTraits<T>::ConjugateType& factor);
00619   void scaleValue(const typename NumericTraits<T>::ConjugateType& factor0,
00620                   const typename NumericTraits<T>::ConjugateType& factor1,
00621                   const typename NumericTraits<T>::ConjugateType& factor2,
00622                   const typename NumericTraits<T>::ConjugateType& factor3);
00623   // </group>
00624 
00625   // Set/get the errors in the flux
00626   // <group>
00627   void setErrors(const typename NumericTraits<T>::ConjugateType& error0,
00628                  const typename NumericTraits<T>::ConjugateType& error1,
00629                  const typename NumericTraits<T>::ConjugateType& error2,
00630                  const typename NumericTraits<T>::ConjugateType& error3);
00631 
00632   void setErrors(const Vector<typename NumericTraits<T>::ConjugateType>& errors);
00633 
00634   const Vector<typename NumericTraits<T>::ConjugateType>& errors() const;
00635   // </group>
00636 
00637   // This functions convert between a RecordInterface and a Flux object and
00638   // define how the Flux is represented in glish.  They return False if the
00639   // RecordInterface is malformed and append an error message to the supplied
00640   // string giving the reason.
00641   // <group>
00642   Bool fromRecord(String& errorMessage, const RecordInterface& record);
00643   Bool toRecord(String& errorMessage, RecordInterface& record) const;
00644   // </group>
00645 
00646   // Function which checks the internal data of this class for correct
00647   // dimensionality and consistent values. Returns True if everything is fine
00648   // otherwise returns False.
00649   Bool ok() const;
00650 
00651   // This function converts between a Vector in Stokes representation and one
00652   // in Circular representation.
00653   static void 
00654     stokesToCircular(Vector<typename NumericTraits<T>::ConjugateType>& out, 
00655                      const Vector<T>& in);
00656 
00657   // This function converts between a Vector in Stokes representation and one
00658   // in Circular representation. The imaginary components of the Stokes vector
00659   // are NOT ignored.
00660   static void 
00661     stokesToCircular(Vector<typename NumericTraits<T>::ConjugateType>& out, 
00662                      const
00663                      Vector<typename NumericTraits<T>::ConjugateType>& in);
00664 
00665   // This function converts between a Vector in Circular representation and one
00666   // in Stokes representation. The imaginary components of the Stokes vector
00667   // are discarded.
00668   static 
00669   void circularToStokes(Vector<T>& out,
00670                         const
00671                         Vector<typename NumericTraits<T>::ConjugateType>& in);
00672 
00673   // This function converts between a Vector in Circular representation and one
00674   // in Stokes representation. The imaginary components of the Stokes vector
00675   // are NOT ignored.
00676   static 
00677   void circularToStokes(Vector<typename NumericTraits<T>::ConjugateType>& out,
00678                         const
00679                         Vector<typename NumericTraits<T>::ConjugateType>& in);
00680 
00681   // This function converts between a Vector in Stokes representation and one
00682   // in Linear representation.
00683   static void
00684     stokesToLinear(Vector<typename NumericTraits<T>::ConjugateType>& out, 
00685                    const Vector<T>& in);
00686 
00687   // This function converts between a Vector in Stokes representation and one
00688   // in Linear representation. The imaginary components of the Stokes vector
00689   // are NOT ignored.
00690   static 
00691   void stokesToLinear(Vector<typename NumericTraits<T>::ConjugateType>& out, 
00692                       const
00693                       Vector<typename NumericTraits<T>::ConjugateType>& in);
00694 
00695   // This function converts between a Vector in Linear representation and one
00696   // in Stokes representation. The imaginary components of the Stokes vector
00697   // are discarded.
00698   static void
00699     linearToStokes(Vector<T>& out, 
00700                    const
00701                    Vector<typename NumericTraits<T>::ConjugateType>& in);
00702 
00703   // This function converts between a Vector in Linear representation and one
00704   // in Stokes representation. The imaginary components of the Stokes vector
00705   // are NOT ignored.
00706   static void
00707     linearToStokes(Vector<typename NumericTraits<T>::ConjugateType>& out, 
00708                    const Vector<typename NumericTraits<T>::ConjugateType>& in);
00709 
00710   // This function converts between a Vector in Linear representation and one
00711   // in Circular representation.
00712   static void
00713     linearToCircular(Vector<typename NumericTraits<T>::ConjugateType>& out, 
00714                      const
00715                      Vector<typename NumericTraits<T>::ConjugateType>& in);
00716 
00717   // This function converts between a Vector in Circular representation and one
00718   // in Linear representation.
00719   static void
00720     circularToLinear(Vector<typename NumericTraits<T>::ConjugateType>& out, 
00721                      const
00722                      Vector<typename NumericTraits<T>::ConjugateType>& in);
00723 
00724 private:
00725   CountedPtr<FluxRep<T> > itsFluxPtr;
00726 };
00727 
00728 
00729 } //# NAMESPACE CASA - END
00730 
00731 #ifndef CASACORE_NO_AUTO_TEMPLATES
00732 #include <components/ComponentModels/Flux.tcc>
00733 #endif //# CASACORE_NO_AUTO_TEMPLATES
00734 #endif