casa
$Rev:20696$
|
Interconvert between pixel and a linear world coordinate. More...
#include <LinearCoordinate.h>
Public Member Functions | |
LinearCoordinate (uInt naxes=1) | |
The default constructor makes a LinearCoordinate for which pixel and world coordinates are equal. | |
LinearCoordinate (const Vector< String > &names, const Vector< String > &units, const Vector< Double > &refVal, const Vector< Double > &inc, const Matrix< Double > &pc, const Vector< Double > &refPix) | |
Construct the LinearCoordinate. | |
LinearCoordinate (const Vector< String > &names, const Vector< Quantum< Double > > &refVal, const Vector< Quantum< Double > > &inc, const Matrix< Double > &pc, const Vector< Double > &refPix) | |
Construct LinearCoordinate with Quantum-based interface. | |
LinearCoordinate (const wcsprm &wcs, Bool oneRel=True) | |
Constructor from WCS structure; must hold ONLY a linear wcs structure Specify whether the absolute pixel coordinates in the wcs structure are 0- or 1-relative. | |
LinearCoordinate (const LinearCoordinate &other) | |
Copy constructor (copy semantics). | |
LinearCoordinate & | operator= (const LinearCoordinate &other) |
Assignment (copy semantics). | |
virtual | ~LinearCoordinate () |
Destructor. | |
virtual Coordinate::Type | type () const |
Returns Coordinate::LINEAR. | |
virtual String | showType () const |
Returns the String "Linear". | |
virtual uInt | nPixelAxes () const |
Returns the number of pixel/world axes. | |
virtual uInt | nWorldAxes () const |
virtual Bool | toWorld (Vector< Double > &world, const Vector< Double > &pixel) const |
Convert a pixel position to a worl position or vice versa. | |
virtual Bool | toPixel (Vector< Double > &pixel, const Vector< Double > &world) const |
virtual Vector< String > | worldAxisNames () const |
Return the requested attribute. | |
virtual Vector< Double > | referenceValue () const |
virtual Vector< Double > | increment () const |
virtual Matrix< Double > | linearTransform () const |
virtual Vector< Double > | referencePixel () const |
virtual Vector< String > | worldAxisUnits () const |
virtual Bool | setWorldAxisNames (const Vector< String > &names) |
Set the value of the requested attributed. | |
virtual Bool | setReferencePixel (const Vector< Double > &refPix) |
virtual Bool | setLinearTransform (const Matrix< Double > &pc) |
virtual Bool | setIncrement (const Vector< Double > &inc) |
virtual Bool | setReferenceValue (const Vector< Double > &refval) |
virtual Bool | setWorldAxisUnits (const Vector< String > &units) |
Set the world axis units. | |
Bool | overwriteWorldAxisUnits (const Vector< String > &units) |
Overwrite the world axis units with no compatibility checks or adjustment. | |
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 LinearCoordinate into the supplied record using the supplied field name. | |
virtual Coordinate * | clone () const |
Make a copy of the LinearCoordinate using new. | |
Static Public Member Functions | |
static LinearCoordinate * | restore (const RecordInterface &container, const String &fieldName) |
Restore the LinearCoordinate from a record. | |
Private Member Functions | |
void | copy (const LinearCoordinate &other) |
Copy private data. | |
void | makeWCS (wcsprm &wcs, uInt naxis, const Vector< Double > &refPix, const Vector< Double > &refVal, const Vector< Double > &incr, const Matrix< Double > &pc, const Vector< String > &units, const Vector< String > &names) |
Make wcs structure. | |
Private Attributes | |
mutable::wcsprm | wcs_p |
An interface to the WCSLIB linear transformation routines. |
Interconvert between pixel and a linear world coordinate.
Public interface
The LinearCoordinate class ties pixel and world axes together through a general linear transformation.
world = (cdelt * PC * (pixel - crpix)) + crval
Where PC is an NxN matrix; pixel, crval, crpix and world are length N vectors, and cdelt is an NxN diagonal matrix, represented as a length N vector.
The LinearCoordinate can contain several uncoupled axes (similar to the way in which the DirectionCoordinate contains two axes).
Caution: All pixels coordinates are zero relative;
Let's make a LinearCoordinate with just one axis containing a coordinate describing length.
Vector<Double> crpix(1); crpix = 0.0; Vector<Double> crval(1); crval = 100.0; Vector<Double> cdelt(1); cdelt = -10.0; Matrix<Double> pc(1,1); pc= 0; pc.diagonal() = 1.0; Vector<String> name(1); name = "length"; Vector<String> units(1); units = "km"; LinearCoordinate lin(names, units, crval, cdelt, pc, crpix);
Now do a coordinate conversion
Vector<Double> world, pixel(1); pixel = 2.0; if (!lin.toWorld(world, pixel)) { cerr << "Error : " << lin.errorMessage() << endl; } else { cerr << "pixel, world = " << pixel << world << endl; }
The answer should of course be -20km.
This class is intended for use with axes which do not have specific coordinate types. A "time" axis would be a good example.
Definition at line 120 of file LinearCoordinate.h.
casa::LinearCoordinate::LinearCoordinate | ( | uInt | naxes = 1 | ) |
The default constructor makes a LinearCoordinate for which pixel and world coordinates are equal.
naxes
gives the number of axes in the Coordinate.
casa::LinearCoordinate::LinearCoordinate | ( | const Vector< String > & | names, |
const Vector< String > & | units, | ||
const Vector< Double > & | refVal, | ||
const Vector< Double > & | inc, | ||
const Matrix< Double > & | pc, | ||
const Vector< Double > & | refPix | ||
) |
Construct the LinearCoordinate.
casa::LinearCoordinate::LinearCoordinate | ( | const Vector< String > & | names, |
const Vector< Quantum< Double > > & | refVal, | ||
const Vector< Quantum< Double > > & | inc, | ||
const Matrix< Double > & | pc, | ||
const Vector< Double > & | refPix | ||
) |
Construct LinearCoordinate with Quantum-based interface.
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::LinearCoordinate::LinearCoordinate | ( | const wcsprm & | wcs, |
Bool | oneRel = True |
||
) |
Constructor from WCS structure; must hold ONLY a linear wcs structure Specify whether the absolute pixel coordinates in the wcs structure are 0- or 1-relative.
The coordinate is always constructed with 0-relative pixel coordinates
casa::LinearCoordinate::LinearCoordinate | ( | const LinearCoordinate & | other | ) |
Copy constructor (copy semantics).
virtual casa::LinearCoordinate::~LinearCoordinate | ( | ) | [virtual] |
Destructor.
virtual Coordinate* casa::LinearCoordinate::clone | ( | ) | const [virtual] |
Make a copy of the LinearCoordinate using new.
The caller is responsible for calling delete.
Implements casa::Coordinate.
void casa::LinearCoordinate::copy | ( | const LinearCoordinate & | other | ) | [private] |
Copy private data.
virtual Vector<Double> casa::LinearCoordinate::increment | ( | ) | const [virtual] |
Implements casa::Coordinate.
virtual Matrix<Double> casa::LinearCoordinate::linearTransform | ( | ) | const [virtual] |
Implements casa::Coordinate.
virtual Coordinate* casa::LinearCoordinate::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::LinearCoordinate::makeWCS | ( | wcsprm & | wcs, |
uInt | naxis, | ||
const Vector< Double > & | refPix, | ||
const Vector< Double > & | refVal, | ||
const Vector< Double > & | incr, | ||
const Matrix< Double > & | pc, | ||
const Vector< String > & | units, | ||
const Vector< String > & | names | ||
) | [private] |
Make wcs structure.
virtual Bool casa::LinearCoordinate::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::LinearCoordinate::near | ( | const Coordinate & | other, |
const Vector< Int > & | excludeAxes, | ||
Double | tol = 1e-6 |
||
) | const [virtual] |
Implements casa::Coordinate.
virtual uInt casa::LinearCoordinate::nPixelAxes | ( | ) | const [virtual] |
Returns the number of pixel/world axes.
The number of axes is arbitrary, however the number of world and pixel axes must at present be the same.
Implements casa::Coordinate.
virtual uInt casa::LinearCoordinate::nWorldAxes | ( | ) | const [virtual] |
Implements casa::Coordinate.
LinearCoordinate& casa::LinearCoordinate::operator= | ( | const LinearCoordinate & | other | ) |
Assignment (copy semantics).
Bool casa::LinearCoordinate::overwriteWorldAxisUnits | ( | const Vector< String > & | units | ) |
Overwrite the world axis units with no compatibility checks or adjustment.
virtual Vector<Double> casa::LinearCoordinate::referencePixel | ( | ) | const [virtual] |
Implements casa::Coordinate.
virtual Vector<Double> casa::LinearCoordinate::referenceValue | ( | ) | const [virtual] |
Implements casa::Coordinate.
static LinearCoordinate* casa::LinearCoordinate::restore | ( | const RecordInterface & | container, |
const String & | fieldName | ||
) | [static] |
Restore the LinearCoordinate 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::LinearCoordinate::save | ( | RecordInterface & | container, |
const String & | fieldName | ||
) | const [virtual] |
Save the LinearCoordinate into the supplied record using the supplied field name.
The field must not already exist, otherwise False
is returned.
Implements casa::Coordinate.
virtual Bool casa::LinearCoordinate::setIncrement | ( | const Vector< Double > & | inc | ) | [virtual] |
Implements casa::Coordinate.
virtual Bool casa::LinearCoordinate::setLinearTransform | ( | const Matrix< Double > & | pc | ) | [virtual] |
Implements casa::Coordinate.
virtual Bool casa::LinearCoordinate::setReferencePixel | ( | const Vector< Double > & | refPix | ) | [virtual] |
Implements casa::Coordinate.
virtual Bool casa::LinearCoordinate::setReferenceValue | ( | const Vector< Double > & | refval | ) | [virtual] |
Implements casa::Coordinate.
virtual Bool casa::LinearCoordinate::setWorldAxisNames | ( | const Vector< String > & | names | ) | [virtual] |
Set the value of the requested attributed.
Note that these just change the internal values, they do not cause any recomputation.
Implements casa::Coordinate.
virtual Bool casa::LinearCoordinate::setWorldAxisUnits | ( | const Vector< String > & | units | ) | [virtual] |
Set the world axis units.
Adjust the increment and reference value by the ratio of the old and new units. The units must be compatible with the current units.
Implements casa::Coordinate.
virtual String casa::LinearCoordinate::showType | ( | ) | const [virtual] |
Returns the String "Linear".
Implements casa::Coordinate.
virtual Bool casa::LinearCoordinate::toPixel | ( | Vector< Double > & | pixel, |
const Vector< Double > & | world | ||
) | const [virtual] |
Implements casa::Coordinate.
virtual Bool casa::LinearCoordinate::toWorld | ( | Vector< Double > & | world, |
const Vector< Double > & | pixel | ||
) | const [virtual] |
Convert a pixel position to a worl position or vice versa.
Returns True if the conversion succeeds, otherwise it returns False and method errorMessage returns an error message. The output vectors are appropriately resized.
Implements casa::Coordinate.
virtual Coordinate::Type casa::LinearCoordinate::type | ( | ) | const [virtual] |
Returns Coordinate::LINEAR.
Implements casa::Coordinate.
virtual Vector<String> casa::LinearCoordinate::worldAxisNames | ( | ) | const [virtual] |
Return the requested attribute.
Implements casa::Coordinate.
virtual Vector<String> casa::LinearCoordinate::worldAxisUnits | ( | ) | const [virtual] |
Implements casa::Coordinate.
mutable ::wcsprm casa::LinearCoordinate::wcs_p [private] |
An interface to the WCSLIB linear transformation routines.
Definition at line 254 of file LinearCoordinate.h.