casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
casa::TwoSidedShape Class Reference

Base class for component shapes with two sides. More...

#include <TwoSidedShape.h>

Inheritance diagram for casa::TwoSidedShape:
casa::ComponentShape casa::RecordTransformable casa::DiskShape casa::GaussianShape casa::LimbDarkenedDiskShape

List of all members.

Public Member Functions

virtual ~TwoSidedShape ()
 a virtual destructor is needed so that the actual destructor in the derived class will be used.
virtual ComponentType::Shape type () const =0
 return the actual component type.
void setWidth (const Quantum< Double > &majorAxis, const Quantum< Double > &minorAxis, const Quantum< Double > &positionAngle)
 set/get the width and orientation of the Shape.
void setWidth (const Quantum< Double > &majorAxis, const Double axialRatio, const Quantum< Double > &positionAngle)
Quantum< DoublemajorAxis () const
Quantum< DoubleminorAxis () const
Quantum< DoublepositionAngle () const
Double axialRatio () const
void setErrors (const Quantum< Double > &majorAxisError, const Quantum< Double > &minorAxisError, const Quantum< Double > &positionAngleError)
 set/get the errors on the shape parameters.
const Quantum< Double > & majorAxisError () const
const Quantum< Double > & minorAxisError () const
const Quantum< Double > & positionAngleError () const
Double axialRatioError () const
virtual void setWidthInRad (const Double majorAxis, const Double minorAxis, const Double positionAngle)=0
 set/get the width and orientation of the Shape.
virtual Double majorAxisInRad () const =0
virtual Double minorAxisInRad () const =0
virtual Double positionAngleInRad () const =0
virtual Double sample (const MDirection &direction, const MVAngle &pixelLatSize, const MVAngle &pixelLongSize) const =0
 Calculate the proportion of the flux that is in a pixel of specified size centered in the specified direction.
virtual void sample (Vector< Double > &scale, const Vector< MDirection::MVType > &directions, const MDirection::Ref &refFrame, const MVAngle &pixelLatSize, const MVAngle &pixelLongSize) const =0
 Same as the previous function except that many directions can be sampled at once.
virtual DComplex visibility (const Vector< Double > &uvw, const Double &frequency) const =0
 Return the Fourier transform of the component at the specified point in the spatial frequency domain.
virtual void visibility (Vector< DComplex > &scale, const Matrix< Double > &uvw, const Double &frequency) const =0
 Same as the previous function except that many (u,v,w) points can be sampled at once.
virtual void visibility (Matrix< DComplex > &scale, const Matrix< Double > &uvw, const Vector< Double > &frequency) const =0
 same as above but with many frequencies
virtual Bool isSymmetric () const
 determine whether the shape is symmetric or not.
virtual ComponentShapeclone () const =0
 Return a pointer to a copy of this object upcast to a ComponentShape object.
virtual uInt nParameters () const
 set/get the shape parameters associated with this shape.
virtual void setParameters (const Vector< Double > &newParms)
virtual Vector< Doubleparameters () const
virtual void setErrors (const Vector< Double > &newParms)
virtual Vector< Doubleerrors () const
virtual Vector< DoubleoptParameters () const
virtual void setOptParameters (const Vector< Double > &newOptParms)
virtual Bool fromRecord (String &errorMessage, const RecordInterface &record)
 This functions convert between a Record and a shape derived from this class.
virtual Bool toRecord (String &errorMessage, RecordInterface &record) const
 Convert the class to an Record representation.
virtual Bool convertUnit (String &errorMessage, const RecordInterface &record)
 Convert the parameters of the component to the specified units.
virtual Bool ok () const
 Function which checks the internal data of this class for correct dimensionality and consistent values.
virtual Vector< DoubletoPixel (const DirectionCoordinate &dirCoord) const
 Convert component shape to absolute pixels (longitude, latitude, major axis, minor axis, position angle [positive +x -> +y ; rad])
