casacore
|
Class to define a world coordinate box region of interest in an image. More...
#include <WCBox.h>
Public Member Functions | |
WCBox () | |
WCBox (const Vector< Quantum< Double > > &blc, const Vector< Quantum< Double > > &trc, const CoordinateSystem &cSys, const Vector< Int > &absRel) | |
Construct from vectors of world coordinates defining the box corners. More... | |
WCBox (const Vector< Quantum< Double > > &blc, const Vector< Quantum< Double > > &trc, const IPosition &pixelAxes, const CoordinateSystem &cSys, const Vector< Int > &absRel) | |
Construct from vectors of world coordinates defining the box corners. More... | |
WCBox (const LCRegion ®ion, const CoordinateSystem &cSys) | |
Construct from the bounding box of an LCRegion . More... | |
WCBox (const WCBox &other) | |
Copy constructor (reference semantics [except for CoordinateSystem ]) More... | |
virtual | ~WCBox () |
Destructor. More... | |
WCBox & | operator= (const WCBox &other) |
Assignment (copy semantics) More... | |
virtual Bool | operator== (const WCRegion &other) const |
Comparison. More... | |
virtual WCRegion * | cloneRegion () const |
Clone a WCBox object. More... | |
virtual Bool | canExtend () const |
WCBox can extend a region. More... | |
WCBox | splitBox (const IPosition &axes) const |
Make a new box from the given axesin this box. More... | |
virtual LCRegion * | doToLCRegion (const CoordinateSystem &cSys, const IPosition &latticeShape, const IPosition &pixelAxesMap, const IPosition &outOrder) const |
Convert to an LCRegion using the supplied CoordinateSystem and shape. More... | |
virtual TableRecord | toRecord (const String &tableName) const |
Convert the WCBox object to a record. More... | |
virtual String | type () const |
Return region type. More... | |
Public Member Functions inherited from casacore::WCRegion | |
WCRegion () | |
WCRegion (const WCRegion &other) | |
Copy constructor (copy semantics). More... | |
virtual | ~WCRegion () |
Destructor. More... | |
Bool | operator!= (const WCRegion &other) const |
virtual uInt | ndim () const |
Get the dimensionality (i.e. More... | |
const Record & | getAxesDesc () const |
Get the description of all axes. More... | |
const Record & | getAxisDesc (uInt axis) const |
Get the description of the given axis. More... | |
Int | axisNr (const Record &desc, const Record &axesDesc) const |
Return the axis number of the description of an axis in the full axes description. More... | |
Bool | isAxisDescEqual (const Record &desc1, const Record &desc2) const |
Are both axis descriptions equal? More... | |
const String & | comment () const |
Get or set the comment. More... | |
void | setComment (const String &comment) |
virtual LCRegion * | toLCRegion (const CoordinateSystem &cSys, const IPosition &shape) const |
Convert to an LCRegion using the given new coordinate system and shape. More... | |
LCRegion * | toLCRegionAxes (const CoordinateSystem &cSys, const IPosition &shape, const IPosition &pixelAxesMap, const IPosition &outOrder) const |
Convert to an LCRegion using the given coordinate system and shape. More... | |
void | defineRecordFields (RecordInterface &record, const String &className) const |
Define the type and class name in the record. More... | |
Static Public Member Functions | |
static WCBox * | fromRecord (const TableRecord &rec, const String &tableName) |
Convert to a WCBox from a record. More... | |
static String | className () |
Returns WCBox. More... | |
Static Public Member Functions inherited from casacore::WCRegion | |
static WCRegion * | fromRecord (const TableRecord &rec, const String &tableName) |
Convert correct object from a record. More... | |
Private Member Functions | |
void | checkUnits (const IPosition &pixelAxes, const Vector< Quantum< Double > > &values, const CoordinateSystem &cSys) |
Check units of quanta are consistent with CoordinateSystem. More... | |
void | convertPixel (Double &pixel, const Quantum< Double > &value, const Int absRel, const Double refPix, const Int shape, const Bool isBlc) const |
Convert relative pixels to absolute or fill in defaults. More... | |
Private Attributes | |
Vector< Quantum< Double > > | itsBlc |
Vector< Quantum< Double > > | itsTrc |
IPosition | itsPixelAxes |
CoordinateSystem | itsCSys |
Vector< Int > | itsAbsRel |
Bool | itsNull |
Additional Inherited Members | |
Protected Member Functions inherited from casacore::WCRegion | |
WCRegion & | operator= (const WCRegion &other) |
Assignment (copy semantics) makes only sense for a derived class. More... | |
void | addAxisDesc (const Record &axisDesc) |
Add an axis with its description. More... | |
Record | makeAxisDesc (const CoordinateSystem &cSys, uInt pixelAxis) const |
Make a description of a pixel axis in the coordinate system. More... | |
Record | makeAxesDesc (const CoordinateSystem &cSys) const |
Make a description of all pixel axes in the coordinate system (in pixel axes order). More... | |
void | makeWorldAbsolute (Vector< Double > &world, const Vector< Int > &absRel, const CoordinateSystem &cSys, const IPosition &shape) const |
Convert relative to absolute world as needed. More... | |
void | checkAxes (const IPosition &pixelAxes, const CoordinateSystem &cSys, const Vector< String > &quantityUnits) const |
Static Protected Member Functions inherited from casacore::WCRegion | |
static void | unitInit () |
static void | convertPixel (Double &pixel, const Double &value, const String &unit, const Int absRel, const Double refPix, const Int shape) |
Class to define a world coordinate box region of interest in an image.
Public interface
The corners of the box are specified in world coordinates, but the region enclosed by those corners is a box in lattice coordinates. Thus, the volume enclosed does not follow world coordinate contours.
All this class does, apart from constructing itself, is know how to save itself to a Record
and how to convert itself to an LCRegion
. The conversion allows you to apply a WCBox
constructed with one CoordinateSystem
to another CoordinateSystem
. That is, you can apply a WCBox
from this image to that image.
The flexibility of the CoordinateSystem
class should be kept in mind when using this class. Recall that a CoordinateSystem
has world and pixel axes, and that these axes can be independently removed and independently (re)ordered.
During construction, the length of the world coordinate vectors may be smaller than the number world axes in the supplied CoordinateSystem
. It is assumed that the units of the world coordinates are the same as those encapsulated in the construction CoordinateSystem
and in the same order as specified (either intrinsically, or by the world axes specification vectors).
The following rules are followed during conversion to an LCRegion
.
latticeShape
must be equal to the number of pixel axes in the supplied CoordinateSystem
. CoordinateSystem
is assumed to be the order of the axes in the lattice for which the supplied latticeShape
is appropriate. CoordinateSystem
supplied to the toLCRegion
function does not have to be identical in structure to that from which the WCBox
was constructed. They can consist of different numbers of world and pixel axes and be in different orders. CoordinateSystem
that is also present (somewhere) in the construction CoordinateSystem
the blc/trc corresponding to that world axis will be converted to pixels appropriate to the supplied CoordinateSystem
. The order of this pixel based blc/trc will be the order of the pixel axes of the supplied CoordinateSystem
CoordinateSystem
that is not present in the construction CoordinateSystem
, the supplied latticeShape
value for the corresponding pixel axis is used, setting blc=0
and trc=latticeShape-1
for that axis. latticeShape
, it is used to create the LCBox
, which is supplied as a pointer to the base class LCRegion
. Note that when determining whether a world axis from one CoordinateSystem
is present on another, it is considered to not be a match if two coordinates of the same type (e.g. DirectionCoordinate
) have different specific types (e.g. J2000 and GALACTIC, or TOPO and LSR for a SpectralCoordinate
)
Let us give some examples with pseudo-code. cSys is the construction CoordinateSystem and cSys2 is the supplied CoordinateSystem. We list their world axes in the square brackets. The construction blc/trc values don't matter as long as there cSys.nWorldAxes() of them. Similarly, the values of shape don't matter as long as there are cSys2.nPixelAxes() of them.
The resultant LCBox will have corners converted according to
The resultant LCBox will have corners converted according to
The resultant LCBox will have corners converted according to
The resultant LCBox will have corners converted according to
In this example we make it a bit harder by reordering the pixel axes too. The new order of the pixel axes in terms of the original order [0,1,2] is given after the world axes
Take the first world axis of cSys2 as an example. First, "freq" is found as the world axis number 2 in cSys. Then, when it is converted to a pixel coordinate, it will turn up as the value on pixel axis 1. The supplied shape must be appropriate to a [stokes, freq, dec, ra] lattice. The resultant LCBox will therefore have corners converted according to
Users must be able to specify regions in world as well as lattice coordinates.
Note: In all of the constructors, the order of the specified world coordinates is that of the PIXEL AXES (not world axes) in the CoordinateSystem
; This is the natural order for a user to want to specify them in;
Note: For the constructors specifying the world values as simple doubles, it is ASSUMED that the units of those doubles are the same as the native units of the CoordinateSystem
for each axis;
Note: World coordinates may be specified as absolute or offset; If the latter, they are offset with respect to the reference pixel of the CoordinateSystem
;
casacore::WCBox::WCBox | ( | ) |
casacore::WCBox::WCBox | ( | const Vector< Quantum< Double > > & | blc, |
const Vector< Quantum< Double > > & | trc, | ||
const CoordinateSystem & | cSys, | ||
const Vector< Int > & | absRel | ||
) |
Construct from vectors of world coordinates defining the box corners.
It is assumed that the order of the values is in the order of the pixel axes in the given coordinate system.
casacore::WCBox::WCBox | ( | const Vector< Quantum< Double > > & | blc, |
const Vector< Quantum< Double > > & | trc, | ||
const IPosition & | pixelAxes, | ||
const CoordinateSystem & | cSys, | ||
const Vector< Int > & | absRel | ||
) |
Construct from vectors of world coordinates defining the box corners.
You specify the pixel axis order of the world values.
casacore::WCBox::WCBox | ( | const LCRegion & | region, |
const CoordinateSystem & | cSys | ||
) |
Construct from the bounding box of an LCRegion
.
casacore::WCBox::WCBox | ( | const WCBox & | other | ) |
Copy constructor (reference semantics [except for CoordinateSystem
])
|
virtual |
Destructor.
|
virtual |
WCBox can extend a region.
Reimplemented from casacore::WCRegion.
|
private |
Check units of quanta are consistent with CoordinateSystem.
|
virtual |
Clone a WCBox object.
Implements casacore::WCRegion.
|
private |
Convert relative pixels to absolute or fill in defaults.
|
virtual |
Convert to an LCRegion using the supplied CoordinateSystem
and shape.
Implements casacore::WCRegion.
|
static |
Convert to a WCBox from a record.
Comparison.
Reimplemented from casacore::WCRegion.
Make a new box from the given axesin this box.
|
virtual |
Convert the WCBox object to a record.
The record can be used to make the object persistent. The tableName
argument can be used by derived classes (e.g. LCPagedMask) to put very large objects.
Implements casacore::WCRegion.
|
virtual |
|
private |