casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes
casa::FluxRep< T > Class Template Reference

A class that represents the Flux (copy semantics) More...

#include <Flux.h>

List of all members.

Public Member Functions

 FluxRep ()
 The default constructor makes an object with I = 1, Q=U=V=0, a Stokes representation, and units of "Jy".
 FluxRep (T i)
 This constructor makes an object where I is specified and Q=U=V=0.
 FluxRep (T i, T q, T u, T v)
 This constructor makes an object where I,Q,U,V are all specified.
 FluxRep (typename NumericTraits< T >::ConjugateType xx, typename NumericTraits< T >::ConjugateType xy, typename NumericTraits< T >::ConjugateType yx, typename NumericTraits< T >::ConjugateType yy, ComponentType::Polarisation pol)
 This constructor makes an object where the flux values and polarisation representation are specified.
 FluxRep (const Vector< T > &flux)
 This constructor makes an object where I,Q,U,V are all specified by a Vector that must have four elements.
 FluxRep (const Vector< typename NumericTraits< T >::ConjugateType > &flux, ComponentType::Polarisation pol)
 This constructor makes an object where the flux values are all specified by a Vector that must have four elements.
 FluxRep (const Quantum< Vector< T > > &flux)
 This constructor makes an object where the flux values are all specified by a Quantum<Vector> that must have four elements.
 FluxRep (const Quantum< Vector< typename NumericTraits< T >::ConjugateType > > &flux, ComponentType::Polarisation pol)
 This constructor makes an object where the flux values are all specified by a Quantum<Vector> that must have four elements.
 FluxRep (const FluxRep< T > &other)
 The copy constructor uses copy semantics.
 ~FluxRep ()
 The destructor is trivial.
FluxRep< T > & operator= (const FluxRep< T > &other)
 The assignment operator uses copy semantics.
const Unitunit () const
 These two functions return the current units.
void unit (Unit &unit) const
void setUnit (const Unit &unit)
 This function sets the current unit.
void convertUnit (const Unit &unit)
 This function sets the current units to the supplied value and additionally converts the internal flux values to the correspond to the new unit.
ComponentType::Polarisation pol () const
 These two functions return the current polarisation representation.
void pol (ComponentType::Polarisation &pol) const
void setPol (ComponentType::Polarisation pol)
 This function sets the current polarisation representation.
void convertPol (ComponentType::Polarisation pol)
 This function sets the current polarisation representation to the supplied value and additionally converts the internal flux values to the correspond to the new polarisation representation.
const Vector< typename
NumericTraits< T >
::ConjugateType > & 
value () const
 This function returns the flux values.
const NumericTraits< T >
::ConjugateType & 
value (uInt p) const
 This function returns the specified component of the flux values.
void value (Vector< T > &value)
 This function returns the flux values after converting it to the Stokes representation.
void value (Vector< typename NumericTraits< T >::ConjugateType > &value) const
 This function returns the flux values.
void value (Quantum< Vector< T > > &value)
 This function returns the flux values after converting it to the Stokes representation.
void value (Quantum< Vector< typename NumericTraits< T >::ConjugateType > > &value) const
 This function returns the flux values.
Quantum< T > value (Stokes::StokesTypes stokes, Bool toJy=True)
 Return the flux value in a Quantum for the specified Stokes.
void setValue (T value)
 This function sets the Flux values assuming the supplied value represents the Stokes I flux in the current units.
void setValue (const Vector< T > &value)
 This function sets the Flux values assuming the supplied values represent the flux in the Stokes representation and is in the current units.
void setValue (const Vector< typename NumericTraits< T >::ConjugateType > &value)
 This function sets the Flux values assuming the supplied values represent the flux in the current representation and units.
void setValue (const Quantum< Vector< T > > &value)
 This function sets the flux values and units assuming the supplied values represent the flux in the Stokes representation.
