casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
casa::DirectionCoordinate Class Reference

Interconvert pixel positions and directions (e.g. RA/DEC). More...

#include <DirectionCoordinate.h>

Inheritance diagram for casa::DirectionCoordinate:
casa::Coordinate

List of all members.

Public Member Functions

 DirectionCoordinate ()
 The default constructor creates a J2000 DirectionCoordinate with a CARtesion projection with longitude,latitude 0,0 at pixel 0,0 and an increment of +1 radian per pixel on both axes.
 DirectionCoordinate (MDirection::Types directionType, const Projection &projection, Double refLong, Double refLat, Double incLong, Double incLat, const Matrix< Double > &xform, Double refX, Double refY, Double longPole=999.0, Double latPole=999.0)
 Define the DirectionCoordinate transformation.
 DirectionCoordinate (MDirection::Types directionType, const Projection &projection, const Quantum< Double > &refLong, const Quantum< Double > &refLat, const Quantum< Double > &incLong, const Quantum< Double > &incLat, const Matrix< Double > &xform, Double refX, Double refY, const Quantum< Double > &longPole=Quantum< Double >(999.0, Unit("rad")), const Quantum< Double > &latPole=Quantum< Double >(999.0, Unit("rad")))
 Create DirectionCoordinate with Quantum-based interface.
 DirectionCoordinate (MDirection::Types directionType, const ::wcsprm &wcs, Bool oneRel=True)
 Constructor from WCS structure; must hold ONLY a celestial wcs structure Specify whether the absolute pixel coordinates in the wcs structure are 0- or 1-relative.
 DirectionCoordinate (const DirectionCoordinate &other)
 Copy constructor (copy semantics)
DirectionCoordinateoperator= (const DirectionCoordinate &other)
 Assignment (copy semantics).
virtual ~DirectionCoordinate ()
 Destructor.
virtual Coordinate::Type type () const
 Return Coordinate::DIRECTION.
virtual String showType () const
 Always returns the String "Direction".
virtual uInt nPixelAxes () const
 Always returns 2.
virtual uInt nWorldAxes () const
void setReferenceConversion (MDirection::Types type)
 Set extra conversion type.
void getReferenceConversion (MDirection::Types &type) const
virtual Bool toWorld (Vector< Double > &world, const Vector< Double > &pixel) const
 Convert a pixel position to a world position or vice versa.
virtual Bool toPixel (Vector< Double > &pixel, const Vector< Double > &world) const
virtual Bool toMix (Vector< Double > &worldOut, Vector< Double > &pixelOut, const Vector< Double > &worldIn, const Vector< Double > &pixelIn, const Vector< Bool > &worldAxes, const Vector< Bool > &pixelAxes, const Vector< Double > &worldMin, const Vector< Double > &worldMax) const
 Mixed pixel/world coordinate conversion.
virtual Bool setWorldMixRanges (const IPosition &shape)
 Compute and retrieve the world min and max ranges, for use in function toMix, for a lattice of the given shape (for this coordinate).
virtual void setDefaultWorldMixRanges ()
void setWorldMixRanges (const Vector< Bool > &which, const Vector< Double > &world)
 Non-virtual function.
Bool toWorld (MDirection &world, const Vector< Double > &pixel) const
 A convenient way to turn the world vector into an MDirection or MVDirection for further processing in the Measures system.
Bool toPixel (Vector< Double > &pixel, const MDirection &world) const
Bool toWorld (MVDirection &world, const Vector< Double > &pixel) const
Bool toPixel (Vector< Double > &pixel, const MVDirection &world) const
virtual Bool toWorldMany (Matrix< Double > &world, const Matrix< Double > &pixel, Vector< Bool > &failures) const
 Batch up a lot of transformations.
virtual Bool toPixelMany (Matrix< Double > &pixel, const Matrix< Double > &world, Vector< Bool > &failures) const
virtual void makeWorldRelative (Vector< Double > &world) const
 Make absolute world coordinates relative and vice-versa (relative to the reference value).
