casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::WCBox Class Reference

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

#include <WCBox.h>

Inheritance diagram for casacore::WCBox:
casacore::WCRegion

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 &region, 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...
 
WCBoxoperator= (const WCBox &other)
 Assignment (copy semantics) More...
 
virtual Bool operator== (const WCRegion &other) const
 Comparison. More...
 
virtual WCRegioncloneRegion () 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 LCRegiondoToLCRegion (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 RecordgetAxesDesc () const
 Get the description of all axes. More...
 
const RecordgetAxisDesc (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 Stringcomment () const
 Get or set the comment. More...
 
void setComment (const String &comment)
 
virtual LCRegiontoLCRegion (const CoordinateSystem &cSys, const IPosition &shape) const
 Convert to an LCRegion using the given new coordinate system and shape. More...
 
LCRegiontoLCRegionAxes (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 WCBoxfromRecord (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 WCRegionfromRecord (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< IntitsAbsRel
 
Bool itsNull
 

Additional Inherited Members

- Protected Member Functions inherited from casacore::WCRegion
WCRegionoperator= (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)
 

Detailed Description

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

Intended use:

Public interface

Prerequisite

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);

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

Definition at line 292 of file WCBox.h.

Constructor & Destructor Documentation

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 casacore::WCBox::~WCBox ( )
virtual

Destructor.

Member Function Documentation

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

WCBox can extend a region.

Reimplemented from casacore::WCRegion.

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

Check units of quanta are consistent with CoordinateSystem.

static String casacore::WCBox::className ( )
static

Returns WCBox.

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

Clone a WCBox object.

Implements casacore::WCRegion.

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.

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.

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

Convert to a WCBox from a record.

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

Assignment (copy semantics)

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

Comparison.

Reimplemented from casacore::WCRegion.

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

Make a new box from the given axesin this box.

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.

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

Return region type.

Returns the class name

Implements casacore::WCRegion.

Member Data Documentation

Vector<Int> casacore::WCBox::itsAbsRel
private

Definition at line 372 of file WCBox.h.

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

Definition at line 368 of file WCBox.h.

CoordinateSystem casacore::WCBox::itsCSys
private

Definition at line 371 of file WCBox.h.

Bool casacore::WCBox::itsNull
private

Definition at line 373 of file WCBox.h.

IPosition casacore::WCBox::itsPixelAxes
private

Definition at line 370 of file WCBox.h.

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

Definition at line 369 of file WCBox.h.


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