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

Table lookup 1-D coordinate, with interpolation. More...

#include <TabularCoordinate.h>

Inheritance diagram for casa::TabularCoordinate:
casa::Coordinate

List of all members.

Public Member Functions

 TabularCoordinate ()
 Default constructor.
 TabularCoordinate (Double refval, Double inc, Double refpix, const String &unit, const String &axisName)
 Create a linear TabularCoordinate where world = refval + inc*(pixel-refpix)
 TabularCoordinate (const Quantum< Double > &refval, const Quantum< Double > &inc, Double refpix, const String &axisName)
 Create a linear TabularCoordinate with a Quantum-based interface where world = refval + inc*(pixel-refpix).
 TabularCoordinate (const Vector< Double > &pixelValues, const Vector< Double > &worldValues, const String &unit, const String &axisName)
 Construct a TabularCoordinate with the specified world values.
 TabularCoordinate (const Vector< Double > &pixelValues, const Quantum< Vector< Double > > &worldValues, const String &axisName)
 Construct a TabularCoordinate with the specified world values via the Quantum-based interface.
 TabularCoordinate (const TabularCoordinate &other)
 Copy constructor (copy semantics).
TabularCoordinateoperator= (const TabularCoordinate &other)
 Assignment (copy semantics).
virtual ~TabularCoordinate ()
 Destructor.
virtual Coordinate::Type type () const
 Returns Coordinate::TABULAR.
virtual String showType () const
 Always returns the String "Tabular".
virtual uInt nPixelAxes () const
 Always returns 1.
virtual uInt nWorldAxes () const
virtual Bool toWorld (Vector< Double > &world, const Vector< Double > &pixel) const
 Convert a pixel position to a world position or vice versa.
virtual Bool toPixel (Vector< Double > &pixel, const Vector< Double > &world) const
Bool toWorld (Double &world, Double pixel) const
Bool toPixel (Double &pixel, Double world) const
virtual Bool toWorldMany (Matrix< Double > &world, const Matrix< Double > &pixel, Vector< Bool > &failures) const
 Batch up a lot of transformations.
virtual Bool toPixelMany (Matrix< Double > &pixel, const Matrix< Double > &world, Vector< Bool > &failures) const
virtual void makePixelRelative (Vector< Double > &pixel) const
 Make absolute coordinates relative and vice-versa (with respect to the referencfe value).
virtual void makePixelAbsolute (Vector< Double > &pixel) const
virtual void makeWorldRelative (Vector< Double > &world) const
virtual void makeWorldAbsolute (Vector< Double > &world) const
virtual Vector< StringworldAxisNames () const
 Return the requested attribute.
virtual Vector< DoublereferencePixel () const
virtual Matrix< DoublelinearTransform () const
virtual Vector< Doubleincrement () const
virtual Vector< DoublereferenceValue () const
virtual Bool setWorldAxisNames (const Vector< String > &names)
 Set the value of the requested attribute.
virtual Bool setReferencePixel (const Vector< Double > &refPix)
virtual Bool setLinearTransform (const Matrix< Double > &xform)
virtual Bool setIncrement (const Vector< Double > &inc)
virtual Bool setReferenceValue (const Vector< Double > &refval)
virtual Bool setWorldAxisUnits (const Vector< String > &units)
 Set/get the axis unit.
virtual Vector< StringworldAxisUnits () const
Bool overwriteWorldAxisUnits (const Vector< String > &units)
 Overwrite the world axis units with no compatibility checks or adjustment.
Vector< DoublepixelValues () const
 Get the table, i.e.
Vector< DoubleworldValues () const
virtual Bool near (const Coordinate &other, Double tol=1e-6) const
 Comparison function.
virtual Bool near (const Coordinate &other, const Vector< Int > &excludeAxes, Double tol=1e-6) const
virtual CoordinatemakeFourierCoordinate (const Vector< Bool > &axes, const Vector< Int > &shape) const
 Find the Coordinate for when we Fourier Transform ourselves.
