|
static void | addDirAxes (CoordinateSystem &coords) |
| Add a RA/DEC pair of direction axes (ie. More...
|
|
static void | addIQUVAxis (CoordinateSystem &coords) |
| Add a Stokes I,Q,U,V axis to the user supplied CoordinateSystem. More...
|
|
static void | addIAxis (CoordinateSystem &coords) |
| Add a Stokes I (only) axis to the user supplied CoordinateSystem. More...
|
|
static Bool | addStokesAxis (CoordinateSystem &coords, uInt shape) |
| Add a Stokes axis of length 1 to 4 selected from I,Q,U,V E.g. More...
|
|
static void | addLinearAxes (CoordinateSystem &coords, const Vector< String > &names, const IPosition &shape) |
| Add Linear axes. More...
|
|
static void | addFreqAxis (CoordinateSystem &coords) |
| Add a spectral axis to the user supplied CoordinateSystem. More...
|
|
static uInt | addAxes (CoordinateSystem &csys, Bool direction, Bool spectral, const String &stokes, Bool linear, Bool tabular, Bool silent=False) |
| Add one axis for each of the specified coordinate types. More...
|
|
static CoordinateSystem | defaultCoords2D () |
| Return a 2-dimensional coordinate system with RA/DEC axes only. More...
|
|
static CoordinateSystem | defaultCoords3D () |
| Return a 3-dimensional coordinate system with RA/DEC axes and a spectral axis. More...
|
|
static CoordinateSystem | defaultCoords4D () |
| Return a 4-dimensional coordinate system with RA/DEC axes, an IQUV polarisation axis and a spectral axis. More...
|
|
static CoordinateSystem | defaultCoords (uInt dims) |
| Calls one of the above three functions depending of the arguement. More...
|
|
static CoordinateSystem | makeCoordinateSystem (const IPosition &shape, Bool doLinear=False) |
| If doLinear=False, Tries to make a standard RA/DEC/Stokes/Frequency CoordinateSystem depending upon the shape. More...
|
|
static Int | findSpectralAxis (const CoordinateSystem &coords) |
| Find which pixel axis in the CoordinateSystem corresponds to the SpectralCoordinate. More...
|
|
static void | findSpectralAxis (Int &pixelAxis, Int &worldAxis, Int &coordinate, const CoordinateSystem &coords) |
| Find the SpectralCoordinate in the CoordinateSystem, and then return the most general description of where it is. More...
|
|
static Vector< Int > | findDirectionAxes (const CoordinateSystem &coords) |
| Find which pixel axes correspond to the DirectionCoordinate in the supplied coordinate system and return this as a Vector. More...
|
|
static void | findDirectionAxes (Vector< Int > &pixelAxes, Vector< Int > &worldAxes, Int &coordinate, const CoordinateSystem &coords) |
| Find which pixel axes correspond to the DirectionCoordinate in the supplied coordinate system and return the most general description of where it is. More...
|
|
static Int | findStokesAxis (Vector< Stokes::StokesTypes > &whichPols, const CoordinateSystem &coords) |
| Find which pixel axis is the polarisation axis in the supplied CoordinateSystem and return this. More...
|
|
static void | findStokesAxis (Int &pixelAxis, Int &worldAxis, Int &coordinate, const CoordinateSystem &coords) |
| Find the StokesCoordinate in the CoordinateSystem, and then return the most general description of where it is. More...
|
|
static Coordinate::Type | findPixelAxis (const CoordinateSystem &cSys, Int axis) |
| Find Coordinate type for this pixel or world axis. More...
|
|
static Coordinate::Type | findWorldAxis (const CoordinateSystem &cSys, Int axis) |
|
static Bool | removeAxes (CoordinateSystem &cSys, Vector< Double > &worldReplacement, const Vector< Int > &worldAxes, const Bool remove) |
| Remove a list of world axes and their associated pixel axes from a CoordinateSystem . More...
|
|
static Bool | removePixelAxes (CoordinateSystem &cSys, Vector< Double > &pixelReplacement, const Vector< Int > &pixelAxes, const Bool remove) |
| Remove a list of pixel axes but not their associated world axes from a CoordinateSystem . More...
|
|
static Bool | dropRemovedAxes (CoordinateSystem &cSysOut, const CoordinateSystem &cSysIn, Bool preserveAxesOrder=False) |
| Physically (nont just virtually) drop coordinates from the CoordinateSystem if all axes are fully removed. More...
|
|
static Bool | makeDirectionMachine (LogIO &os, MDirection::Convert &machine, const DirectionCoordinate &dirCoordTo, const DirectionCoordinate &dirCoordFrom, const ObsInfo &obsTo, const ObsInfo &obsFrom) |
| Setup Measures conversion machine for MDirections. More...
|
|
static Bool | makeFrequencyMachine (LogIO &os, MFrequency::Convert &machine, Int coordinateTo, Int coordinateFrom, const CoordinateSystem &coordsTo, const CoordinateSystem &coordsFrom, const Unit &unit=Unit(String("Hz"))) |
| Setup Measures conversion machines for MFrequencies. More...
|
|
static Bool | makeFrequencyMachine (LogIO &os, MFrequency::Convert &machine, MFrequency::Types typeTo, MFrequency::Types typeFrom, const MDirection &dirTo, const MDirection &dirFrom, const MEpoch &epochTo, const MEpoch &epochFrom, const MPosition &posTo, const MPosition &posFrom, const Unit &unit=Unit(String("Hz"))) |
| Setup Measures conversion machines for MFrequencies. More...
|
|
static Bool | findSky (String &errorMessage, Int &dirCoord, Vector< Int > &pixelAxes, Vector< Int > &worldAxes, const CoordinateSystem &cSys) |
| Find the Sky in the CoordinateSystem. More...
|
|
static Bool | holdsSky (Bool &holdsOneSkyAxis, const CoordinateSystem &cSys, Vector< Int > pixelAxes) |
| Do the specified axes hold the sky ? Returns False if no DirectionCoordinate or if only one axis of the DirectionCoordinate is held or the specified pixel axes don't pertain to the DirectionCoordinate. More...
|
|
static Stokes::StokesTypes | findSingleStokes (LogIO &os, const CoordinateSystem &cSys, uInt pixel=0) |
| Find the Stokes for the specified pixel. More...
|
|
static void | setNiceAxisLabelUnits (CoordinateSystem &cSys) |
| Set the world axis units in the CS to 'deg' for Direction. More...
|
|
static Bool | setCoordinateUnits (CoordinateSystem &cSys, const Vector< String > &units, uInt which) |
| Set world axis units for specific Coordinate. More...
|
|
static Bool | setDirectionUnit (CoordinateSystem &cSys, const String &unit, Int which=-1) |
| Set a unit for all unremoved world axes in the DirectionCoordinate in the CS. More...
|
|
static Bool | setDirectionConversion (String &errorMsg, CoordinateSystem &cSys, const String directionSystem) |
| Set Direction conversion layer of DirectionCoordinate in CoordinateSystem so that pixel<->world go to the specified direction system (a valid MDirection::Types string). More...
|
|
static Bool | setSpectralState (String &errorMsg, CoordinateSystem &cSys, const String &unit, const String &spcquant) |
| Set spectral state of SpectralCoordinate in CoordinateSystem. More...
|
|
static Bool | setVelocityState (String &errorMsg, CoordinateSystem &cSys, const String &unit, const String &spcquant) |
| Set velocity state of SpectralCoordinate in CoordinateSystem. More...
|
|
static Bool | isSky (LogIO &os, const CoordinateSystem &cSys) |
| Does the CoordinateSystem hold just the sky? Returns True if CS pixel axis 0 is the longitude and 1 latitude else returns False. More...
|
|
static Bool | setRestFrequency (String &errorMsg, CoordinateSystem &cSys, const String &unit, const Double &value) |
| Set rest frequency of SpectralCoordinate in CoordinateSystem. More...
|
|
static Bool | setSpectralConversion (String &errorMsg, CoordinateSystem &cSys, const String frequencySystem) |
| Set Spectral conversion layer of SpectralCoordinate in CoordinateSystem so that pixel<->world go to the specified frequency system (a valid MFrequency::Types string). More...
|
|
static Bool | setSpectralFormatting (String &errorMsg, CoordinateSystem &cSys, const String &unit, const String &spcquant) |
| Set default format unit and doppler velocity state of SpectralCoordinate in CoordinateSystem. More...
|
|
static String | formatCoordinate (const IPosition &pixel, const CoordinateSystem &cSys, Int precision=-1) |
| Convert an absolute pixel coordinate to world and format with default Coordinate formatting. More...
|
|
static String | formatCoordinate (const Vector< Double > &pixel, const CoordinateSystem &cSys, Int precision=-1) |
|
static String | axisLabel (const Coordinate &coord, uInt axisInCoordinate=0, Bool doWorld=True, Bool doAbs=True, Bool doVel=False) |
| Generate axis label String from coordinate. More...
|
|
static Bool | cylindricalFix (CoordinateSystem &cSys, String &errorMessage, const IPosition &shape) |
| Fix up Cylindrical parameters in any DirectionCoordinate for when the longitude is outside of [-180,180] range. More...
|
|
static CoordinateSystem | makeBinnedCoordinateSystem (const IPosition &factors, const CoordinateSystem &cSysIn, Bool failOnStokes=False) |
| Apply the binning factors to the CS and create a new one reflecting the binning You can optionally throw an exception if factors is non-unit for any Stokes axis. More...
|
|
|
static Int | compareCoordinates (const CoordinateSystem &thisCsys, const CoordinateSystem &thatCsys) |
| Check how the coordinates of this and that compare. More...
|
|
static Vector< Int > | toPixelAxes (const CoordinateSystem &thisCsys, const CoordinateSystem &thatCsys, const Vector< Int > &worldAxes) |
| Convert the world axes map given in worldAxes to a pixel axes map. More...
|
|
static Bool | checkOrder (const Vector< Int > &pixelAxes) |
| Check if the axes in the pixel axes map are in ascending order. More...
|
|
static Bool | findExtendAxes (IPosition &newAxes, IPosition &stretchAxes, const IPosition &newShape, const IPosition &oldShape, const CoordinateSystem &newCsys, const CoordinateSystem &oldCsys) |
| Find the new and stretch axes when comparing the old and new coordinates and shapes (helper for ExtendImage). More...
|
|
Functions for creating default CoordinateSystems.
Intended use:
Public interface
Prerequisite
Etymology
CoordinateUtils follows the Casacore naming convention for static functions that are associated with a class.
Synopsis
This file contains declarations for static functions that manipulate coordinate systems. It currently contains functions for:
The functions for adding default axes to a CoordinateSystem can add either a RA/DEC pair of axes, a Polarisation Axis, or a Spectral Axis to a user supplied coordinate system. The default values for these functions are:
-
addDirAxes
this adds a DirectionCoordinate with a reference pixel of (0,0) corresponding to an RA/DEC of (0,0) in a J2000 reference frame. The pixel increment is 1 arc-minute.
-
addIQUVAxis
this adds a polarization axis with four elements corresponding to the Stokes (I,Q,U,V) components.
-
addIAxis
this adds a polarization axis with one element corresponding to the Stokes I component only
-
addFreqAxis
this adds a spectral axis with a reference frequency of 1.415GHz on channel 0. The channel bandwidth (pixel increment) is 1kHz, and the reference frame is the kinematical Local Standard of rest (MFrequency ::LSRK).
The defaultCoords
functions, create from scratch a CoordinateSystem using the above described addXXXAxis
functions to add the required number of dimensions to the CoordinateSystem. Only 2, 3 or 4 dimensional coordinate systems can be constructed using these functions. The coordinate systems always have RA/Dec axes. Three dimensional Systems add a spectral axis and four-dimensional systems add an IQUV polarization axis. An exception (AipsError) is thrown if defaultCoords(uInt)
is called with a parameter that is not 2, 3, or 4.
The defaultCoordsXX
functions return the coordinate system by value (which involves a copy of the CoordinateSystem) and hence are not as effcient as the addXXXAxis
functions.
If the default axes provided by these functions are not quite what is required it is possible to use member functions of the CoordinateSystem and Coordinate classes (DirectionCoordinate, StokesCoordinate, SpectralCoordinate etc.) to tweak the appropriate parameters of the specified axis.
Now we turn to the functions for finding axes in a CoordinateSystem. With a CoordinateSystem object it is not required that the first Coordinate axis in the the CoordinateSystem map to the first pixel axis in an image. Hence it is necessary to determine which pixel axis corresponds to a specified Coordinate and this can be done using these functions. Some coordinate types, in particular DirectionCoordinate, usually map to more than one pixel axis (DirectionsCoordinates are inherently two-dimensional).
This group contains declarations for static functions that search CoordinateSystem's for a coordinate of the specified type. It returns the pixel axis (zero relative) of the specified coordinate type. If the supplied Coordinate system does not contain the specified coordinate type the returned value is function specific (but usually -1). If the supplied CoordinateSystem contains two or more of the specified coordinateType then an exception (AipsError) is thrown.
Finally functions are provided for removing lists of pixel/world axes from a CoordinateSystem. This process is made a little awkward by the fact that when you remove one axis, all the rest shuffle down one, so it is provided here. Generally, one only needs to remove one axis (in which case you should use the CoordinateSystem::removeWorldAxis and CoordinateSystem::removcePixelAxis functions), but on occaision, the multiple need is there.
Example
I use these functions when creating test images.
Example
Functions are needed to handle images without specifying a canonical coordinate order. For example suppose we want to find the spectral aixs of a PagedImage object.
cout << "The spectral axis is of shape " << image.shape()(spectralAxis) << endl;
Example
Here we remove the first and last world axes, and their associated pixel axes from a 3D CoordinateSystem. The reference values and reference pixels are used for the replacement values.
Vector<Int> worldAxes(2);
worldAxes(0) = 0; worldAxes(1) = cSys.nWorldAxes()-1;
Vector<Double> worldRep;
cout << "For world axes used " << worldRep << " for replacement" << endl;
Motivation
I got fed up writing small functions to create and find coordinates when writing test programs involving Images and ComponentModels.
Thrown Exceptions
Definition at line 202 of file CoordinateUtil.h.