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

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

#include <TabularCoordinate.h>

Inheritance diagram for casacore::TabularCoordinate:
casacore::Coordinate

Public Member Functions

 TabularCoordinate ()
 Default constructor. More...
 
 TabularCoordinate (Double refval, Double inc, Double refpix, const String &unit, const String &axisName)
 Create a linear TabularCoordinate where world = refval + inc*(pixel-refpix) More...
 
 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). More...
 
 TabularCoordinate (const Vector< Double > &pixelValues, const Vector< Double > &worldValues, const String &unit, const String &axisName)
 Construct a TabularCoordinate with the specified world values. More...
 
 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. More...
 
 TabularCoordinate (const TabularCoordinate &other)
 Copy constructor (copy semantics). More...
 
TabularCoordinateoperator= (const TabularCoordinate &other)
 Assignment (copy semantics). More...
 
virtual ~TabularCoordinate ()
 Destructor. More...
 
virtual Coordinate::Type type () const
 Returns Coordinate::TABULAR. More...
 
virtual String showType () const
 Always returns the String "Tabular". More...
 
virtual uInt nPixelAxes () const
 Always returns 1. More...
 
virtual uInt nWorldAxes () const
 
virtual Bool toWorld (Vector< Double > &world, const Vector< Double > &pixel, Bool=True) const
 Convert a pixel position to a world position or vice versa. More...
 
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. More...
 
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). More...
 
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. More...
 
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. More...
 
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. More...
 
virtual Vector< StringworldAxisUnits () const
 
Bool overwriteWorldAxisUnits (const Vector< String > &units)
 Overwrite the world axis units with no compatibility checks or adjustment. More...
 
Vector< DoublepixelValues () const
 Get the table, i.e. More...
 
Vector< DoubleworldValues () const
 
virtual Bool near (const Coordinate &other, Double tol=1e-6) const
 Comparison function. More...
 
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. More...
 
virtual Bool save (RecordInterface &container, const String &fieldName) const
 Save the TabularCoordinate into the supplied record using the supplied field name. More...
 
virtual Coordinateclone () const
 Make a copy of the TabularCoordinate using new. More...
 
- Public Member Functions inherited from casacore::Coordinate
virtual ~Coordinate ()
 Destructor. More...
 
virtual Bool toMix (Vector< Double > &worldOut, Vector< Double > &pixelOut, const Vector< Double > &worldIn, const Vector< Double > &pixelIn, const Vector< Bool > &worldAxes, const Vector< Bool > &pixelAxes, const Vector< Double > &worldMin, const Vector< Double > &worldMax) const
 Mixed absolute pixel/world coordinate conversion. More...
 
virtual Bool setWorldMixRanges (const IPosition &shape)
 Set the world min and max ranges, for use in function toMix, for a lattice of the given shape for this coordinate. More...
 
virtual void setDefaultWorldMixRanges ()
 
Vector< DoubleworldMixMin () const
 
Vector< DoubleworldMixMax () const
 
virtual void makeWorldAbsoluteRef (Vector< Double > &world, const Vector< Double > &refVal) const
 Make absolute coordinates relative and vice versa with respect to the given reference value. More...
 
virtual void makePixelRelativeMany (Matrix< Double > &pixel) const
 Batch up a lot of absolute/relative transformations. More...
 
virtual void makePixelAbsoluteMany (Matrix< Double > &pixel) const
 
virtual void makeWorldRelativeMany (Matrix< Double > &world) const
 
virtual void makeWorldAbsoluteMany (Matrix< Double > &world) const
 
const StringerrorMessage () const
 If the last conversion to world or pixel coordinates resulted in an error, report that error. More...
 
virtual void getPrecision (Int &precision, Coordinate::formatType &format, Bool showAsAbsolute, Int defPrecScientific, Int defPrecFixed, Int defPrecTime) const
 Provide a common interface to getting formatted representations of coordinate values. More...
 
virtual String format (String &units, Coordinate::formatType format, Double worldValue, uInt axis, Bool isAbsolute=True, Bool showAsAbsolute=True, Int precision=-1, Bool usePrecForMixed=False) const
 
String formatQuantity (String &units, Coordinate::formatType format, const Quantum< Double > &worldValue, uInt axis, Bool isAbsolute=True, Bool showAsAbsolute=True, Int precision=-1)
 
virtual Bool doNearPixel (const Coordinate &other, const Vector< Bool > &thisAxes, const Vector< Bool > &otherAxes, Double tol=1.0e-6) const
 Comparison only made for specified axes in this and other Coordinate The default implementation should be ok for all Coordinate types except Stokes and Quality... More...
 
virtual Coordinaterotate (const Quantum< Double > &angle) const
 return the result of rotating the coordinate clockwise through the specified angle. More...
 

Static Public Member Functions

static TabularCoordinaterestore (const RecordInterface &container, const String &fieldName)
 Recover the TabularCoordinate from a record. More...
 
- Static Public Member Functions inherited from casacore::Coordinate
static String typeToString (Coordinate::Type type)
 