virtual Bool save (RecordInterface &container, const String &fieldName) const
 Save the TabularCoordinate into the supplied record using the supplied field name.
virtual Coordinateclone () const
 Make a copy of the TabularCoordinate using new.

Static Public Member Functions

static TabularCoordinaterestore (const RecordInterface &container, const String &fieldName)
 Recover the TabularCoordinate from a record.

Private Member Functions

void clear_self ()
 Common for assignment operator and destructor.
void copy (const TabularCoordinate &other)
 Common code for copy ctor and assignment operator.
void makeNonLinearTabularCoordinate (const Vector< Double > &pixelValues, const Vector< Double > &worldValues)

Private Attributes

Double crval_p
Double cdelt_p
Double crpix_p
Double matrix_p
String unit_p
String name_p
Interpolate1D< Double, Double > * channel_corrector_p
 Channel_True = channel_corrections_p(Channel_average).
Interpolate1D< Double, Double > * channel_corrector_rev_p

Detailed Description

Table lookup 1-D coordinate, with interpolation.

Intended use:

Public interface

Review Status

Reviewed By:
Peter Barnes
Date Reviewed:
1999/12/24
Test programs:
tTabularCoordinate

Prerequisite

Synopsis

This class is used where the world and pixel values are determined by a lookup table. For fractional pixel values, a linear interpolation is used. The values returned for, e.g., the increment, are based on the average of the whole table. At present, the values must either increase or decrease monotonically.


Caution: All pixels coordinates are zero relative;

Example

Let's make a non-linear TabularCoordinate and convert a pixel value to world (which will use linear interpolation)

       Vector<Double> pixelValues(3); 
       Vector<Double> worldValues(3); 
       pixelValues(0) = 122.0;
       pixelValues(1) = 300.0;
       pixelValues(2) = 6524.0;
       worldValues(0) = 1.1e6;
       worldValues(1) = 2.1e6;
       worldValues(2) = 2.2e6;
   
       String unit("km");
       String axisName("length");
   
       TabularCoordinate tc(pixelValues, worldValues, unit, axisName);
   
       Double world, pixel;
       pixel = 200.12;
       if (!tc.toWorld(world, pixel)) {
         cerr << "Error : " << tc.errorMessage() << endl;
       } else {
         cerr << "pixel, world = " << pixel << ", " << world << endl;
       }

Motivation

This class was motivated by the need for an irregular axis, such as a collection of frequencies. For example, the SpectralCoordinate class contains a TabularCoordinate.

Thrown Exceptions

To Do

Definition at line 114 of file TabularCoordinate.h.


Constructor & Destructor Documentation

Default constructor.

It is equivalent to TabularCoordinate(0,1,0, "", "Tabular");

casa::TabularCoordinate::TabularCoordinate ( Double  refval,
Double  inc,
Double  refpix,
const String unit,
const String axisName 
)

Create a linear TabularCoordinate where world = refval + inc*(pixel-refpix)

casa::TabularCoordinate::TabularCoordinate ( const Quantum< Double > &  refval,
const Quantum< Double > &  inc,
Double  refpix,
const String axisName 
)

Create a linear TabularCoordinate with a Quantum-based interface where world = refval + inc*(pixel-refpix).

The units of the increment (inc) will be converted to those of the reference value (refVal) which will then serve as the units of the Coordinate.

casa::TabularCoordinate::TabularCoordinate ( const Vector< Double > &  pixelValues,
const Vector< Double > &  worldValues,
const String unit,
const String axisName 
)

Construct a TabularCoordinate with the specified world values.

The increments and related functions return the average values calculated from the first and last world values. The number of pixel and world values must be the same. Normally the pixel values will be 0,1,2,..., but this is not required.

A linear interpolation/extrapolation is used for channels which are not supplied. The reference channel (pixel) is chosen to be 0. The frequencies must increase or decrease monotonically (otherwise the toPixel lookup would not be possible).

