casacore
|
Table lookup 1-D coordinate, with interpolation. More...
#include <TabularCoordinate.h>
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... | |
TabularCoordinate & | operator= (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< String > | worldAxisNames () const |
Return the requested attribute. More... | |
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. 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< String > | worldAxisUnits () const |
Bool | overwriteWorldAxisUnits (const Vector< String > &units) |
Overwrite the world axis units with no compatibility checks or adjustment. More... | |
Vector< Double > | pixelValues () const |
Get the table, i.e. More... | |
Vector< Double > | worldValues () 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 Coordinate * | makeFourierCoordinate (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 Coordinate * | clone () 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< Double > | worldMixMin () const |
Vector< Double > | worldMixMax () 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 String & | errorMessage () 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 Coordinate * | rotate (const Quantum< Double > &angle) const |
return the result of rotating the coordinate clockwise through the specified angle. More... | |
Static Public Member Functions | |
static TabularCoordinate * | restore (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... | |
Coordinate & | operator= (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< Double > | worldMin_p |
toMix ranges. More... | |
Vector< Double > | worldMax_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)
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 |
Destructor.
|
private |
Common for assignment operator and destructor.
|
virtual |
Make a copy of the TabularCoordinate using new.
The caller is responsible for calling delete.
Implements casacore::Coordinate.
|
private |
Common code for copy ctor and assignment operator.
Implements casacore::Coordinate.
Implements casacore::Coordinate.
|
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.
|
private |
|
inlinevirtual |
Reimplemented from casacore::Coordinate.
Definition at line 214 of file TabularCoordinate.h.
References crpix_p.
|
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.
|
inlinevirtual |
Reimplemented from casacore::Coordinate.
Definition at line 216 of file TabularCoordinate.h.
References crval_p.
|
inlinevirtual |
Reimplemented from casacore::Coordinate.
Definition at line 215 of file TabularCoordinate.h.
References crval_p.
|
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 |
Implements casacore::Coordinate.
|
virtual |
Always returns 1.
Implements casacore::Coordinate.
|
virtual |
Implements casacore::Coordinate.
TabularCoordinate& casacore::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 casacore::Coordinate.
Implements casacore::Coordinate.
|
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 |
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 |
Implements casacore::Coordinate.
|
virtual |
Implements casacore::Coordinate.
|
virtual |
Implements casacore::Coordinate.
|
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 |
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 |
Always returns the String "Tabular".
Implements casacore::Coordinate.
|
virtual |
Implements casacore::Coordinate.
|
virtual |
Reimplemented from casacore::Coordinate.
|
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 |
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 |
Returns Coordinate::TABULAR.
Implements casacore::Coordinate.
Return the requested attribute.
Implements casacore::Coordinate.
Implements casacore::Coordinate.
|
private |
Definition at line 293 of file TabularCoordinate.h.
|
private |
Channel_True = channel_corrections_p(Channel_average).
Definition at line 300 of file TabularCoordinate.h.
|
private |
Definition at line 301 of file TabularCoordinate.h.
|
private |
Definition at line 293 of file TabularCoordinate.h.
Referenced by makePixelAbsolute(), and makePixelRelative().
|
private |
Definition at line 293 of file TabularCoordinate.h.
Referenced by makeWorldAbsolute(), and makeWorldRelative().
|
private |
Definition at line 294 of file TabularCoordinate.h.
|
private |
Definition at line 296 of file TabularCoordinate.h.
|
private |
Definition at line 295 of file TabularCoordinate.h.