static void set_wcs (::wcsprm &wcs)
 Call wcsset on the wcs structure. More...
 
static void init_wcs (::wcsprm &wcs, int naxis)
 Call wcsini on the wcs structure. More...
 
static void sub_wcs (const ::wcsprm &src, int &nsub, int axes[],::wcsprm &dst)
 Call wcssub on the src/dst pair. More...
 
static void copy_wcs (const ::wcsprm &src,::wcsprm &dst)
 Call wcssub on the src/dst pair with null nsub/axes. More...
 

Private Member Functions

void clear_self ()
 Common for assignment operator and destructor. More...
 
void copy (const TabularCoordinate &other)
 Common code for copy ctor and assignment operator. More...
 
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). More...
 
Interpolate1D< Double, Double > * channel_corrector_rev_p
 

Additional Inherited Members

- Public Types inherited from casacore::Coordinate
enum  Type {
  LINEAR,
  DIRECTION,
  SPECTRAL,
  STOKES,
  TABULAR,
  QUALITY,
  COORDSYS
}
 This enum lists the types of the derived classes. More...
 
enum  formatType {
  DEFAULT,
  SCIENTIFIC,
  FIXED,
  MIXED,
  TIME
}
 This enum is used for formatting world values into Strings. More...
 
- Protected Member Functions inherited from casacore::Coordinate
 Coordinate ()
 Default constructor. More...
 
 Coordinate (const Coordinate &other)
 Copy constructor (copy semantics) More...
 
Coordinateoperator= (const Coordinate &other)
 Assignment (copy semantics) More...
 
void set_error (const String &errorMsg) const
 Set error message. More...
 
Bool find_scale_factor (String &error, Vector< Double > &factor, const Vector< String > &units, const Vector< String > &oldUnits)
 
void fourierUnits (String &nameOut, String &unitOut, String &unitInCanon, Coordinate::Type type, Int axis, const String &unitIn, const String &nameIn) const
 Tries to find a canonical unit for input unit (e.g. More...
 
Bool toWorldWCS (Vector< Double > &world, const Vector< Double > &pixel, wcsprm &wcs) const
 Functions to interconvert pixel<->world via wcs. More...
 
Bool toPixelWCS (Vector< Double > &pixel, const Vector< Double > &world, wcsprm &wcs) const
 
Bool toWorldManyWCS (Matrix< Double > &world, const Matrix< Double > &pixel, Vector< Bool > &failures, wcsprm &wcs) const
 
Bool toPixelManyWCS (Matrix< Double > &pixel, const Matrix< Double > &world, Vector< Bool > &failures, wcsprm &wcs) const
 
void toCurrentMany (Matrix< Double > &world, const Vector< Double > &toCurrentFactors) const
 Functions for handling conversion between the current units and the wcs units. More...
 
void fromCurrentMany (Matrix< Double > &world, const Vector< Double > &toCurrentFactors) const
 
virtual void convertTo (Vector< Double > &) const
 Functions for handling conversion between the current reference frame and the native one. More...
 
virtual void convertFrom (Vector< Double > &) const
 
void convertToMany (Matrix< Double > &world) const
 Functions for handling conversion between the current reference frame and the native one for many conversions. More...
 
void convertFromMany (Matrix< Double > &world) const
 
void pcToXform (Matrix< Double > &xForm, const wcsprm &wcs) const
 Interconvert between wcs PC cards and Matrix xForm format. More...
 
void xFormToPC (wcsprm &wcs, const Matrix< Double > &xForm) const
 
- Protected Attributes inherited from casacore::Coordinate
Vector< DoubleworldMin_p
 toMix ranges. More...
 
Vector< DoubleworldMax_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");
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

casacore::TabularCoordinate::TabularCoordinate ( )

Default constructor.

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

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

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

casacore::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.

casacore::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).

casacore::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

casacore::TabularCoordinate::TabularCoordinate ( const TabularCoordinate other)

Copy constructor (copy semantics).

virtual casacore::TabularCoordinate::~TabularCoordinate ( )
virtual

Destructor.

Member Function Documentation

void casacore::TabularCoordinate::clear_self ( )
private

Common for assignment operator and destructor.

virtual Coordinate* casacore::TabularCoordinate::clone ( ) const
virtual

Make a copy of the TabularCoordinate using new.

The caller is responsible for calling delete.

Implements casacore::Coordinate.

void casacore::TabularCoordinate::copy ( const TabularCoordinate other)
private

Common code for copy ctor and assignment operator.

virtual Vector<Double> casacore::TabularCoordinate::increment ( ) const
virtual

Implements casacore::Coordinate.

virtual Matrix<Double> casacore::TabularCoordinate::linearTransform ( ) const
virtual

Implements casacore::Coordinate.

virtual Coordinate* casacore::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 casacore::Coordinate.

void casacore::TabularCoordinate::makeNonLinearTabularCoordinate ( const Vector< Double > &  pixelValues,
const Vector< Double > &  worldValues 
)
private
virtual void casacore::TabularCoordinate::makePixelAbsolute ( Vector< Double > &  pixel) const
inlinevirtual