void setValue (const Quantum< Vector< typename NumericTraits< T >::ConjugateType > > &value, ComponentType::Polarisation pol)
 This function sets the flux values, units and polarisation assuming the supplied values represent the flux in the specified representation.
void setValue (const Quantum< T > &value, Stokes::StokesTypes stokes)
 Set flux for given Stokes from Quantum.
void scaleValue (const T &factor)
 Scale the Flux value by the specified amount.
void scaleValue (const T &factor0, const T &factor1, const T &factor2, const T &factor3)
void scaleValue (const typename NumericTraits< T >::ConjugateType &factor)
void scaleValue (const typename NumericTraits< T >::ConjugateType &factor0, const typename NumericTraits< T >::ConjugateType &factor1, const typename NumericTraits< T >::ConjugateType &factor2, const typename NumericTraits< T >::ConjugateType &factor3)
void setErrors (const typename NumericTraits< T >::ConjugateType &error0, const typename NumericTraits< T >::ConjugateType &error1, const typename NumericTraits< T >::ConjugateType &error2, const typename NumericTraits< T >::ConjugateType &error3)
 Set/get the errors in the flux.
void setErrors (const Vector< typename NumericTraits< T >::ConjugateType > &errors)
const Vector< typename
NumericTraits< T >
::ConjugateType > & 
errors () const
Bool fromRecord (String &errorMessage, const RecordInterface &record)
 This functions convert between a RecordInterface and a FluxRep object and define how the FluxRep is represented in glish.
Bool toRecord (String &errorMessage, RecordInterface &record) const
Bool ok () const
 Function which checks the internal data of this class for correct dimensionality and consistent values.

Static Public Member Functions

static void setAllowedUnits (const Vector< String > &allowedUnits)
 in addition to Jy, allow these "flux" units.
static void clearAllowedUnits ()
 clear all allowed units set by setAllowedUnits

Private Attributes

Vector< typename NumericTraits
< T >::ConjugateType > 
itsVal
ComponentType::Polarisation itsPol
Unit itsUnit
Vector< typename NumericTraits
< T >::ConjugateType > 
itsErr

Static Private Attributes

static Vector< String_allowedUnits

Detailed Description

template<class T>
class casa::FluxRep< T >

A class that represents the Flux (copy semantics)

Intended use:

Public interface

 <h3>Review Status</h3><dl><dt>Date Reviewed:<dd>yyyy/mm/dd</dl> 

Prerequisite

Etymology

This class actually contains the flux values as distinct from the Flux class which is a pointer to this class. Hence this class name is a shortening of "Flux Representation". The Flux class is probably of more general user utility as its reference semantics can cut down on the number of temporary objects that get constructed.

Synopsis

This class encapsulates three quantities that are needed to more completely represent the polarised flux of a component. These quantities are:

Flux values.
These are four numbers which are the numerical value of the flux in all four polarisations. The values can be represented in either single or double precision depending on the template type.
Flux units.
These are the units for the flux values. The units must have dimensions of W/m^2/Hz and are represented using the Unit class. The most common unit is "Jy".
Polarisation representation.
This describes how the polarised flux is represented. It can be one of the following:
Stokes
The flux is representing using the Stokes I, Q, U, V components respectively.
Linear
The flux is representing using the XX,XY,YX,YY correlation products resp. X and Y is the signal from linear feeds at zero parallactic angle.
Circular
The flux is representing using the RR,RL,LR,LL correlation products resp. R and L is the signal from right and left handed circular feeds.

This class is templated but only two templated types are valid. These are:

The template type defines the precision of the Flux Values.

This class uses functions in the Flux class which convert between the different polarisation representations. They assume (until a decision has been made on this) that the total intensity is the average of the linear or circular correlation products. ie., I = (RR+LL)/2 = (XX+YY)/2.