virtual void makeWorldRelative (MDirection &world) const
virtual void makeWorldAbsolute (Vector< Double > &world) const
virtual void makeWorldAbsolute (MDirection &world) const
virtual void makeWorldAbsoluteRef (Vector< Double > &world, const Vector< Double > &refVal) const
 Make absolute coordinates relative and vice versa with respect to the given reference value.
MDirection::Types directionType (Bool showConversion=False) const
 Recover the requested attribute.
Projection projection () const
virtual Vector< StringworldAxisNames () const
 Return the requested attributed.
virtual Vector< StringworldAxisUnits () const
virtual Vector< DoublereferenceValue () const
virtual Vector< Doubleincrement () const
virtual Matrix< DoublelinearTransform () const
virtual Vector< DoublereferencePixel () const
virtual Bool setWorldAxisNames (const Vector< String > &names)
 Set the value of the requested attribute.
virtual Bool setReferencePixel (const Vector< Double > &refPix)
virtual Bool setLinearTransform (const Matrix< Double > &xform)
virtual Bool setIncrement (const Vector< Double > &inc)
virtual Bool setReferenceValue (const Vector< Double > &refval)
virtual Bool setWorldAxisUnits (const Vector< String > &units)
 Change the world axis units.
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 void getPrecision (Int &precision, Coordinate::formatType &format, Bool showAsAbsolute, Int defPrecScientific, Int defPrecFixed, Int defPrecTime) const
 Format a DirectionCoordinate coordinate world value nicely through the common format interface.
virtual String format (String &units, Coordinate::formatType format, Double worldValue, uInt axis, Bool isAbsolute, Bool showAsAbsolute, Int precision=-1, Bool usePrecForMixed=False) const
Bool cylindricalFix (Int shapeLong, Int shapeLat)
 Fix cylindrical coordinates to put the longitude in [-180,180] range.
