casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
casa::FluxRep< T > Class Template Reference

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

#include <Flux.h>

Public Member Functions

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

Static Private Member Functions

static casacore::Unit _getConversionUnit (const casacore::Unit &unit)
 returns the conversion unit to which unit conforms. More...
 

Private Attributes

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

Static Private Attributes

static const std::vector
< casacore::Unit
_allowedUnits
 

Detailed Description

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

A class that represents the Flux (copy semantics)

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

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 casacore::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:
casacore::Stokes<dd> The flux is representing using the casacore::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 casacore::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 casacore::Stokes representation (eg., when calling the value(casacore::Vector<T>&) function).

Because this class using casacore::Complex numbers with a precision that depends on the template type many of the function arguments are of type casacore::NumericTraits<T>. This simply a type that maps to casacore::Complex if T is casacore::Float and casacore::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 casacore::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 casacore::Vector with the [XX,XY,YX,YY] values (still in "WU")

FluxRep<casacore::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 157 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 casacore::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 casacore::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 casacore::Stokes representation, and units of "Jy".

template<class T>
casa::FluxRep< T >::FluxRep ( typename casacore::NumericTraits< T >::ConjugateType  xx,
typename casacore::NumericTraits< T >::ConjugateType  xy,
typename casacore::NumericTraits< T >::ConjugateType  yx,
typename casacore::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 casacore::Vector< T > &  flux)

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

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

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

This constructor makes an object where the flux values are all specified by a casacore::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 casacore::Quantum< casacore::Vector< T > > &  flux)

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

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

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

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

The casacore::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 casacore::Unit casa::FluxRep< T >::_getConversionUnit ( const casacore::Unit unit)
staticprivate

returns the conversion unit to which unit conforms.

If unit does not conform to a supported unit, an exception is thrown.

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 casacore::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 casacore::Vector<typename casacore::NumericTraits<T>::ConjugateType>& casa::FluxRep< T >::errors ( ) const
template<class T>
casacore::Bool casa::FluxRep< T >::fromRecord ( casacore::String errorMessage,
const casacore::RecordInterface record 
)

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

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

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

casacore::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 casacore::NumericTraits< T >::ConjugateType &  factor)
template<class T>
void casa::FluxRep< T >::scaleValue ( const typename casacore::NumericTraits< T >::ConjugateType &  factor0,
const typename casacore::NumericTraits< T >::ConjugateType &  factor1,
const typename casacore::NumericTraits< T >::ConjugateType &  factor2,
const typename casacore::NumericTraits< T >::ConjugateType &  factor3 
)
template<class T>
void casa::FluxRep< T >::setErrors ( const typename casacore::NumericTraits< T >::ConjugateType &  error0,
const typename casacore::NumericTraits< T >::ConjugateType &  error1,
const typename casacore::NumericTraits< T >::ConjugateType &  error2,
const typename casacore::NumericTraits< T >::ConjugateType &  error3 
)

Set/get the errors in the flux.

template<class T>
void casa::FluxRep< T >::setErrors ( const casacore::Vector< typename casacore::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 casacore::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 casacore::Stokes I flux in the current units.

The other casacore::Stokes parameters are set to zero.

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

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

The casacore::Vector must have four elements.

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

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

The casacore::Vector must have four elements.

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

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

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

template<class T>
void casa::FluxRep< T >::setValue ( const casacore::Quantum< casacore::Vector< typename casacore::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 casacore::Quantum must be dimensionally equivalent to the "Jy" and the casacore::Vector must have four elements.

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

Set flux for given casacore::Stokes from Quantum.

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

These two functions return the current units.

template<class T>
void casa::FluxRep< T >::unit ( casacore::Unit unit) const
template<class T>
const casacore::Vector<typename casacore::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 casacore::NumericTraits<T>::ConjugateType& casa::FluxRep< T >::value ( casacore::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 ( casacore::Vector< T > &  value)

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

The units of the returned casacore::Vector are the current units.

template<class T>
void casa::FluxRep< T >::value ( casacore::Vector< typename casacore::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 ( casacore::Quantum< casacore::Vector< T > > &  value)

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

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

template<class T>
void casa::FluxRep< T >::value ( casacore::Quantum< casacore::Vector< typename casacore::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 casacore::Quantum is the current polarisation representation. The length of the casacore::Vector in the casacore::Quantum will be resized to 4 elements if it is not already that length.

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

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

Can convert to Jy if requested.

Member Data Documentation

template<class T>
const std::vector<casacore::Unit> casa::FluxRep< T >::_allowedUnits
staticprivate

Definition at line 360 of file Flux.h.

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

Definition at line 359 of file Flux.h.

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

Definition at line 357 of file Flux.h.

template<class T>
casacore::Unit casa::FluxRep< T >::itsUnit
private

Definition at line 358 of file Flux.h.

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

Definition at line 356 of file Flux.h.


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