Table lookup 1-D coordinate, with interpolation. More...
#include <TabularCoordinate.h>
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). | |
TabularCoordinate & | operator= (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, Bool=True) 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< String > | worldAxisNames () const |
Return the requested attribute. | |
virtual Vector< Double > | referencePixel () const |
virtual Matrix< Double > | linearTransform () const |
virtual Vector< Double > | increment () const |
virtual Vector< Double > | referenceValue () 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< String > | worldAxisUnits () const |
Bool | overwriteWorldAxisUnits (const Vector< String > &units) |
Overwrite the world axis units with no compatibility checks or adjustment. | |
Vector< Double > | pixelValues () const |
Get the table, i.e. | |
Vector< Double > | worldValues () 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 Coordinate * | makeFourierCoordinate (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 Coordinate * | clone () const |
Make a copy of the TabularCoordinate using new. | |
Static Public Member Functions | |
static TabularCoordinate * | restore (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 |
Table lookup 1-D coordinate, with interpolation.
Public interface
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;
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; }
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.
Definition at line 114 of file TabularCoordinate.h.
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.
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.
Implements casacore::Coordinate.
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 [inline, virtual] |
Reimplemented from casacore::Coordinate.
Definition at line 214 of file TabularCoordinate.h.
References crpix_p.
virtual void casacore::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 casacore::Coordinate.
Definition at line 213 of file TabularCoordinate.h.
References crpix_p.
virtual void casacore::TabularCoordinate::makeWorldAbsolute | ( | Vector< Double > & | world | ) | const [inline, virtual] |
Reimplemented from casacore::Coordinate.
Definition at line 216 of file TabularCoordinate.h.
References crval_p.
virtual void casacore::TabularCoordinate::makeWorldRelative | ( | Vector< Double > & | world | ) | const [inline, virtual] |
Reimplemented from casacore::Coordinate.
Definition at line 215 of file TabularCoordinate.h.
References crval_p.
virtual Bool casacore::TabularCoordinate::near | ( | const Coordinate & | other, | |
const Vector< Int > & | excludeAxes, | |||
Double | tol = 1e-6 | |||
) | const [virtual] |
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.
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).
Reimplemented from casacore::Coordinate.
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 casacore::Coordinate.
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.
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.
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.
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] |
Returns Coordinate::TABULAR.
Implements casacore::Coordinate.
Return the requested attribute.
Implements casacore::Coordinate.
Implements casacore::Coordinate.
Double casacore::TabularCoordinate::cdelt_p [private] |
Definition at line 293 of file TabularCoordinate.h.
Channel_True = channel_corrections_p(Channel_average).
Definition at line 300 of file TabularCoordinate.h.
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.