casa::TabularCoordinate::TabularCoordinate ( const Vector< Double > &  pixelValues,
const Quantum< Vector< Double > > &  worldValues,
const String axisName 
)

Construct a TabularCoordinate with the specified world values via the Quantum-based interface.

All comments for the previous constructor apply

Copy constructor (copy semantics).

Destructor.


Member Function Documentation

Common for assignment operator and destructor.

virtual Coordinate* casa::TabularCoordinate::clone ( ) const [virtual]

Make a copy of the TabularCoordinate using new.

The caller is responsible for calling delete.

Implements casa::Coordinate.

void casa::TabularCoordinate::copy ( const TabularCoordinate other) [private]

Common code for copy ctor and assignment operator.

virtual Vector<Double> casa::TabularCoordinate::increment ( ) const [virtual]

Implements casa::Coordinate.

Implements casa::Coordinate.

virtual Coordinate* casa::TabularCoordinate::makeFourierCoordinate ( const Vector< Bool > &  axes,
const Vector< Int > &  shape 
) const [virtual]

Find the Coordinate for when we Fourier Transform ourselves.

This pointer must be deleted by the caller. Axes specifies which axes of the Coordinate you wish to transform. Shape specifies the shape of the image associated with all the axes of the Coordinate. Currently the output reference pixel is always shape/2. If the pointer returned is 0, it failed with a message in errorMessage

Reimplemented from casa::Coordinate.

void casa::TabularCoordinate::makeNonLinearTabularCoordinate ( const Vector< Double > &  pixelValues,
const Vector< Double > &  worldValues 
) [private]
virtual void casa::TabularCoordinate::makePixelAbsolute ( Vector< Double > &  pixel) const [inline, virtual]

Reimplemented from casa::Coordinate.

Definition at line 212 of file TabularCoordinate.h.

References crpix_p.

virtual void casa::TabularCoordinate::makePixelRelative ( Vector< Double > &  pixel) const [inline, virtual]

Make absolute coordinates relative and vice-versa (with respect to the referencfe value).

Vectors must be length nPixelAxes() or nWorldAxes() or memory access errors will occur

Reimplemented from casa::Coordinate.

Definition at line 211 of file TabularCoordinate.h.

References crpix_p.

virtual void casa::TabularCoordinate::makeWorldAbsolute ( Vector< Double > &  world) const [inline, virtual]

Reimplemented from casa::Coordinate.

Definition at line 214 of file TabularCoordinate.h.

References crval_p.

virtual void casa::TabularCoordinate::makeWorldRelative ( Vector< Double > &  world) const [inline, virtual]

Reimplemented from casa::Coordinate.

Definition at line 213 of file TabularCoordinate.h.

References crval_p.

virtual Bool casa::TabularCoordinate::near ( const Coordinate other,
Double  tol = 1e-6 
) const [virtual]

Comparison function.

Any private Double data members are compared with the specified fractional tolerance. Don't compare on the specified axes in the Coordinate. If the comparison returns False, method errorMessage() contains a message about why.

Implements casa::Coordinate.

virtual Bool casa::TabularCoordinate::near ( const Coordinate other,
const Vector< Int > &  excludeAxes,
Double  tol = 1e-6 
) const [virtual]

Implements casa::Coordinate.

virtual uInt casa::TabularCoordinate::nPixelAxes ( ) const [virtual]

Always returns 1.

Implements casa::Coordinate.

virtual uInt casa::TabularCoordinate::nWorldAxes ( ) const [virtual]

Implements casa::Coordinate.

TabularCoordinate& casa::TabularCoordinate::operator= ( const TabularCoordinate other)

Assignment (copy semantics).

Overwrite the world axis units with no compatibility checks or adjustment.

Get the table, i.e.

the pixel and world values. The length of these Vectors will be zero if this axis is pure linear.

Implements casa::Coordinate.

Implements casa::Coordinate.

static TabularCoordinate* casa::TabularCoordinate::restore ( const RecordInterface container,
const String fieldName 
) [static]

Recover the TabularCoordinate from a record.