virtual Bool fromPixel (const Vector< Double > &parameters, const DirectionCoordinate &dirCoord)
 Fill the shape from the vector (longitude, latitude, major axis, minor axis, position angle [positive +x -> +y ; rad]).
virtual String sizeToString () const =0
 Get the string containing the various size quantities of a component.

Static Public Member Functions

static String sizeToString (Quantity major, Quantity minor, Quantity posangle, Bool includeUncertainties=True, Quantity majorErr=0, Quantity minorErr=0, Quantity posanErr=0)
 Format the string containing the various size quantities of a component.

Protected Member Functions

 TwoSidedShape ()
 The constructors and assignment operator are protected as only derived classes should use them.
 TwoSidedShape (const MDirection &direction, const Unit &majorAxisUnit, const Unit &minorAxisUnit, const Unit &paUnit)
 TwoSidedShape (const TwoSidedShape &other)
TwoSidedShapeoperator= (const TwoSidedShape &other)

Private Member Functions

Vector< DoublewidthToCartesian (const Quantum< Double > &width, const Quantum< Double > &pa, const MDirection &dirRef, const DirectionCoordinate &dirCoord, const Vector< Double > &pixelCen) const
MDirection directionFromCartesian (Double width, Double pa, const DirectionCoordinate &dirCoord, const Vector< Double > &pixelCen) const

Private Attributes

Unit itsMajUnit
 
   

Unit itsMinUnit
Unit itsPaUnit
Quantum< DoubleitsMajErr
Quantum< DoubleitsMinErr
Quantum< DoubleitsPaErr

Detailed Description

Base class for component shapes with two sides.

Intended use:

Public interface

 <h3>Review Status</h3><dl><dt>Date Reviewed:<dd>yyyy/mm/dd<dt>Test programs:<dd>tTwoSidedShape<dt>Demo programs:<dd>dTwoSidedShape</dl> 

Prerequisite

Synopsis

This base class adds a common interface for component shapes that have two sides. These shapes can be parameterised as having a major-axis width, minor-axis width and a position angle (as well as the reference direction). Currently there are two shapes which use this parameterisation, the Gaussian shape and the disk shape. Shapes which do not have this parameterisation, such as the point shape, are derived directly from the ComponentShape class.

Functions in this class implement a more convenient way of setting the parameters associated with two-sided shapes than the very flexible, but clumsy, parameters functions. The width parameters can be set using the setWidth functions. These functions enforce the rule that the major-axis width must not be smaller than the minor-axis width. Hence the axial ratio, which is the minor-axis width divided by the major-axis width, must always be greater than zero and less than or equal to one.

The functions in this class also free derived classes from the having to deal with units. Any angular unit can be used to specify the width of the shape. The widths returned by the majoraxis, minoraxis & the positionAngle functions are in the same units as they where specified in, unless the convertUnit function has been used to specify another unit.

For maximum speed the *InRad functions are provided. These functions bypass all the computation involving units.

The toRecord and fromRecord functions in this class standardise the record representation of classes derived from this one. In addition to the type and direction fields all records, discussed in the ComponentShape class, there are three more mandatory fields called; majoraxis, minoraxis & positionangle. These fields are record representation of Quantum<Double> objects and hence contain a value and unit. eg., A typical record for any of the shapes derived from this class might be:

    c := [type = 'gaussian',
          direction = [type = 'direction',
                       refer = 'b1950',
                       m0 = [value = .1, unit = 'rad']
                       m1 = [value = -.1, unit = 'rad']
                      ],
          majoraxis = [value=.5, unit='arcmin'],
          minoraxis = [value=1, unit='arcsec'],
          positionangle = [value=10, unit='deg']
         ]

Example

Because this is an abstract base class, an actual instance of this class cannot be constructed. However the interface it defines can be used inside a function. This allows functions which have TwoSidedShapes as arguments to work for any derived class. Hence the printShape function shown below will work for GaussianShapes and DiskShapes but not for PointShapes.