Reimplemented from casacore::Coordinate.

Definition at line 214 of file TabularCoordinate.h.

References crpix_p.

virtual void casacore::TabularCoordinate::makePixelRelative ( Vector< Double > &  pixel) const
inlinevirtual

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 casacore::Coordinate.

Definition at line 213 of file TabularCoordinate.h.

References crpix_p.

virtual void casacore::TabularCoordinate::makeWorldAbsolute ( Vector< Double > &  world) const
inlinevirtual

Reimplemented from casacore::Coordinate.

Definition at line 216 of file TabularCoordinate.h.

References crval_p.

virtual void casacore::TabularCoordinate::makeWorldRelative ( Vector< Double > &  world) const
inlinevirtual

Reimplemented from casacore::Coordinate.

Definition at line 215 of file TabularCoordinate.h.

References crval_p.

virtual Bool casacore::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 casacore::Coordinate.

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

Implements casacore::Coordinate.

virtual uInt casacore::TabularCoordinate::nPixelAxes ( ) const
virtual

Always returns 1.

Implements casacore::Coordinate.

virtual uInt casacore::TabularCoordinate::nWorldAxes ( ) const
virtual

Implements casacore::Coordinate.

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

Assignment (copy semantics).

Bool casacore::TabularCoordinate::overwriteWorldAxisUnits ( const Vector< String > &  units)

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

Vector<Double> casacore::TabularCoordinate::pixelValues ( ) const

Get the table, i.e.

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

virtual Vector<Double> casacore::TabularCoordinate::referencePixel ( ) const
virtual

Implements casacore::Coordinate.

virtual Vector<Double> casacore::TabularCoordinate::referenceValue ( ) const
virtual

Implements casacore::Coordinate.

static TabularCoordinate* casacore::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 casacore::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 casacore::Coordinate.

virtual Bool casacore::TabularCoordinate::setIncrement ( const Vector< Double > &  inc)
virtual

Implements casacore::Coordinate.

virtual Bool casacore::TabularCoordinate::setLinearTransform ( const Matrix< Double > &  xform)
virtual

Implements casacore::Coordinate.

virtual Bool casacore::TabularCoordinate::setReferencePixel ( const Vector< Double > &  refPix)
virtual

Implements casacore::Coordinate.

virtual Bool casacore::TabularCoordinate::setReferenceValue ( const Vector< Double > &  refval)
virtual

Implements casacore::Coordinate.

virtual Bool casacore::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 casacore::Coordinate.

virtual Bool casacore::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 casacore::Coordinate.

virtual String casacore::TabularCoordinate::showType ( ) const
virtual

Always returns the String "Tabular".

Implements casacore::Coordinate.

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

Implements casacore::Coordinate.

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

Reimplemented from casacore::Coordinate.

virtual Bool casacore::TabularCoordinate::toWorld ( Vector< Double > &  world,
const Vector< Double > &  pixel,
Bool  = True 
) 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. The Bool parameter in toWorld() has no effect as this coordinate does not support a conversion layer frame.

Implements casacore::Coordinate.

Bool casacore::TabularCoordinate::toWorld ( Double world,
Double  pixel 
) const
virtual Bool casacore::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 casacore::Coordinate.

virtual Coordinate::Type casacore::TabularCoordinate::type ( ) const
virtual
virtual Vector<String> casacore::TabularCoordinate::worldAxisNames ( ) const
virtual

Return the requested attribute.

Implements casacore::Coordinate.

virtual Vector<String> casacore::TabularCoordinate::worldAxisUnits ( ) const
virtual

Implements casacore::Coordinate.

Vector<Double> casacore::TabularCoordinate::worldValues ( ) const

Member Data Documentation

Double casacore::TabularCoordinate::cdelt_p
private

Definition at line 293 of file TabularCoordinate.h.

Interpolate1D<Double,Double>* casacore::TabularCoordinate::channel_corrector_p
private

Channel_True = channel_corrections_p(Channel_average).

Definition at line 300 of file TabularCoordinate.h.

Interpolate1D<Double,Double>* casacore::TabularCoordinate::channel_corrector_rev_p
private

Definition at line 301 of file TabularCoordinate.h.

Double casacore::TabularCoordinate::crpix_p
private

Definition at line 293 of file TabularCoordinate.h.

Referenced by makePixelAbsolute(), and makePixelRelative().

Double casacore::TabularCoordinate::crval_p
private

Definition at line 293 of file TabularCoordinate.h.

Referenced by makeWorldAbsolute(), and makeWorldRelative().

Double casacore::TabularCoordinate::matrix_p
private

Definition at line 294 of file TabularCoordinate.h.

String casacore::TabularCoordinate::name_p
private

Definition at line 296 of file TabularCoordinate.h.

String casacore::TabularCoordinate::unit_p
private

Definition at line 295 of file TabularCoordinate.h.


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