In order to represent the Flux using the circular or linear representations the Flux values need to be complex (eg.,XY = I + iV, YX = I - iV) This class does not require, or check a number of constraints such as XY = conj(YX) and hence it is possible to define a flux using a linear or circular representation that cannot be completely represented using the Stokes representation. Because this class stores the flux values as complex numbers there is no loss of accuracy when converting between different polarisation representations. But it discards the imaginary component of the flux when externally representing the flux using with a Stokes representation (eg., when calling the value(Vector<T>&) function).

Because this class using Complex numbers with a precision that depends on the template type many of the function arguments are of type NumericTraits<T>. This simply a type that maps to Complex if T is Float and DComplex if T is a Double. Because of problems with the the gnu compiler functions which use this type as an argument MUST be inline. Hopefully this problem will go away sometime.

Example

The following example creates a FluxRep object using a Stokes representation and converts it to "WU" (Westerbork Units). After printing out the converted I flux it converts the Flux to a linear representation and prints out a Vector with the [XX,XY,YX,YY] values (still in "WU")

    FluxRep<Double> flux(1.0, 0.0, 0.0, 0.1); // I = 1.0, V = 0.1
    flux.convertUnit("WU");
    cout << "The I flux (in WU is)" << flux.value(0) << endl;
    flux.convertPol(ComponentType::LINEAR);
    cout << "The XX,XY,YX,YY flux (in WU is)" << flux.value() << endl;

Motivation

This class was needed to contain the flux in the ComponentModels module and centralizes a lot of code that would otherwise be duplicated in disparate places.

Thrown Exceptions

To Do

Definition at line 153 of file Flux.h.


Constructor & Destructor Documentation

template<class T>
casa::FluxRep< T >::FluxRep ( )

The default constructor makes an object with I = 1, Q=U=V=0, a Stokes representation, and units of "Jy".

template<class T>
casa::FluxRep< T >::FluxRep ( i)

This constructor makes an object where I is specified and Q=U=V=0.

It assumes a Stokes representation, and units of "Jy".

template<class T>
casa::FluxRep< T >::FluxRep ( i,
q,
u,
v 
)

This constructor makes an object where I,Q,U,V are all specified.

It assumes a Stokes representation, and units of "Jy".

template<class T>
casa::FluxRep< T >::FluxRep ( typename NumericTraits< T >::ConjugateType  xx,
typename NumericTraits< T >::ConjugateType  xy,
typename NumericTraits< T >::ConjugateType  yx,
typename NumericTraits< T >::ConjugateType  yy,
ComponentType::Polarisation  pol 
)

This constructor makes an object where the flux values and polarisation representation are specified.

It assumes the units are "Jy".

template<class T>
casa::FluxRep< T >::FluxRep ( const Vector< T > &  flux)

This constructor makes an object where I,Q,U,V are all specified by a Vector that must have four elements.

It assumes a Stokes representation, and units of "Jy".

template<class T>
casa::FluxRep< T >::FluxRep ( const Vector< typename NumericTraits< T >::ConjugateType > &  flux,
ComponentType::Polarisation  pol 
)

This constructor makes an object where the flux values are all specified by a Vector that must have four elements.

The polarisation representation must also be specified. It assumes the units are "Jy".

template<class T>
casa::FluxRep< T >::FluxRep ( const Quantum< Vector< T > > &  flux)

This constructor makes an object where the flux values are all specified by a Quantum<Vector> that must have four elements.

The Quantum must have units that are dimensionally equivalent to the "Jy" and these are the units of the FluxRep object. A Stokes polarisation representation is assumed.

template<class T>
casa::FluxRep< T >::FluxRep ( const Quantum< Vector< typename NumericTraits< T >::ConjugateType > > &  flux,
ComponentType::Polarisation  pol 
)

This constructor makes an object where the flux values are all specified by a Quantum<Vector> that must have four elements.

The Quantum must have units that are dimensionally equivalent to the "Jy" and these are the units of the FluxRep object. The polarisation representation must also be specified.

template<class T>
casa::FluxRep< T >::FluxRep ( const FluxRep< T > &  other)

The copy constructor uses copy semantics.