In this example the printShape function prints out the type of model it is working with, the reference direction of that model, the major-axis width, minor-axis width and the position angle. This example is also available in the dTwoSidedShape.cc file.

     void printShape(const TwoSidedShape& theShape) {
       cout << "This is a " << ComponentType::name(theShape.type())
            << " shape " << endl 
            << "with a reference direction of "
            << theShape.refDirection().getAngle("deg") << " ("
            << theShape.refDirection().getRefString() << ")" << endl
            << "and a major axis of " << theShape.majorAxis() << endl
            << "      minor axis of " << theShape.minorAxis() << endl
            << "and   position angle of " << theShape.positionAngle() << endl;
     }

Motivation

This base class was created to allow the reuse of a number of common functions by all derived classes.

To Do

Definition at line 152 of file TwoSidedShape.h.


Constructor & Destructor Documentation

virtual casa::TwoSidedShape::~TwoSidedShape ( ) [virtual]

a virtual destructor is needed so that the actual destructor in the derived class will be used.

The constructors and assignment operator are protected as only derived classes should use them.

casa::TwoSidedShape::TwoSidedShape ( const MDirection direction,
const Unit majorAxisUnit,
const Unit minorAxisUnit,
const Unit paUnit 
) [protected]
casa::TwoSidedShape::TwoSidedShape ( const TwoSidedShape other) [protected]

Member Function Documentation

Reimplemented in casa::GaussianShape.

virtual ComponentShape* casa::TwoSidedShape::clone ( ) const [pure virtual]

Return a pointer to a copy of this object upcast to a ComponentShape object.

The class that uses this function is responsible for deleting the pointer. This is used to implement a virtual copy constructor.

Implements casa::ComponentShape.

Implemented in casa::GaussianShape, casa::DiskShape, and casa::LimbDarkenedDiskShape.

virtual Bool casa::TwoSidedShape::convertUnit ( String errorMessage,
const RecordInterface record 
) [virtual]

Convert the parameters of the component to the specified units.

The supplied record must have three fields, namely 'majoraxis', 'minoraxis' & 'positionangle'. These fields must contains strings that are angular units and this function will convert the corresponding parameters to the specified units. This will have no effect on the shape of this class but will affect the format of the record returned by the toRecord function, and the units used in the the Quanta returned by the majoraxis, minoraxis & positionangle functions.

Implements casa::ComponentShape.

MDirection casa::TwoSidedShape::directionFromCartesian ( Double  width,
Double  pa,
const DirectionCoordinate dirCoord,
const Vector< Double > &  pixelCen 
) const [private]
virtual Vector<Double> casa::TwoSidedShape::errors ( ) const [virtual]

Implements casa::ComponentShape.

virtual Bool casa::TwoSidedShape::fromPixel ( const Vector< Double > &  parameters,
const DirectionCoordinate dirCoord 
) [virtual]

Fill the shape from the vector (longitude, latitude, major axis, minor axis, position angle [positive +x -> +y ; rad]).

The return is True if the input major axis (in pixels) became the minor axis (in world coordinates), else False.

Reimplemented from casa::ComponentShape.

virtual Bool casa::TwoSidedShape::fromRecord ( String errorMessage,
const RecordInterface record 
) [virtual]

This functions convert between a Record and a shape derived from this class.

These functions define how the object is represented in glish and this is detailed in the synopsis above. They return False if the record is malformed and append an error message to the supplied string giving the reason.

Implements casa::ComponentShape.

virtual Bool casa::TwoSidedShape::isSymmetric ( ) const [virtual]

determine whether the shape is symmetric or not.

Always returns True.

Implements casa::ComponentShape.

virtual Double casa::TwoSidedShape::majorAxisInRad ( ) const [pure virtual]
virtual Double casa::TwoSidedShape::minorAxisInRad ( ) const [pure virtual]
virtual uInt casa::TwoSidedShape::nParameters ( ) const [virtual]

set/get the shape parameters associated with this shape.