virtual CoordinatemakeFourierCoordinate (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 DirectionCoordinate into the supplied record using the supplied field name.
virtual Coordinateclone () const
 Make a copy of the DirectionCoordinate using new.
Vector< DoublelongLatPoles () const
 Fish out the ref and non-native poles (refLong, refLat, longPole, latPole) Not for general use.
Quantity getPixelArea () const
 get the pixel area.
DirectionCoordinate convert (Quantity &angle, MDirection::Types directionType) const
 Convert this coordinate to another reference frame by rotating it about the reference pixel so the the axes of the new reference frame are aligned along the cardinal directions (left-right, up-down).

Static Public Member Functions

static Vector< StringaxisNames (MDirection::Types type, Bool FITSName=False)
 Return canonical axis names for the given MDirection type, giving FITS names if desired.
static DirectionCoordinaterestore (const RecordInterface &container, const String &fieldName)
 Recover the DirectionCoordinate from a record.

Private Member Functions

void toCurrent (Vector< Double > &degrees) const
 Interconvert between the current units and wcs units (degrees)
void fromCurrent (Vector< Double > &current) const
void checkFormat (Coordinate::formatType &format, Bool absolute) const
 Check formatting types.
String formatLatitude (String &units, MVAngle &mVA, Bool absolute, Coordinate::formatType form, Int prec) const
 Format a latitude.
String formatLongitude (String &units, MVAngle &mVA, MDirection::GlobalTypes gtype, Bool absolute, Coordinate::formatType form, Int prec) const
 Format a longitude.
Bool toMix2 (Vector< Double > &out, const Vector< Double > &in, const Vector< Double > &minWorld, const Vector< Double > &maxWorld, Bool longIsWorld) const
 Mixed pixel/world coordinate conversion.
void initializeFactors ()
 Initialize unit conversion vectors and units.
void makeDirectionCoordinate (MDirection::Types directionType, const Projection &proj, Double refLong, Double refLat, Double incLong, Double incLat, const Matrix< Double > &xform, Double refX, Double refY, Double longPole, Double latPole)
 Helper functions interfacing to WCS.
void makeWCS (::wcsprm &wcs, const Matrix< Double > &xform, const Projection &proj, MDirection::Types directionType, Double refPixLong, Double refPixLat, Double refLong, Double refLat, Double incLong, Double incLat, Double longPole, Double latPole)
void normalizePCMatrix ()
 Normalize each row of the PC matrix such that increment() will return the actual angular increment and any scale factors are removed from the PC matrix (modifies wcs_p.pc and wcs_p.cdelt and wcs_p.altlin, executes set_wcs() and hence wcsset() on the struct) See Greisen & Calabretta, A&A 395, 1061-1075 (2002), equation (4)
Double putLongInPiRange (Double lon, const String &unit) const
void makeConversionMachines ()
 Set up conversion machine.
virtual void convertTo (Vector< Double > &world) const
 Convert from type_p -> conversionType_p.
virtual void convertFrom (Vector< Double > &world) const
void copy (const DirectionCoordinate &other)
 Copy private data.
void setRotationMatrix ()
 Set up the offset coordinate rotation matrix.
void setRotationMatrix (RotMatrix &rot, Double lon, Double lat) const
const Vector< DoubletoCurrentFactors () const
 Return unit conversion vector for converting to current units.

Private Attributes

MDirection::Types type_p
 Direction type.
MDirection::Types conversionType_p
Projection projection_p
 Projection parameters.
mutable::wcsprm wcs_p
 WCS structure.
Vector< Doubleto_degrees_p
 WCS computes in degrees - use this to convert back and forth between current DirectionCoordinate units and degrees or radians.
Vector< Doubleto_radians_p
Vector< Stringnames_p
 Axis names.
Vector< Stringunits_p
 Current units.
RotMatrix rot_p
 Rotation matrix used to handle relative coordinates.
MDirection::ConvertpConversionMachineTo_p
 Conversion machines.
MDirection::ConvertpConversionMachineFrom_p

Detailed Description

Interconvert pixel positions and directions (e.g. RA/DEC).

Intended use:

Public interface

Review Status

Reviewed By:
Peter Barnes
Date Reviewed:
1999/12/24
Test programs:
tDirectionCoordinate

Prerequisite

Synopsis

This class implements pixel to world coordinate conversions. This class implements geometric conversions (e.g. SIN projection) via the WCS library and also provides an interface to astronomical conversions (RA/DEC <--> l,b) via the Measures module.


Caution: All absolute pixels coordinates are zero relative;

Example

Let's make a DirectionCoordinate --- used to represent a direction, usually an RA/DEC, but it could also be, e.g., an AZ/EL pair.

       Matrix<Double> xform(2,2);                                    // 1
       xform = 0.0; xform.diagonal() = 1.0;                          // 2
       DirectionCoordinate radec(MDirection::J2000,                  // 3 
                               Projection(Projection::SIN),          // 4 
                               135*C::pi/180.0, 60*C::pi/180.0,      // 5
                               -1*C::pi/180.0, 1*C::pi/180,          // 6
                               xform,                                // 7
                               128, 128);                            // 8   

In this example is is more convenient to change the units to degrees. This can be accomplished as follows:

       Vector<String> units(2); units = "deg";                       //  9
       radec.setWorldAxisUnits(units);                               // 10

The increment and reference value are updated appropriately.

Set up a couple of vectors to use the world and pixel coordinate values.

       Vector<Double> world(2), pixel(2);                            // 11
       pixel = 138.0;                                                // 12

We use 138 as an arbitrary pixel position which is near the reference pixel so we can tell if the answers look foolish or not. We can actually perform a transformation like this as follows. If it succeeds we print the value of the world coordinate.

       Bool ok = radec.toWorld(world, pixel);                        // 13
       if (!ok) {                                                    // 14 
         cout << "Error: " << radec.errorMessage() << endl;          // 15
         return 1;                                                   // 16
       }                                                             // 17
       cout << world << " <--- " << pixel << endl;         // 18

There is an overloaded "toWorld" function that produces an MDirection in case you want to, e.g., find out what the position in B1950 coordinates would be.

The reverse transformation takes place similarly:

       ok = radec.toPixel(pixel, world);                             // 19   

Example

We could also have made the above DirectionCoordinate using the Quantum-based constructor, which is a little more elegant if you want to use degrees.

Matrix<Double> xform(2,2); xform = 0.0; xform.diagonal() = 1.0; Quantum<Double> refLon(135.0, "deg"); Quantum<Double> refLat(60.0, "deg"); Quantum<Double> incLon(-1.0, "deg"); Quantum<Double> incLat(1.0, "deg"); DirectionCoordinate radec(MDirection::J2000, Projection(Projection::SIN), refLon, refLat, incLon, incLat, xform, 128, 128);

But note that the constructor will have converted the native units of the DirectionCoordinate to radians. So the Double-based toWorld and toPixel functions will be in terms of radians. If you want the native units to be degrees, then again you can use

       Vector<String> units(2); units = "deg";         
       radec.setWorldAxisUnits(units);                 

and thereafter degrees are the native units.

Motivation

Directions in the sky are fundamental to astronomy.

Thrown Exceptions

To Do

Definition at line 217 of file DirectionCoordinate.h.


Constructor & Destructor Documentation

The default constructor creates a J2000 DirectionCoordinate with a CARtesion projection with longitude,latitude 0,0 at pixel 0,0 and an increment of +1 radian per pixel on both axes.

casa::DirectionCoordinate::DirectionCoordinate ( MDirection::Types  directionType,
const Projection projection,
Double  refLong,
Double  refLat,
Double  incLong,
Double  incLat,
const Matrix< Double > &  xform,
Double  refX,
Double  refY,
Double  longPole = 999.0,
Double  latPole = 999.0 
)

Define the DirectionCoordinate transformation.

refLong and refLat will normally the the RA/DEC of the pixel described by refX/refY. incLat/incLong are the increments per pixel (RA is usually negative), and the xform matrix is usually the unit diagonal matrix unless you have a rotation or some other linear transformation between the pixel and world axes.

Note that the units are radians initially. You can change it to degrees or something else with the setWorldAxisUnits method later if you want.

longPole and latPole are defined by Calabretta and Greisen (these are reference points not at the native pole). In general you can leave these out and the default values will cause them to be computed appropriately. However, when reading from FITS the LONPOLE and LATPOLE keywords are passed along here.

casa::DirectionCoordinate::DirectionCoordinate ( MDirection::Types  directionType,
const Projection projection,
const Quantum< Double > &  refLong,
const Quantum< Double > &  refLat,
const Quantum< Double > &  incLong,
const Quantum< Double > &  incLat,
const Matrix< Double > &  xform,
Double  refX,
Double  refY,
const Quantum< Double > &  longPole = QuantumDouble >(999.0, Unit("rad")),
const Quantum< Double > &  latPole = QuantumDouble >(999.0, Unit("rad")) 
)

Create DirectionCoordinate with Quantum-based interface.

Parameters are the same as above. Regardless of the units of the quanta, the initial units of the DirectionCoordinate will be converted radians. You can change it to degrees or something else with the setWorldAxisUnits method later if you want.

longPole and latPole are defined by Calabretta and Greisen (these are reference points not at the native pole). In general you can leave these out and the default values will cause them to be computed appropriately. However, when reading from FITS the LONPOLE and LATPOLE keywords are passed along here. To get the default the 999.0 value should be used (units are irrelevant in that case)

casa::DirectionCoordinate::DirectionCoordinate ( MDirection::Types  directionType,
const ::wcsprm &  wcs,
Bool  oneRel = True 
)

Constructor from WCS structure; must hold ONLY a celestial 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

Copy constructor (copy semantics)

Destructor.


Member Function Documentation

static Vector<String> casa::DirectionCoordinate::axisNames ( MDirection::Types  type,
Bool  FITSName = False 
) [static]

Return canonical axis names for the given MDirection type, giving FITS names if desired.

BEG think this should be in the MDirection class, but WNB disagrees. Leave it here for now.

void casa::DirectionCoordinate::checkFormat ( Coordinate::formatType format,
Bool  absolute 
) const [private]

Check formatting types.

Reimplemented from casa::Coordinate.

virtual Coordinate* casa::DirectionCoordinate::clone ( ) const [virtual]

Make a copy of the DirectionCoordinate using new.

The caller is responsible for calling delete.

Implements casa::Coordinate.

Convert this coordinate to another reference frame by rotating it about the reference pixel so the the axes of the new reference frame are aligned along the cardinal directions (left-right, up-down).

The reference pixel remains the same and the conversion is exact for the reference pixel and in general becomes less accurate as distance from reference pixel increases. The latitude like and the longitude like pixel increments are preserved. Conversions for which require extra information such as epoch and position are not supported. The angle parameter is the angle through which this coordinate had to be rotated clockwise to produce the new coordinate.

virtual void casa::DirectionCoordinate::convertFrom ( Vector< Double > &  world) const [private, virtual]

Reimplemented from casa::Coordinate.

virtual void casa::DirectionCoordinate::convertTo ( Vector< Double > &  world) const [private, virtual]

Convert from type_p -> conversionType_p.

Reimplemented from casa::Coordinate.

void casa::DirectionCoordinate::copy ( const DirectionCoordinate other) [private]

Copy private data.

Bool casa::DirectionCoordinate::cylindricalFix ( Int  shapeLong,
Int  shapeLat 
)

Fix cylindrical coordinates to put the longitude in [-180,180] range.

If False returned, it failed an an error is in errorMessage This fix is not done automatically internally because of the dependence on the image shape. It should be called for any foreign image (such as FITS) that is imported

Recover the requested attribute.

virtual String casa::DirectionCoordinate::format ( String units,
Coordinate::formatType  format,
Double  worldValue,
uInt  axis,
Bool  isAbsolute,
Bool  showAsAbsolute,
Int  precision = -1,
Bool  usePrecForMixed = False 
) const [virtual]

Reimplemented from casa::Coordinate.

String casa::DirectionCoordinate::formatLatitude ( String units,
MVAngle mVA,
Bool  absolute,
Coordinate::formatType  form,
Int  prec 
) const [private]

Format a latitude.

String casa::DirectionCoordinate::formatLongitude ( String units,
MVAngle mVA,
MDirection::GlobalTypes  gtype,
Bool  absolute,
Coordinate::formatType  form,
Int  prec 
) const [private]

Format a longitude.

void casa::DirectionCoordinate::fromCurrent ( Vector< Double > &  current) const [private]

get the pixel area.

virtual void casa::DirectionCoordinate::getPrecision ( Int precision,
Coordinate::formatType format,
Bool  showAsAbsolute,
Int  defPrecScientific,
Int  defPrecFixed,
Int  defPrecTime 
) const [virtual]

Format a DirectionCoordinate coordinate world value nicely through the common format interface.

See Coordinate for basics.

Formatting types that are allowed are SCIENTIFIC, FIXED, MIXED, and TIME If you ask for format type Coordinate::DEFAULT then the selected format depends upon what the value of the enum MDirection::GlobalTypes is for this DirectionCoordinate. For example, if it is GRADEC or GHADEC you would get Coordinate::TIME style formatting (DD:MM:SS.SS), otherwise you would get Coordinate::FIXED formatting by default.

axis says which axis in this Coordinate we are formatting. We have to know this because we may format Longitude and Latitude differently. For Coordinate::TIME style formatting, precision refers to the places after the decimal in the SS field.

If you leave units empty, then it makes up a nice unit for you.

Reimplemented from casa::Coordinate.

Definition at line 321 of file DirectionCoordinate.h.

References conversionType_p.

virtual Vector<Double> casa::DirectionCoordinate::increment ( ) const [virtual]

Implements casa::Coordinate.

Initialize unit conversion vectors and units.

Implements casa::Coordinate.

Fish out the ref and non-native poles (refLong, refLat, longPole, latPole) Not for general use.

Units are degrees.

Set up conversion machine.

void casa::DirectionCoordinate::makeDirectionCoordinate ( MDirection::Types  directionType,
const Projection proj,
Double  refLong,
Double  refLat,
Double  incLong,
Double  incLat,
const Matrix< Double > &  xform,
Double  refX,
Double  refY,
Double  longPole,
Double  latPole 
) [private]

Helper functions interfacing to WCS.

virtual Coordinate* casa::DirectionCoordinate::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::DirectionCoordinate::makeWCS ( ::wcsprm &  wcs,
const Matrix< Double > &  xform,
const Projection proj,
MDirection::Types  directionType,
Double  refPixLong,
Double  refPixLat,
Double  refLong,
Double  refLat,
Double  incLong,
Double  incLat,
Double  longPole,
Double  latPole 
) [private]
virtual void casa::DirectionCoordinate::makeWorldAbsolute ( Vector< Double > &  world) const [virtual]

Reimplemented from casa::Coordinate.

virtual void casa::DirectionCoordinate::makeWorldAbsolute ( MDirection world) const [virtual]
virtual void casa::DirectionCoordinate::makeWorldAbsoluteRef ( Vector< Double > &  world,
const Vector< Double > &  refVal 
) const [virtual]

Make absolute coordinates relative and vice versa with respect to the given reference value.

Add the other functions in this grouping as needed.

Reimplemented from casa::Coordinate.

virtual void casa::DirectionCoordinate::makeWorldRelative ( Vector< Double > &  world) const [virtual]

Make absolute world coordinates relative and vice-versa (relative to the reference value).

Note that these functions are independent of the MDirection::Types (set either at construction or by function setReferenceConversion). The vectors must be of length nWorldAxes or memory access errors will occur

Reimplemented from casa::Coordinate.

virtual void casa::DirectionCoordinate::makeWorldRelative ( MDirection world) const [virtual]
virtual Bool casa::DirectionCoordinate::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 returns a message about why.

Implements casa::Coordinate.

virtual Bool casa::DirectionCoordinate::near ( const Coordinate other,
const Vector< Int > &  excludeAxes,
Double  tol = 1e-6 
) const [virtual]

Implements casa::Coordinate.

Normalize each row of the PC matrix such that increment() will return the actual angular increment and any scale factors are removed from the PC matrix (modifies wcs_p.pc and wcs_p.cdelt and wcs_p.altlin, executes set_wcs() and hence wcsset() on the struct) See Greisen & Calabretta, A&A 395, 1061-1075 (2002), equation (4)

virtual uInt casa::DirectionCoordinate::nPixelAxes ( ) const [virtual]

Always returns 2.

Implements casa::Coordinate.

virtual uInt casa::DirectionCoordinate::nWorldAxes ( ) const [virtual]

Implements casa::Coordinate.

DirectionCoordinate& casa::DirectionCoordinate::operator= ( const DirectionCoordinate other)

Assignment (copy semantics).

Double casa::DirectionCoordinate::putLongInPiRange ( Double  lon,
const String unit 
) const [private]

Implements casa::Coordinate.

Implements casa::Coordinate.

static DirectionCoordinate* casa::DirectionCoordinate::restore ( const RecordInterface container,
const String fieldName 
) [static]

Recover the DirectionCoordinate from a record.

A null pointer means that the restoration did not succeed.

virtual Bool casa::DirectionCoordinate::save ( RecordInterface container,
const String fieldName 
) const [virtual]

Save the DirectionCoordinate into the supplied record using the supplied field name.

The field must not exist, otherwise False is returned.

Implements casa::Coordinate.

Reimplemented from casa::Coordinate.

virtual Bool casa::DirectionCoordinate::setIncrement ( const Vector< Double > &  inc) [virtual]

Implements casa::Coordinate.

virtual Bool casa::DirectionCoordinate::setLinearTransform ( const Matrix< Double > &  xform) [virtual]

Implements casa::Coordinate.

Set extra conversion type.

Whenever a conversion from pixel to world is done, the world value is then further converted to this MDirection::Types value. For example, your DirectionCoordinate may be defined in J2000. You can use this to get the world values out in say GALACTIC. Similarly, whenever you convert from world to pixel, the world value is assumed to be that appropriate to the conversionDirectionType. It is first converted to the MDirection::Types with which the DirectionCoordinate was constructed and from there to pixel. If you don't call this function, or you set the same type for which the DirectionCoordinate was constructed, no extra conversions occur. Some conversions will fail. These are the ones that require extra frame information (epoch, position) such as to AZEL from J2000 etc. This will be added later.

In the mixed pixel/world conversion routine toMix the implementation is only partial. See the comments for this function below.

virtual Bool casa::DirectionCoordinate::setReferencePixel ( const Vector< Double > &  refPix) [virtual]

Implements casa::Coordinate.

virtual Bool casa::DirectionCoordinate::setReferenceValue ( const Vector< Double > &  refval) [virtual]

Implements casa::Coordinate.

Set up the offset coordinate rotation matrix.

Units of long and lat are current world units

void casa::DirectionCoordinate::setRotationMatrix ( RotMatrix rot,
Double  lon,
Double  lat 
) const [private]
virtual Bool casa::DirectionCoordinate::setWorldAxisNames ( const Vector< String > &  names) [virtual]

Set the value of the requested attribute.

Note that these just change the internal values, they do not cause any recomputation.

Implements casa::Coordinate.

virtual Bool casa::DirectionCoordinate::setWorldAxisUnits ( const Vector< String > &  units) [virtual]

Change 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 angle. The units are initially "rad" (radians).

Implements casa::Coordinate.

virtual Bool casa::DirectionCoordinate::setWorldMixRanges ( const IPosition shape) [virtual]

Compute and retrieve the world min and max ranges, for use in function toMix, for a lattice of the given shape (for this coordinate).

Using these ranges in toMix should speed it up and help avoid ambiguity. If the shape is negative, that indicates that the shape is unknown for that axis. The default range is used for that axis. This situation arises in a CoordinateSystem for which a pixel, but not a world axis has been removed. The output vectors are resized. Returns False if fails (and then setDefaultWorldMixRanges generates the ranges) with a reason in errorMessage(). The setDefaultWorldMixRanges function just gives you [-90->90], [-180,180] (in appropriate units)

Reimplemented from casa::Coordinate.

void casa::DirectionCoordinate::setWorldMixRanges ( const Vector< Bool > &  which,
const Vector< Double > &  world 
)

Non-virtual function.

When which is T, use the world value as the center for the mix world range.

virtual String casa::DirectionCoordinate::showType ( ) const [virtual]

Always returns the String "Direction".

Implements casa::Coordinate.

void casa::DirectionCoordinate::toCurrent ( Vector< Double > &  degrees) const [private]

Interconvert between the current units and wcs units (degrees)

Return unit conversion vector for converting to current units.

virtual Bool casa::DirectionCoordinate::toMix ( Vector< Double > &  worldOut,
Vector< Double > &  pixelOut,
const Vector< Double > &  worldIn,
const Vector< Double > &  pixelIn,
const Vector< Bool > &  worldAxes,
const Vector< Bool > &  pixelAxes,
const Vector< Double > &  worldMin,
const Vector< Double > &  worldMax 
) const [virtual]

Mixed pixel/world coordinate conversion.

worldIn and worldAxes are of length nWorldAxes. pixelIn and pixelAxes are of length nPixelAxes. worldAxes(i)=True specifies you have given a world value in worldIn(i) to convert to pixel. pixelAxes(i)=True specifies you have given a pixel value in pixelIn(i) to convert to world. You cannot specify the same axis via worldAxes and pixelAxes. Values in pixelIn are converted to world and put into worldOut in the appropriate world axis location. Values in worldIn are copied to worldOut. Values in worldIn are converted to pixel and put into pixelOut in the appropriate pixel axis location. Values in pixelIn are copied to pixelOut.

worldMin and worldMax specify the range of the world coordinate (in the world axis units of that world axis in the CoordinateSystem) being solved for in a mixed calculation for each world axis. Some mixed solutions can be degenerate, whereupon you you must say which one you want. Use functions setWorldMixRanges and worldMixMin, worldMixMax to set these ranges, If you don't know, use the defaults (function setDefaultWorldMixRanges. Removed axes are handled (for example, a removed pixel axis with remaining corresponding world axis will correctly be converted to world using the replacement value). Returns True if the conversion succeeds, otherwise it returns False and errorMessage() contains an error message. The output vectors are resized.

If you actually request a pure pixel to world or world to pixel via toMix, then the functions toWorld or toPixel will be invoked directly (see above) and the extra conversion layer invoked through function setReferenceConversion will be active. However, if you request a true mixed pixel/world conversion, the extra conversion layer is not activated (because of the nature of mixed conversions). This situation may change in the future with a partial implementation added.

Reimplemented from casa::Coordinate.

Bool casa::DirectionCoordinate::toMix2 ( Vector< Double > &  out,
const Vector< Double > &  in,
const Vector< Double > &  minWorld,
const Vector< Double > &  maxWorld,
Bool  longIsWorld 
) const [private]

Mixed pixel/world coordinate conversion.

Vector in must be length nWorldAxes (2). Specify whether longitude (in(0)) or latitude (in(1)) is the world coordinate . It is assumed that the other value is the pixel coordinate.

virtual Bool casa::DirectionCoordinate::toPixel ( Vector< Double > &  pixel,
const Vector< Double > &  world 
) const [virtual]

Implements casa::Coordinate.

Bool casa::DirectionCoordinate::toPixel ( Vector< Double > &  pixel,
const MDirection world 
) const
Bool casa::DirectionCoordinate::toPixel ( Vector< Double > &  pixel,
const MVDirection world 
) const
virtual Bool casa::DirectionCoordinate::toPixelMany ( Matrix< Double > &  pixel,
const Matrix< Double > &  world,
Vector< Bool > &  failures 
) const [virtual]

Reimplemented from casa::Coordinate.

virtual Bool casa::DirectionCoordinate::toWorld ( Vector< Double > &  world,
const Vector< Double > &  pixel 
) const [virtual]

Convert a pixel position to a world 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.

Bool casa::DirectionCoordinate::toWorld ( MDirection world,
const Vector< Double > &  pixel 
) const

A convenient way to turn the world vector into an MDirection or MVDirection for further processing in the Measures system.

We could improve the performance of this if it would be useful, however I expect that normally you would just call this once to get a template MDirection, and then call the vector versions.

Bool casa::DirectionCoordinate::toWorld ( MVDirection world,
const Vector< Double > &  pixel 
) const
virtual Bool casa::DirectionCoordinate::toWorldMany ( Matrix< Double > &  world,
const Matrix< Double > &  pixel,
Vector< Bool > &  failures 
) const [virtual]

Batch up a lot of transformations.

The first (most rapidly varying) axis of the matrices contain the coordinates. Returns False if any conversion failed and errorMessage() will hold a message. The failures array is the length of the number of conversions (True for failure, False for success)

Reimplemented from casa::Coordinate.

Return the requested attributed.

Implements casa::Coordinate.

Implements casa::Coordinate.


Member Data Documentation

Definition at line 593 of file DirectionCoordinate.h.

Referenced by getReferenceConversion().

Axis names.

Definition at line 610 of file DirectionCoordinate.h.

Definition at line 622 of file DirectionCoordinate.h.

Conversion machines.

"To" handles type_p -> conversionType_p "From" handles conversionType_p -> type_p;

Definition at line 621 of file DirectionCoordinate.h.

Projection parameters.

Definition at line 596 of file DirectionCoordinate.h.

Rotation matrix used to handle relative coordinates.

Definition at line 616 of file DirectionCoordinate.h.

WCS computes in degrees - use this to convert back and forth between current DirectionCoordinate units and degrees or radians.

Definition at line 606 of file DirectionCoordinate.h.

Definition at line 607 of file DirectionCoordinate.h.

Direction type.

Definition at line 593 of file DirectionCoordinate.h.

Current units.

Definition at line 613 of file DirectionCoordinate.h.

mutable ::wcsprm casa::DirectionCoordinate::wcs_p [private]

WCS structure.

This is mutable because the wcs functions that do toPixel and toWorld (which have const signature) require a non const wcs structure. so either all of these virtual functions lose their const or we use mutable...

Definition at line 602 of file DirectionCoordinate.h.


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