template<class T>
casa::FluxRep< T >::~FluxRep ( )

The destructor is trivial.


Member Function Documentation

template<class T>
static void casa::FluxRep< T >::clearAllowedUnits ( ) [static]

clear all allowed units set by setAllowedUnits

template<class T>
void casa::FluxRep< T >::convertPol ( ComponentType::Polarisation  pol)

This function sets the current polarisation representation to the supplied value and additionally converts the internal flux values to the correspond to the new polarisation representation.

template<class T>
void casa::FluxRep< T >::convertUnit ( const Unit unit)

This function sets the current units to the supplied value and additionally converts the internal flux values to the correspond to the new unit.

template<class T>
const Vector<typename NumericTraits<T>::ConjugateType>& casa::FluxRep< T >::errors ( ) const
template<class T>
Bool casa::FluxRep< T >::fromRecord ( String errorMessage,
const RecordInterface record 
)

This functions convert between a RecordInterface and a FluxRep object and define how the FluxRep is represented in glish.

They return False if the RecordInterface is malformed and append an error message to the supplied string giving the reason.

template<class T>
Bool casa::FluxRep< T >::ok ( ) const

Function which checks the internal data of this class for correct dimensionality and consistent values.

Returns True if everything is fine otherwise returns False.

template<class T>
FluxRep<T>& casa::FluxRep< T >::operator= ( const FluxRep< T > &  other)

The assignment operator uses copy semantics.

template<class T>
ComponentType::Polarisation casa::FluxRep< T >::pol ( ) const

These two functions return the current polarisation representation.

template<class T>
void casa::FluxRep< T >::pol ( ComponentType::Polarisation pol) const
template<class T>
void casa::FluxRep< T >::scaleValue ( const T &  factor)

Scale the Flux value by the specified amount.

These functions multiply the flux values irrespective of the current polarisation representation. If only one scale factor is supplied then only the first component of the flux is scaled.

template<class T>
void casa::FluxRep< T >::scaleValue ( const T &  factor0,
const T &  factor1,
const T &  factor2,
const T &  factor3 
)
template<class T>
void casa::FluxRep< T >::scaleValue ( const typename NumericTraits< T >::ConjugateType &  factor)
template<class T>
void casa::FluxRep< T >::scaleValue ( const typename NumericTraits< T >::ConjugateType &  factor0,
const typename NumericTraits< T >::ConjugateType &  factor1,
const typename NumericTraits< T >::ConjugateType &  factor2,
const typename NumericTraits< T >::ConjugateType &  factor3 
)
template<class T>
static void casa::FluxRep< T >::setAllowedUnits ( const Vector< String > &  allowedUnits) [static]

in addition to Jy, allow these "flux" units.

Useful when images have "flux-like" units such as Jy.km/s

template<class T>
void casa::FluxRep< T >::setErrors ( const typename NumericTraits< T >::ConjugateType &  error0,
const typename NumericTraits< T >::ConjugateType &  error1,
const typename NumericTraits< T >::ConjugateType &  error2,
const typename NumericTraits< T >::ConjugateType &  error3 
)

Set/get the errors in the flux.

template<class T>
void casa::FluxRep< T >::setErrors ( const Vector< typename NumericTraits< T >::ConjugateType > &  errors)
template<class T>
void casa::FluxRep< T >::setPol ( ComponentType::Polarisation  pol)

This function sets the current polarisation representation.

It does NOT convert the flux values.

template<class T>
void casa::FluxRep< T >::setUnit ( const Unit unit)

This function sets the current unit.

It does NOT convert the flux values to correspond to the new unit. The new unit must be dimensionally equivalent to the "Jy".

template<class T>
void casa::FluxRep< T >::setValue ( value)

This function sets the Flux values assuming the supplied value represents the Stokes I flux in the current units.

The other Stokes parameters are set to zero.

template<class T>
void casa::FluxRep< T >::setValue ( const Vector< T > &  value)