A null pointer means that the restoration did not succeed - probably because fieldName doesn't exist or doesn't contain a CoordinateSystem.

virtual Bool casa::TabularCoordinate::save ( RecordInterface container,
const String fieldName 
) const [virtual]

Save the TabularCoordinate into the supplied record using the supplied field name.

The field must not exist, otherwise False is returned.

Implements casa::Coordinate.

virtual Bool casa::TabularCoordinate::setIncrement ( const Vector< Double > &  inc) [virtual]

Implements casa::Coordinate.

virtual Bool casa::TabularCoordinate::setLinearTransform ( const Matrix< Double > &  xform) [virtual]

Implements casa::Coordinate.

virtual Bool casa::TabularCoordinate::setReferencePixel ( const Vector< Double > &  refPix) [virtual]

Implements casa::Coordinate.

virtual Bool casa::TabularCoordinate::setReferenceValue ( const Vector< Double > &  refval) [virtual]

Implements casa::Coordinate.

virtual Bool casa::TabularCoordinate::setWorldAxisNames ( const Vector< String > &  names) [virtual]

Set the value of the requested attribute.

Note that these just change the internal values, they do not cause any recomputation.

Implements casa::Coordinate.

virtual Bool casa::TabularCoordinate::setWorldAxisUnits ( const Vector< String > &  units) [virtual]

Set/get the axis unit.

Adjust the increment and reference value by the ratio of the old and new units. The unit must be compatible with the current units.

Implements casa::Coordinate.

virtual String casa::TabularCoordinate::showType ( ) const [virtual]

Always returns the String "Tabular".

Implements casa::Coordinate.

virtual Bool casa::TabularCoordinate::toPixel ( Vector< Double > &  pixel,
const Vector< Double > &  world 
) const [virtual]

Implements casa::Coordinate.

Bool casa::TabularCoordinate::toPixel ( Double pixel,
Double  world 
) const
virtual Bool casa::TabularCoordinate::toPixelMany ( Matrix< Double > &  pixel,
const Matrix< Double > &  world,
Vector< Bool > &  failures 
) const [virtual]

Reimplemented from casa::Coordinate.

virtual Bool casa::TabularCoordinate::toWorld ( Vector< Double > &  world,
const Vector< Double > &  pixel 
) const [virtual]

Convert a pixel position to a world position or vice versa.

Returns True if the conversion succeeds, otherwise it returns False and method errorMessage contains an error message. The output vectors are appropriately resized.

Implements casa::Coordinate.

Bool casa::TabularCoordinate::toWorld ( Double world,
Double  pixel 
) const
virtual Bool casa::TabularCoordinate::toWorldMany ( Matrix< Double > &  world,
const Matrix< Double > &  pixel,
Vector< Bool > &  failures 
) const [virtual]

Batch up a lot of transformations.

The first (most rapidly varying) axis of the matrices contain the coordinates. Returns False if any conversion failed and errorMessage() will hold a message. The failures array (True for fail, False for success) is the length of the number of conversions and holds an error status for each conversion.

Reimplemented from casa::Coordinate.

virtual Coordinate::Type casa::TabularCoordinate::type ( ) const [virtual]

Returns Coordinate::TABULAR.

Implements casa::Coordinate.

Return the requested attribute.

Implements casa::Coordinate.

Implements casa::Coordinate.


Member Data Documentation

Definition at line 291 of file TabularCoordinate.h.

Channel_True = channel_corrections_p(Channel_average).

Definition at line 298 of file TabularCoordinate.h.

Definition at line 299 of file TabularCoordinate.h.

Definition at line 291 of file TabularCoordinate.h.

Referenced by makePixelAbsolute(), and makePixelRelative().

Definition at line 291 of file TabularCoordinate.h.

Referenced by makeWorldAbsolute(), and makeWorldRelative().

Definition at line 292 of file TabularCoordinate.h.

Definition at line 294 of file TabularCoordinate.h.

Definition at line 293 of file TabularCoordinate.h.


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