There are always three these being in order: the major-axis, the minor-axis and the position angle. All these angular quantities are specified and returned in radians. The Vector supplied to the setParameters and setErrors functions must have three elements and the Vector returned by the parameters and errors functions will have three elements. The errors are nominally 1-sigma in an implicit Gaussian distribution.

Implements casa::ComponentShape.

virtual Bool casa::TwoSidedShape::ok ( ) const [virtual]

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

Returns True if everything is fine otherwise returns False.

Reimplemented from casa::ComponentShape.

Reimplemented in casa::GaussianShape, casa::DiskShape, and casa::LimbDarkenedDiskShape.

TwoSidedShape& casa::TwoSidedShape::operator= ( const TwoSidedShape other) [protected]
virtual Vector<Double> casa::TwoSidedShape::optParameters ( ) const [virtual]

Implements casa::ComponentShape.

Reimplemented in casa::LimbDarkenedDiskShape.

virtual Vector<Double> casa::TwoSidedShape::parameters ( ) const [virtual]

Implements casa::ComponentShape.

virtual Double casa::TwoSidedShape::positionAngleInRad ( ) const [pure virtual]
virtual Double casa::TwoSidedShape::sample ( const MDirection direction,
const MVAngle pixelLatSize,
const MVAngle pixelLongSize 
) const [pure virtual]

Calculate the proportion of the flux that is in a pixel of specified size centered in the specified direction.

The returned value will always be between zero and one (inclusive).

Implements casa::ComponentShape.

Implemented in casa::GaussianShape, casa::DiskShape, and casa::LimbDarkenedDiskShape.

virtual void casa::TwoSidedShape::sample ( Vector< Double > &  scale,
const Vector< MDirection::MVType > &  directions,
const MDirection::Ref refFrame,
const MVAngle pixelLatSize,
const MVAngle pixelLongSize 
) const [pure virtual]

Same as the previous function except that many directions can be sampled at once.

The reference frame and pixel size must be the same for all the specified directions. A default implementation of this function is available that uses the single pixel sample function described above. However customised versions of this function will be more efficient as intermediate values only need to be computed once.

Implements casa::ComponentShape.

Implemented in casa::GaussianShape, casa::DiskShape, and casa::LimbDarkenedDiskShape.

void casa::TwoSidedShape::setErrors ( const Quantum< Double > &  majorAxisError,
const Quantum< Double > &  minorAxisError,
const Quantum< Double > &  positionAngleError 
)

set/get the errors on the shape parameters.

virtual void casa::TwoSidedShape::setErrors ( const Vector< Double > &  newParms) [virtual]

Implements casa::ComponentShape.

virtual void casa::TwoSidedShape::setOptParameters ( const Vector< Double > &  newOptParms) [virtual]

Implements casa::ComponentShape.

Reimplemented in casa::LimbDarkenedDiskShape.

virtual void casa::TwoSidedShape::setParameters ( const Vector< Double > &  newParms) [virtual]

Implements casa::ComponentShape.

void casa::TwoSidedShape::setWidth ( const Quantum< Double > &  majorAxis,
const Quantum< Double > &  minorAxis,
const Quantum< Double > &  positionAngle 
)

set/get the width and orientation of the Shape.

The width of the major must be larger than the width of the minor axes. The position angle is measured North through East ie a position angle of zero degrees means that the major axis is North-South and a position angle of 10 degrees moves the Northern edge to the East. The axial ratio is the ratio of the minor to major axes widths. Hence it is always between zero and one.

void casa::TwoSidedShape::setWidth ( const Quantum< Double > &  majorAxis,
const Double  axialRatio,
const Quantum< Double > &  positionAngle 
)
virtual void casa::TwoSidedShape::setWidthInRad ( const Double  majorAxis,
const Double  minorAxis,
const Double  positionAngle 
) [pure virtual]

set/get the width and orientation of the Shape.

These are the same as the above functions except that all widths are in radians.

Implemented in casa::GaussianShape, casa::DiskShape, and casa::LimbDarkenedDiskShape.

virtual String casa::TwoSidedShape::sizeToString ( ) const [pure virtual]