This function sets the Flux values assuming the supplied values represent the flux in the Stokes representation and is in the current units.

The Vector must have four elements.

template<class T>
void casa::FluxRep< T >::setValue ( const Vector< typename NumericTraits< T >::ConjugateType > &  value)

This function sets the Flux values assuming the supplied values represent the flux in the current representation and units.

The Vector must have four elements.

template<class T>
void casa::FluxRep< T >::setValue ( const Quantum< Vector< T > > &  value)

This function sets the flux values and units assuming the supplied values represent the flux in the Stokes representation.

The units of the Quantum must be dimensionally equivalent to the "Jy" and the Vector must have four elements.

template<class T>
void casa::FluxRep< T >::setValue ( const Quantum< Vector< typename NumericTraits< T >::ConjugateType > > &  value,
ComponentType::Polarisation  pol 
)

This function sets the flux values, units and polarisation assuming the supplied values represent the flux in the specified representation.

The units of the Quantum must be dimensionally equivalent to the "Jy" and the Vector must have four elements.

template<class T>
void casa::FluxRep< T >::setValue ( const Quantum< T > &  value,
Stokes::StokesTypes  stokes 
)

Set flux for given Stokes from Quantum.

template<class T>
Bool casa::FluxRep< T >::toRecord ( String errorMessage,
RecordInterface record 
) const
template<class T>
const Unit& casa::FluxRep< T >::unit ( ) const

These two functions return the current units.

template<class T>
void casa::FluxRep< T >::unit ( Unit unit) const
template<class T>
const Vector<typename NumericTraits<T>::ConjugateType>& casa::FluxRep< T >::value ( ) const

This function returns the flux values.

The polarisation representation and units are in whatever is current.

template<class T>
const NumericTraits<T>::ConjugateType& casa::FluxRep< T >::value ( uInt  p) const

This function returns the specified component of the flux values.

The polarisation representation and units are in whatever is current.

template<class T>
void casa::FluxRep< T >::value ( Vector< T > &  value)

This function returns the flux values after converting it to the Stokes representation.

The units of the returned Vector are the current units.

template<class T>
void casa::FluxRep< T >::value ( Vector< typename NumericTraits< T >::ConjugateType > &  value) const

This function returns the flux values.

The polarisation representation and units are in whatever is current.

template<class T>
void casa::FluxRep< T >::value ( Quantum< Vector< T > > &  value)

This function returns the flux values after converting it to the Stokes representation.

The units of the returned Quantum are the current units of the FluxRep object. The length of the Vector in the Quantum will be resized to 4 elements if it is not already that length.

template<class T>
void casa::FluxRep< T >::value ( Quantum< Vector< typename NumericTraits< T >::ConjugateType > > &  value) const

This function returns the flux values.

The units of the returned Quantum are the current units of the FluxRep object. Similarly the polarisation representation of the returned Quantum is the current polarisation representation. The length of the Vector in the Quantum will be resized to 4 elements if it is not already that length.

template<class T>
Quantum<T> casa::FluxRep< T >::value ( Stokes::StokesTypes  stokes,
Bool  toJy = True 
)

Return the flux value in a Quantum for the specified Stokes.

Can convert to Jy if requested.


Member Data Documentation

template<class T>
Vector<String> casa::FluxRep< T >::_allowedUnits [static, private]

Definition at line 363 of file Flux.h.

template<class T>
Vector<typename NumericTraits<T>::ConjugateType> casa::FluxRep< T >::itsErr [private]

Definition at line 362 of file Flux.h.

template<class T>
ComponentType::Polarisation casa::FluxRep< T >::itsPol [private]

Definition at line 360 of file Flux.h.

template<class T>
Unit casa::FluxRep< T >::itsUnit [private]

Definition at line 361 of file Flux.h.

template<class T>
Vector<typename NumericTraits<T>::ConjugateType> casa::FluxRep< T >::itsVal [private]

Definition at line 359 of file Flux.h.


The documentation for this class was generated from the following file: