Loading...
Searching...
No Matches
casacore::WCBox Class Reference
images package (libcasa_images) » Regions_module

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.
| 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.
| WCBox (const LCRegion &region, const CoordinateSystem &cSys)
| Construct from the bounding box of an LCRegion.
| WCBox (const WCBox &other)
| Copy constructor (reference semantics [except for CoordinateSystem]).
virtual | ~WCBox ()
| Destructor.
WCBox & | operator= (const WCBox &other)
| Assignment (copy semantics).
virtual Bool | operator== (const WCRegion &other) const
| Comparison.
virtual WCRegion * | cloneRegion () const
| Clone a WCBox object.
virtual Bool | canExtend () const
| WCBox can extend a region.
WCBox | splitBox (const IPosition &axes) const
| Make a new box from the given axesin this box.
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.
virtual TableRecord | toRecord (const String &tableName) const
| Convert the WCBox object to a record.
virtual String | type () const
| Return region type.
Public Member Functions inherited from casacore::WCRegion
| WCRegion ()
| WCRegion (const WCRegion &other)
| Copy constructor (copy semantics).
virtual | ~WCRegion ()
| Destructor.
Bool | operator!= (const WCRegion &other) const
virtual uInt | ndim () const
| Get the dimensionality (i.e.
const Record & | getAxesDesc () const
| Get the description of all axes.
const Record & | getAxisDesc (uInt axis) const
| Get the description of the given axis.
Int | axisNr (const Record &desc, const Record &axesDesc) const
| Return the axis number of the description of an axis in the full axes description.
Bool | isAxisDescEqual (const Record &desc1, const Record &desc2) const
| Are both axis descriptions equal?
const String & | comment () const
| Get or set the comment.
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.
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.
void | defineRecordFields (RecordInterface &record, const String &className) const
| Define the type and class name in the record.

## Static Public Member Functions

static WCBox * | fromRecord (const TableRecord &rec, const String &tableName)
| Convert to a WCBox from a record.
static String | className ()
| Returns WCBox.
Static Public Member Functions inherited from casacore::WCRegion
static WCRegion * | fromRecord (const TableRecord &rec, const String &tableName)
| Convert correct object from a record.

## Private Member Functions

void | checkUnits (const IPosition &pixelAxes, const Vector< Quantum< Double > > &values, const CoordinateSystem &cSys)
| Check units of quanta are consistent with CoordinateSystem.
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.

## 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.
void | addAxisDesc (const Record &axisDesc)
| Add an axis with its description.
Record | makeAxisDesc (const CoordinateSystem &cSys, uInt pixelAxis) const
| Make a description of a pixel axis in the coordinate system.
Record | makeAxesDesc (const CoordinateSystem &cSys) const
| Make a description of all pixel axes in the coordinate system (in pixel axes order).
void | makeWorldAbsolute (Vector< Double > &world, const Vector< Int > &absRel, const CoordinateSystem &cSys, const IPosition &shape) const
| Convert relative to absolute world as needed.
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)

## Detailed Description

Class to define a world coordinate box region of interest in an image.

### Intended use:

Public interface

### Prerequisite

- WCRegion
- LCRegion
- CoordinateSystem

### Synopsis

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.

1. The number of elements in the supplied latticeShape must be equal to the number of pixel axes in the supplied CoordinateSystem.
2. The order of the pixel axes in the supplied CoordinateSystem is assumed to be the order of the axes in the lattice for which the supplied latticeShape is appropriate.
3. The 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.
4. For every world axis in the supplied 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
5. For every world axis in the supplied 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.
6. Once the pixel based blc/trc has been created, then, with the supplied 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 CoordinateSystemis 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)

### Example

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.

cSys = [ra, dec, freq];
cSys2 = [ra, dec];
blc = [,,];
trc = [,,];
shape = [,];
WCBox box(blc, trc, cSys);
LCRegion* pR = box.toLCRegion(cSys2, shape);
casacore::LCRegion
Definition LCRegion.h:86
casacore::WCBox::WCBox
WCBox()
casacore::shape
IPosition shape(const RecordFieldId &) const
Get the actual shape of this field.

The resultant LCBox will have corners converted according to

blcLC(0) <- blc(0);
blcLC(1) <- blc(1);
trcLC(0) <- trc(0);
trcLC(1) <- trc(1);

### Example

cSys = [ra, dec, freq];
cSys2 = [freq, stokes];
blc = [,,];
trc = [,,];
shape = [,];
WCBox box(blc, trc, cSys);
LCRegion* pR = box.toLCRegion(cSys2, shape);

The resultant LCBox will have corners converted according to

blcLC(0) <- blc(2);
blcLC(1) = 0;
trcLC(0) <- trc(2);
trcLC(1) = shape(1) - 1;

### Example

cSys = [ra, dec];
cSys2 = [ra, dec, freq];
blc = [,];
trc = [,];
shape = [,,];
WCBox box(blc, trc, cSys);
LCRegion* pR = box.toLCRegion(cSys2, shape);

The resultant LCBox will have corners converted according to

blcLC(0) <- blc(0);
blcLC(1) <- blc(1);
blcLC(2) = 0l
trcLC(0) <- trc(0);
trcLC(1) <- trc(1);
trcLC(2) = shape(2)-1;

### Example

cSys = [ra, dec, freq];
cSys2 = [freq, ra, dec];
blc = [,,];
trc = [,,];
shape = [,,];
WCBox box(blc, trc, cSys);
LCRegion* pR = box.toLCRegion(cSys2, shape);

The resultant LCBox will have corners converted according to

blcLC(0) <- blc(2);
blcLC(1) <- blc(0);
blcLC(2) <- blc(1);
trcLC(0) <- trc(2);
trcLC(1) <- trc(0);
trcLC(2) <- trc(1);

### Example

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

cSys = [ra, dec, freq], [0, 1, 2];
cSys2 = [freq, ra, dec, stokes], [3, 0, 2, 1];
blc = [,,];
trc = [,,];
shape = [,,,];
WCBox box(blc, trc, cSys);
LCRegion* pR = box.toLCRegion(cSys2, shape);

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

blcLC(0) = 0
blcLC(1) <- blc(2);
blcLC(2) <- blc(1);
blcLC(3) <- blc(0);
trcLC(0) = shape(0)-1;
trcLC(1) <- trc(2);
trcLC(2) <- trc(1);
trcLC(3) <- trc(0);

### Motivation

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;

### To Do

- Implement offset coordinates

Definition at line 291 of file WCBox.h.

## Constructor & Destructor Documentation

## WCBox() [1/5]

casacore::WCBox::WCBox | ( |  | ) |

Referenced by fromRecord(), operator=(), splitBox(), and WCBox().

## WCBox() [2/5]

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.

## WCBox() [3/5]

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.

## WCBox() [4/5]

casacore::WCBox::WCBox | ( | const LCRegion & | region,
|  | const CoordinateSystem & | cSys )

Construct from the bounding box of an LCRegion.

## WCBox() [5/5]

casacore::WCBox::WCBox | ( | const WCBox & | other | ) |

Copy constructor (reference semantics [except for CoordinateSystem]).

References WCBox().

## ~WCBox()

virtual casacore::WCBox::~WCBox | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## canExtend()

virtual Bool casacore::WCBox::canExtend | ( |  | ) | const

virtual

WCBox can extend a region.

Reimplemented from casacore::WCRegion.

## checkUnits()

void casacore::WCBox::checkUnits | ( | const IPosition & | pixelAxes,
|  | const Vector< Quantum< Double > > & | values,
|  | const CoordinateSystem & | cSys )

private

Check units of quanta are consistent with CoordinateSystem.

## className()

String casacore::WCBox::className | ( |  | ) |

static

Returns WCBox.

## cloneRegion()

virtual WCRegion * casacore::WCBox::cloneRegion | ( |  | ) | const

virtual

Clone a WCBox object.

Implements casacore::WCRegion.

References casacore::WCRegion::WCRegion().

## convertPixel()

void casacore::WCBox::convertPixel | ( | Double & | pixel,
|  | const Quantum< Double > & | value,
|  | const Int | absRel,
|  | const Double | refPix,
|  | const Int | shape,
|  | const Bool | isBlc ) const

private

Convert relative pixels to absolute or fill in defaults.

References casacore::NewDelAllocator< T >::value, and casacore::shape().

## doToLCRegion()

virtual LCRegion * casacore::WCBox::doToLCRegion | ( | const CoordinateSystem & | cSys,
|  | const IPosition & | latticeShape,
|  | const IPosition & | pixelAxesMap,
|  | const IPosition & | outOrder ) const

virtual

Convert to an LCRegion using the supplied CoordinateSystem and shape.

Implements casacore::WCRegion.

## fromRecord()

WCBox * casacore::WCBox::fromRecord | ( | const TableRecord & | rec,
|  | const String & | tableName )

static

Convert to a WCBox from a record.

References WCBox().

## operator=()

WCBox & casacore::WCBox::operator= | ( | const WCBox & | other | ) |

Assignment (copy semantics).

References WCBox().

## operator==()

virtual Bool casacore::WCBox::operator== | ( | const WCRegion & | other | ) | const

virtual

Comparison.

Reimplemented from casacore::WCRegion.

References casacore::WCRegion::WCRegion().

## splitBox()

WCBox casacore::WCBox::splitBox | ( | const IPosition & | axes | ) | const

Make a new box from the given axesin this box.

References WCBox().

## toRecord()

virtual TableRecord casacore::WCBox::toRecord | ( | const String & | tableName | ) | const

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.

## type()

virtual String casacore::WCBox::type | ( |  | ) | const

virtual

Return region type.

Returns the class name

Implements casacore::WCRegion.

## Member Data Documentation

## itsAbsRel

Vector<Int> casacore::WCBox::itsAbsRel

private

Definition at line 371 of file WCBox.h.

## itsBlc

Vector<Quantum<Double> > casacore::WCBox::itsBlc

private

Definition at line 367 of file WCBox.h.

## itsCSys

CoordinateSystem casacore::WCBox::itsCSys

private

Definition at line 370 of file WCBox.h.

## itsNull

Bool casacore::WCBox::itsNull

private

Definition at line 372 of file WCBox.h.

## itsPixelAxes

IPosition casacore::WCBox::itsPixelAxes

private

Definition at line 369 of file WCBox.h.

## itsTrc

Vector<Quantum<Double> > casacore::WCBox::itsTrc

private

Definition at line 368 of file WCBox.h.

The documentation for this class was generated from the following file:

- images/Regions/WCBox.h