LinearCoordinate.h
Classes
- LinearCoordinate -- Interconvert between pixel and a linear world coordinate. (full description)
Interface
- Public Members
- LinearCoordinate(uInt naxes = 1)
- 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)
- LinearCoordinate(const Vector<String> &names, const Vector<Quantum<Double> >& refVal, const Vector<Quantum<Double> >& inc, const Matrix<Double> &pc, const Vector<Double> &refPix)
- LinearCoordinate(const LinearCoordinate &other)
- LinearCoordinate &operator=(const LinearCoordinate &other)
- virtual ~LinearCoordinate()
- virtual Coordinate::Type type() const
- virtual String showType() const
- virtual uInt nPixelAxes() const
- virtual uInt nWorldAxes() const
- virtual Bool toWorld(Vector<Double> &world, const Vector<Double> &pixel) const
- virtual Bool toPixel(Vector<Double> &pixel, const Vector<Double> &world) const
- virtual Vector<String> worldAxisNames() const
- 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)
- 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)
- Bool overwriteWorldAxisUnits(const Vector<String> &units)
- virtual Bool setWorldMixRanges (const IPosition& shape)
- virtual void setDefaultWorldMixRanges ()
- virtual Vector<Double> worldMixMin () const
- virtual Vector<Double> worldMixMax () const
- virtual Bool near(const Coordinate& other, Double tol=1e-6) const
- 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
- virtual Bool save(RecordInterface &container, const String &fieldName) const
- static LinearCoordinate *restore(const RecordInterface &container, const String &fieldName)
- virtual Coordinate *clone() const
Review Status
- Reviewed By:
- Peter Barnes
- Date Reviewed:
- 1999/12/24
- Programs:
- Tests:
Prerequisite
- Coordinate defines the fundamental
interface to coordinate conversions.
Synopsis
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).
All pixels coordinates are zero relative.
Example
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.
Motivation
This class is intended for use with axes which do not have specific coordinate
types. A "time" axis would be a good example.
Thrown Exceptions
To Do
- Allow differing numbers of world and pixel axes. Requires a change in
WCS or use of a different library.
Member Description
The default constructor makes a LinearCoordinate for which pixel
and world coordinates are equal. naxes gives the number
of axes in the Coordinate.
Construct the LinearCoordinate
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.
Copy constructor (copy semantics).
LinearCoordinate &operator=(const LinearCoordinate &other)
Assignment (copy semantics).
Destructor.
Returns Coordinate::LINEAR.
Returns the String "Linear".
virtual uInt nPixelAxes() const
virtual uInt nWorldAxes() const
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.
virtual Bool toWorld(Vector<Double> &world, const Vector<Double> &pixel) const
virtual Bool toPixel(Vector<Double> &pixel, const Vector<Double> &world) const
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.
Return the requested attribute
Set the value of the requested attributed. Note that these just
change the internal values, they do not cause any recomputation.
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.
Overwrite the world axis units with no compatibility
checks or adjustment.
Set the world min and max ranges, for use in function toMix,
for a lattice of the given shape (for this coordinate).
The implementation here gives world coordinates dangling 25% off the
edges of the image.
The output vectors are resized. Returns False if fails (and
then setDefaultWorldMixRanges generates the ranges)
with a reason in errorMessage().
The setDefaultWorldMixRanges function
gives you [-1e99->1e99].
virtual Bool near(const Coordinate& other, Double tol=1e-6) const
virtual Bool near(const Coordinate& other, const Vector<Int>& excludeAxes, Double tol=1e-6) const
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.
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.
virtual Bool save(RecordInterface &container, const String &fieldName) const
Save the LinearCoordinate into the supplied record using the supplied field name.
The field must not already exist, otherwise False is returned.
static LinearCoordinate *restore(const RecordInterface &container, const String &fieldName)
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.
Make a copy of the LinearCoordinate using new. The caller is responsible for calling
delete.