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:
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.
PagedImage(IPosition(4,256,256,4,32), CoordinateUtil::defaultCoords4D(), String("test.image"));
const Int spectralAxis = CoordinateUtil::findSpectralAxis(image.coordinates()); cout << "The spectral axis is of shape " << image.shape()(spectralAxis) << endl;
CoordinateSystem cSys = CoordinateUtil::defaultCoords3D(); Vector<Int> worldAxes(2); worldAxes(0) = 0; worldAxes(1) = cSys.nWorldAxes()-1; Vector<Double> worldRep; Bool ok = CoordinateUtil::removeAxes(cSys, worldRep, worldAxes, True); cout << "For world axes used " << worldRep << " for replacement" << endl;
Add a Stokes I,Q,U,V axis to the user supplied CoordinateSystem.
Add a Stokes I (only) axis to the user supplied CoordinateSystem.
Add a Stokes axis of length 1 to 4 selected from I,Q,U,V E.g. if shape=2 you get IQ. Returns False if shape is not in the range 1 to 4
Add Linear axes. The LinearCoordinate can have > 1 axes (like the DirectionCoordinate has 2). The number of axes is given by the length of the names argument. If you supply a shape, it will be used to set the reference pixel to 1/2 the shape. If the shape does not have the same number of elements as the names variable, the reference pixel will be 0
Add a spectral axis to the user supplied CoordinateSystem. See the synopsis above for the current default values.
Return a 2-dimensional coordinate system with RA/DEC axes only.
Return a 3-dimensional coordinate system with RA/DEC axes and a spectral axis.
Return a 4-dimensional coordinate system with RA/DEC axes, an IQUV polarisation axis and a spectral axis.
Calls one of the above three functions depending of the arguement. An AipsError is thrown if dims is not 2, 3, or 4.
If doLinear=False, Tries to make a standard RA/DEC/Stokes/Frequency CoordinateSystem depending upon the shape. The shape for the Stokes axis must be <= 4. If axis 2 can't be Stokes it will be a Spectral axis instead. AFter the standard types, the rest (if any) of the CoordinateSystem consists of LinearCoordinates. If doLinear=True, then you just get a linear coordinate system
Find which pixel axis in the CoordinateSystem corresponds to the SpectralCoordinate. If there is no SpectralCoordinate in the coordinate system then return -1.
Find the SpectralCoordinate in the CoordinateSystem, and then return the most general description of where it is. If there is no SpectralCoordinate in the CoordinateSystem then return -1 for coordinate. If the world or pixel axis has been removed, return -1 for that value.
Find which pixel axes correspond to the DirectionCoordinate in the supplied coordinate system and return this as a Vector. If there is no DirectionCoordinate in the CoordinateSystem then return a Vector of zero length. Normally the returned Vector will have a length of two. However, if the pixel axis has been removed, then the resultant vector will take the value -1 for that axis.
Find which pixel axes correspond to the DirectionCoordinate in the supplied coordinate system and return the most general description of where it is. If there is no DirectionCoordinate then coordinate is returned with value -1. Values of -1 in the returned vectors indicate an axis has been removed.
Find which pixel axis is the polarisation axis in the supplied CoordinateSystem and return this. If there is no StokesCoordinate in the CoordinateSystem return a negative number. The actual polarisations on the returned pixel axis are returned in the whichPols Vector. Each element of this Vector is a Stokes::StokesTypes enumerator and the length of the Vector is the same as the length of the polarisation axis. If there is no polarisation axis the whichPols returns a unit length Vector containing Stokes::I
Find the StokesCoordinate in the CoordinateSystem, and then return the most general description of where it is. If there is no StokesCoordinate in the CoordinateSystem then return -1 for coordinate. If the world or pixel axis has been removed, return -1 for that value.
Find Coordinate type for this pixel or world axis
Remove a list of world axes and their associated pixel axes from a CoordinateSystem. The list of world axes to be removed is derived from a list giving either axes to remove, or axes to keep (controlled by whether remove is True or False. The replacement values (see functions CoordinateSystem::removeWorldAxis) for the world axes can be given. For the associated pixel axes, the pixel replacement coordinate is found by converting the world coordinate to a pixel coordinate. If the length of the replacement value vector is not the number of world axes to be removed then the reference values will be used (e.g. use zero length vectors).
Remove a list of pixel axes but not their associated world axes from a CoordinateSystem. The list of pixel axes to be removed is derived from a list giving either axes to remove, or axes to keep (controlled by whether remove is True or False. The replacement values (see functions CoordinateSystem::removePixelAxis) for the pixel axes can be given. If the length of the replacement value vector is not the number of pixel axes to be removed then the reference pixel will be used (e.g. use zero length vectors).
Physically (nont just virtually) drop coordinates from the CoordinateSystem if all axes are fully removed. For coordinates with axes partially removed (world/pixel) preserve that removal state in the output CS. No effort is made to deal in any way with transposed systems.
Setup Measures conversion machine for MDirections. Returns True if the machine was needed and set. Returns False if the machine was not needed and not set.
Setup Measures conversion machines for MFrequencies. Returns False if a trial conversion failed, else returns True. There must be both a Direction and a Spectral Coordinate in the CoordinateSystem when making the Frequency machine, else an exception occurs.
Setup Measures conversion machines for MFrequencies. Returns False if a trial conversion failed, else returns True.
Find the Sky in the CoordinateSystem. Assumes only one DirectionCoordinate. pixelAxes and worldAxes say where in the CS the DirectionCoordinate axes are (long then lat). Returns False and an error message if it can't find the sky.
Does the CoordinateSystem hold just the sky ? Exception if not. Returns True if CS pixel axis 0 is the longitude and 1 latitude else returns False
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.
Find the Stokes for the specified pixel. If there is no Stokes in the CoordinateSystem, returns Stokes::I
Set the world axis units in the CS to 'deg' for Direction. For Spectral set the velocity handling to use 'km/s' units. Other coordinates are not touched.
Set world axis units for specific Coordinate. Returnd False if fails to set units with error in cSys.errorMessage().
Set a unit for all unremoved world axes in the DirectionCoordinate in the CS. Returns False if fails to set unit with error in cSys. If no DC returns True
Set Direction conversion layer of DirectionCoordinate in CoordinateSystem so that pixel<->world go to the specified direction system (a valid MDirection::Types string). Returns False with error if direction system invalid. If no DirectionCoordinate returns True
Set spectral state of SpectralCoordinate in CoordinateSystem. Unit must be consistent with Hz or m/s and the doppler a valid MDoppler string. For no change, leave either String empty. Returns False if invalid inputs (and CS not changed) and an error message.
Set velocity state of SpectralCoordinate in CoordinateSystem. Unit must be consistent m/s and the doppler a valid MDoppler string. For no change, leave either String empty. Returns False if invalid inputs (and CS not changed) and an error message.
Set Spectral conversion layer of SpectralCoordinate in CoordinateSystem so that pixel<->world go to the specified frequency system (a valid MFrequency::Types string). Returns False if frequency system invalid or if no DirectionCoordinate or if cant get Date/Epoch
Set default format unit and doppler velocity state of SpectralCoordinate in CoordinateSystem. Unit can be consistent with Hz or m/s Returns False if invalid inputs (and CS not changed) and an error message.
Convert an absolute pixel coordinate to world and format with
default Coordinate formatting
Convert the world axes map given in worldAxes to a pixel axes map.
Check if the axes in the pixel axes map are in ascending order.
Find the new and stretch axes when comparing the old and new
coordinates and shapes (helper for ExtendImage).
Fix up Cylindrical parameters in any DirectionCoordinate for when the longitude
is outside of [-180,180] range. If it returns False, it failed and an error
message is returned as well. This function should be called on any
CS made from an imported image like FITS
Apply the binning factors to the CS and create a new one reflecting the binning
static Vector<Int> toPixelAxes (const CoordinateSystem& thisCsys, const CoordinateSystem& thatCsys, const Vector<Int>& worldAxes)
static Bool checkOrder (const Vector<Int>& pixelAxes)
static Bool findExtendAxes (IPosition& newAxes, IPosition& stretchAxes, const IPosition& newShape, const IPosition& oldShape, const CoordinateSystem& newCsys, const CoordinateSystem& oldCsys)
static Int compareCoordinates (const CoordinateSystem& thisCsys, const CoordinateSystem& thatCsys)
static Bool cylindricalFix (CoordinateSystem& cSys, String& errorMessage, const IPosition& shape)
static CoordinateSystem makeBinnedCoordinateSystem (const IPosition& factors, const CoordinateSystem& cSysIn)