Get the string containing the various size quantities of a component.

Implements casa::ComponentShape.

Implemented in casa::GaussianShape, casa::DiskShape, and casa::LimbDarkenedDiskShape.

static String casa::TwoSidedShape::sizeToString ( Quantity  major,
Quantity  minor,
Quantity  posangle,
Bool  includeUncertainties = True,
Quantity  majorErr = 0,
Quantity  minorErr = 0,
Quantity  posanErr = 0 
) [static]

Format the string containing the various size quantities of a component.

virtual Vector<Double> casa::TwoSidedShape::toPixel ( const DirectionCoordinate dirCoord) const [virtual]

Convert component shape to absolute pixels (longitude, latitude, major axis, minor axis, position angle [positive +x -> +y ; rad])

Reimplemented from casa::ComponentShape.

virtual Bool casa::TwoSidedShape::toRecord ( String error,
RecordInterface outRecord 
) const [virtual]

Convert the class to an Record representation.

The input record may already contain fields and these fields may be silently overridden. New fields may be added to the input Record. If the transformation succeeds then the error String is unchanged and the function returns True. Otherwise the function returns False and appends an error message to the supplied String giving the reason why the conversion failed.

Implements casa::ComponentShape.

virtual ComponentType::Shape casa::TwoSidedShape::type ( ) const [pure virtual]

return the actual component type.

Implements casa::ComponentShape.

Implemented in casa::GaussianShape, casa::DiskShape, and casa::LimbDarkenedDiskShape.

virtual DComplex casa::TwoSidedShape::visibility ( const Vector< Double > &  uvw,
const Double frequency 
) const [pure virtual]

Return the Fourier transform of the component at the specified point in the spatial frequency domain.

The point is specified by a 3-element vector (u,v,w) that has units of meters and the frequency of the observation, in Hertz. These two quantities can be used to derive the required spatial frequency (s = uvw*freq/c). The w component is not used in these functions. The scale factor returned by this function can be used to scale the flux at the origin of the Fourier plane in order to determine the visibility at the specified point.

The "origin" of the transform is the reference direction of the component. This means for symmetric components, where the reference direction is at the centre, that the Fourier transform will always be real.

Implements casa::ComponentShape.

Implemented in casa::GaussianShape, casa::DiskShape, and casa::LimbDarkenedDiskShape.

virtual void casa::TwoSidedShape::visibility ( Vector< DComplex > &  scale,
const Matrix< Double > &  uvw,
const Double frequency 
) const [pure virtual]

Same as the previous function except that many (u,v,w) points can be sampled at once.

The observation frequency is the same for all the specified points. The uvw Matrix must have first dimension of three and the second dimension must match the length of the scale vector. A default implementation of this function is available that uses the single point visibility function described above. However customised versions of this function may be more efficient as intermediate values only need to be computed once.

Implements casa::ComponentShape.

Implemented in casa::GaussianShape, casa::DiskShape, and casa::LimbDarkenedDiskShape.

virtual void casa::TwoSidedShape::visibility ( Matrix< DComplex > &  scale,
const Matrix< Double > &  uvw,
const Vector< Double > &  frequency 
) const [pure virtual]

same as above but with many frequencies

Implements casa::ComponentShape.

Implemented in casa::GaussianShape, casa::DiskShape, and casa::LimbDarkenedDiskShape.

Vector<Double> casa::TwoSidedShape::widthToCartesian ( const Quantum< Double > &  width,
const Quantum< Double > &  pa,
const MDirection dirRef,
const DirectionCoordinate dirCoord,
const Vector< Double > &  pixelCen 
) const [private]

Member Data Documentation

Definition at line 351 of file TwoSidedShape.h.

   

Definition at line 348 of file TwoSidedShape.h.

Definition at line 352 of file TwoSidedShape.h.

Definition at line 349 of file TwoSidedShape.h.

Definition at line 353 of file TwoSidedShape.h.

Definition at line 350 of file TwoSidedShape.h.


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