00001 //# CoordinateUtils.h: static functions dealing with coordinates 00002 //# Copyright (C) 1997,1998,1999,2000,2001,2002,2004 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id$ 00027 00028 #ifndef COORDINATES_COORDINATEUTIL_H 00029 #define COORDINATES_COORDINATEUTIL_H 00030 00031 00032 #include <casacore/casa/aips.h> 00033 #include <casacore/casa/Arrays/Vector.h> 00034 #include <casacore/measures/Measures/Stokes.h> 00035 #include <casacore/coordinates/Coordinates/Coordinate.h> 00036 00037 #include <casacore/measures/Measures/MDirection.h> //# For enums 00038 #include <casacore/measures/Measures/MFrequency.h> 00039 #include <casacore/measures/Measures/MeasConvert.h> 00040 00041 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00042 00043 class CoordinateSystem; 00044 class DirectionCoordinate; 00045 class ObsInfo; 00046 class String; 00047 class LogIO; 00048 class MEpoch; 00049 class MPosition; 00050 class Unit; 00051 00052 00053 // <summary>Functions for creating default CoordinateSystems</summary> 00054 // <use visibility=export> 00055 00056 // <reviewed reviewer="" date="" tests="" demos=""> 00057 // </reviewed> 00058 00059 // <prerequisite> 00060 // <li> <linkto class="CoordinateSystem">CoordinateSystem</linkto> 00061 // </prerequisite> 00062 // 00063 // <etymology> 00064 // CoordinateUtils follows the Casacore naming convention for static functions 00065 // that are associated with a class. 00066 // </etymology> 00067 // 00068 // <synopsis> 00069 // This file contains declarations for static functions that manipulate 00070 // coordinate systems. It currently contains functions for: 00071 // <ul> 00072 // <li> Adding default axes to a CoordinateSystem 00073 // <li> Creating a default CoordinateSystem 00074 // <li> Finding specified axes in a CoordinateSystem 00075 // </ul> 00076 // 00077 // The functions for adding default axes to a CoordinateSystem can add 00078 // either a RA/DEC pair of axes, a Polarisation Axis, or a Spectral Axis to 00079 // a user supplied coordinate system. The default values for these functions 00080 // are: 00081 // <ul> 00082 // <li> <src>addDirAxes</src> this adds a DirectionCoordinate with a 00083 // reference pixel of (0,0) corresponding to an RA/DEC of (0,0) in a 00084 // J2000 reference frame. The pixel increment is 1 arc-minute. 00085 // <li> <src>addIQUVAxis</src> this adds a polarization axis with four 00086 // elements corresponding to the Stokes (I,Q,U,V) components. 00087 // <li> <src>addIAxis</src> this adds a polarization axis with one 00088 // element corresponding to the Stokes I component only 00089 // <li> <src>addFreqAxis</src> this adds a spectral axis with a reference 00090 // frequency of 1.415GHz on channel 0. The channel bandwidth (pixel 00091 // increment) is 1kHz, and the reference frame is the kinematical Local Standard of 00092 // rest (<linkto class="MFrequency">MFrequency</linkto>::LSRK). 00093 // </ul> 00094 // 00095 // The <src>defaultCoords</src> functions, create from scratch a 00096 // CoordinateSystem using the above described <src>addXXXAxis</src> 00097 // functions to add the required number of dimensions to the 00098 // CoordinateSystem. Only 2, 3 or 4 dimensional coordinate systems can be 00099 // constructed using these functions. The coordinate systems always have 00100 // RA/Dec axes. Three dimensional Systems add a spectral axis and 00101 // four-dimensional systems add an IQUV polarization axis. An exception 00102 // (AipsError) is thrown if <src>defaultCoords(uInt)</src> is called with a 00103 // parameter that is not 2, 3, or 4. 00104 // 00105 // The <src>defaultCoordsXX</src> functions return the coordinate system by 00106 // value (which involves a copy of the CoordinateSystem) and hence are not 00107 // as effcient as the <src>addXXXAxis</src> functions. 00108 // 00109 // If the default axes provided by these functions are not quite what is 00110 // required it is possible to use member functions of the 00111 // <linkto class="CoordinateSystem">CoordinateSystem</linkto> 00112 // and <linkto class="Coordinate">Coordinate</linkto> classes 00113 // (<linkto class="DirectionCoordinate">DirectionCoordinate</linkto>, 00114 // <linkto class="StokesCoordinate">StokesCoordinate</linkto>, 00115 // <linkto class="SpectralCoordinate">SpectralCoordinate</linkto> etc.) 00116 // to tweak the appropriate parameters of the specified axis. 00117 // 00118 // Now we turn to the functions for finding axes in a CoordinateSystem. With 00119 // a CoordinateSystem object it is not required that the first Coordinate 00120 // axis in the the CoordinateSystem map to the first pixel axis in an 00121 // image. Hence it is necessary to determine which pixel axis corresponds to a 00122 // specified Coordinate and this can be done using these functions. Some 00123 // coordinate types, in particular DirectionCoordinate, usually map to more 00124 // than one pixel axis (DirectionsCoordinates are inherently two-dimensional). 00125 // 00126 // This group contains declarations for static functions that search 00127 // CoordinateSystem's for a coordinate of the specified type. It returns the 00128 // pixel axis (zero relative) of the specified coordinate type. If the supplied 00129 // Coordinate system does not contain the specified coordinate type the 00130 // returned value is function specific (but usually -1). If the supplied 00131 // CoordinateSystem contains two or more of the specified coordinateType then 00132 // an exception (AipsError) is thrown. 00133 // 00134 // Finally functions are provided for removing lists of pixel/world axes 00135 // from a CoordinateSystem. 00136 // This process is made a little awkward by the fact that when you 00137 // remove one axis, all the rest shuffle down one, so it is 00138 // provided here. Generally, one only needs to remove one axis 00139 // (in which case you should use the CoordinateSystem::removeWorldAxis and 00140 // CoordinateSystem::removcePixelAxis functions), but on occaision, 00141 // the multiple need is there. 00142 // </synopsis> 00143 // 00144 // <example> 00145 // I use these functions when creating test images. 00146 // <srcblock> 00147 // PagedImage(IPosition(4,256,256,4,32), CoordinateUtil::defaultCoords4D(), 00148 // String("test.image")); 00149 // </srcblock> 00150 // </example> 00151 // 00152 // <example> 00153 // Functions are needed to handle images without specifying a canonical 00154 // coordinate order. For example suppose we want to find the spectral aixs 00155 // of a PagedImage object. 00156 // 00157 // <srcblock> 00158 // const Int spectralAxis = CoordinateUtil::findSpectralAxis(image.coordinates()); 00159 // cout << "The spectral axis is of shape " << image.shape()(spectralAxis) << endl; 00160 // </srcblock> 00161 // </example> 00162 // 00163 // <example> 00164 // Here we remove the first and last world axes, and their associated 00165 // pixel axes from a 3D CoordinateSystem. The reference values and 00166 // reference pixels are used for the replacement values. 00167 // 00168 // <srcblock> 00169 // CoordinateSystem cSys = CoordinateUtil::defaultCoords3D(); 00170 // Vector<Int> worldAxes(2); 00171 // worldAxes(0) = 0; worldAxes(1) = cSys.nWorldAxes()-1; 00172 // Vector<Double> worldRep; 00173 // Bool ok = CoordinateUtil::removeAxes(cSys, worldRep, worldAxes, True); 00174 // cout << "For world axes used " << worldRep << " for replacement" << endl; 00175 // </srcblock> 00176 // </example> 00177 // 00178 // 00179 // <motivation> 00180 // I got fed up writing small functions to create and find coordinates when writing 00181 // test programs involving Images and ComponentModels. 00182 // </motivation> 00183 // 00184 // <thrown> 00185 // <li> AipsError 00186 // </thrown> 00187 // 00188 // <todo asof="1997/01/23"> 00189 // Many of these methods belong in the CoordinateSystem class, 00190 // eg all the add* methods, and in fact CoordinateSystem already has analogs 00191 // for many of them. The factory methods which create a CoordinateSystem 00192 // could also arguably go in CoordinateSystem as static methods. Having a separate 00193 // utility class that really just has methods that operate on or create CoordinateSystem 00194 // objects makes no sense. CoordinateUtil is the antithesis of object oriented design, 00195 // and we need to endeavor to expunge it from our system. 00196 // </todo> 00197 00198 // <linkfrom anchor=defaultAxes classes="CoordinateSystem"> 00199 // Static functions for creating <here>default</here> coordinate systems 00200 // </linkfrom> 00201 00202 class CoordinateUtil 00203 { 00204 public: 00205 00206 // Add a RA/DEC pair of direction axes (ie. a DirectionCoordinate) to the 00207 // user supplied CoordinateSystem. See the synopsis above for the current 00208 // default values. 00209 static void addDirAxes(CoordinateSystem& coords); 00210 00211 // Add a Stokes I,Q,U,V axis to the user supplied CoordinateSystem. 00212 static void addIQUVAxis(CoordinateSystem& coords); 00213 00214 // Add a Stokes I (only) axis to the user supplied CoordinateSystem. 00215 static void addIAxis(CoordinateSystem& coords); 00216 00217 // Add a Stokes axis of length 1 to 4 selected from I,Q,U,V 00218 // E.g. if shape=2 you get IQ. Returns False if shape 00219 // is not in the range 1 to 4 00220 static Bool addStokesAxis(CoordinateSystem& coords, uInt shape); 00221 00222 // Add Linear axes. The LinearCoordinate can have > 1 axes (like 00223 // the DirectionCoordinate has 2). The number of axes is given 00224 // by the length of the names argument. If you supply a shape, 00225 // it will be used to set the reference pixel to 1/2 the shape. 00226 // If the shape does not have the same number of elements as 00227 // the names variable, the reference pixel will be 0 00228 static void addLinearAxes (CoordinateSystem & coords, 00229 const Vector<String>& names, 00230 const IPosition& shape); 00231 00232 // Add a spectral axis to the user supplied CoordinateSystem. See the 00233 // synopsis above for the current default values. 00234 static void addFreqAxis(CoordinateSystem& coords); 00235 00236 00237 // Add one axis for each of the specified coordinate types. 00238 // Returns the number of axes added. 00239 // If silent==True, existing axes are silently ignored. 00240 // This should really be a method of CoordinateSystem, but the 00241 // code was moved from ImageUtilities which makes heavy use 00242 // of CoordUtil methods (which aren't available to CoordinateSystem) 00243 static uInt addAxes ( 00244 CoordinateSystem& csys, 00245 Bool direction, 00246 Bool spectral, const String& stokes, 00247 Bool linear, Bool tabular, 00248 Bool silent=False 00249 ); 00250 00251 // Return a 2-dimensional coordinate system with RA/DEC axes only. 00252 static CoordinateSystem defaultCoords2D(); 00253 00254 // Return a 3-dimensional coordinate system with RA/DEC axes and a spectral axis. 00255 static CoordinateSystem defaultCoords3D(); 00256 00257 // Return a 4-dimensional coordinate system with RA/DEC axes, an IQUV 00258 // polarisation axis and a spectral axis. 00259 static CoordinateSystem defaultCoords4D(); 00260 00261 // Calls one of the above three functions depending of the arguement. An 00262 // AipsError is thrown if dims is not 2, 3, or 4. 00263 static CoordinateSystem defaultCoords(uInt dims); 00264 00265 // If doLinear=False, Tries to make a standard RA/DEC/Stokes/Frequency CoordinateSystem 00266 // depending upon the shape. The shape for the Stokes axis 00267 // must be <= 4. If axis 2 can't be Stokes it will be a Spectral 00268 // axis instead. AFter the standard types, the rest (if any) 00269 // of the CoordinateSystem consists of LinearCoordinates. 00270 // If doLinear=True, then you just get a linear coordinate system 00271 static CoordinateSystem makeCoordinateSystem(const IPosition& shape, 00272 Bool doLinear=False); 00273 00274 // 00275 // Find which pixel axis in the CoordinateSystem corresponds to the 00276 // SpectralCoordinate. If there is no SpectralCoordinate in the coordinate 00277 // system then return -1. 00278 static Int findSpectralAxis(const CoordinateSystem & coords); 00279 00280 // Find the SpectralCoordinate in the CoordinateSystem, and then 00281 // return the most general description of where it is. 00282 // If there is no SpectralCoordinate in the CoordinateSystem then return 00283 // -1 for coordinate. If the world or pixel axis has been removed, 00284 // return -1 for that value. 00285 static void findSpectralAxis(Int& pixelAxis, Int& worldAxis, Int& coordinate, 00286 const CoordinateSystem & coords); 00287 00288 // Find which pixel axes correspond to the DirectionCoordinate in the 00289 // supplied coordinate system and return this as a Vector. If there is no 00290 // DirectionCoordinate in the CoordinateSystem then return a Vector of zero 00291 // length. Normally the returned Vector will have a length of two. 00292 // However, if the pixel axis has been removed, then the resultant 00293 // vector will take the value -1 for that axis. 00294 static Vector<Int> findDirectionAxes(const CoordinateSystem & coords); 00295 00296 // Find which pixel axes correspond to the DirectionCoordinate in the supplied coordinate 00297 // system and return the most general description of where it is. If there is 00298 // no DirectionCoordinate then coordinate is returned with value -1. 00299 // Values of -1 in the returned vectors indicate an axis has been removed. 00300 static void findDirectionAxes(Vector<Int>& pixelAxes, Vector<Int>& worldAxes, 00301 Int& coordinate, const CoordinateSystem & coords); 00302 00303 // Find which pixel axis is the polarisation axis in the supplied 00304 // CoordinateSystem and return this. If there is no StokesCoordinate in the 00305 // CoordinateSystem return a negative number. The actual polarisations on the 00306 // returned pixel axis are returned in the whichPols Vector. Each element of 00307 // this Vector is a Stokes::StokesTypes enumerator and the length of the Vector 00308 // is the same as the length of the polarisation axis. If there is no 00309 // polarisation axis the whichPols returns a unit length Vector containing 00310 // Stokes::I 00311 static Int findStokesAxis(Vector<Stokes::StokesTypes>& whichPols, 00312 const CoordinateSystem& coords); 00313 00314 // Find the StokesCoordinate in the CoordinateSystem, and then 00315 // return the most general description of where it is. 00316 // If there is no StokesCoordinate in the CoordinateSystem then return 00317 // -1 for coordinate. If the world or pixel axis has been removed, 00318 // return -1 for that value. 00319 static void findStokesAxis(Int& pixelAxis, Int& worldAxis, Int& coordinate, 00320 const CoordinateSystem & coords); 00321 00322 // Find Coordinate type for this pixel or world axis 00323 // <group> 00324 static Coordinate::Type findPixelAxis (const CoordinateSystem& cSys, Int axis); 00325 static Coordinate::Type findWorldAxis (const CoordinateSystem& cSys, Int axis); 00326 // </group> 00327 00328 // Remove a list of world axes and their associated 00329 // pixel axes from a <src>CoordinateSystem</src>. The list of world 00330 // axes to be removed is derived from a list giving either axes to remove, 00331 // or axes to keep (controlled by whether <src>remove</src> 00332 // is <src>True</src> or <src>False</src>. The replacement values (see functions 00333 // <src>CoordinateSystem::removeWorldAxis</src>) for the world axes 00334 // can be given. For the associated pixel axes, the pixel replacement 00335 // coordinate is found by converting the world coordinate 00336 // to a pixel coordinate. If the length of the replacement value 00337 // vector is not the number of world axes to be removed then 00338 // the reference values will be used (e.g. use zero length 00339 // vectors). 00340 static Bool removeAxes(CoordinateSystem& cSys, 00341 Vector<Double>& worldReplacement, 00342 const Vector<Int>& worldAxes, 00343 const Bool remove); 00344 00345 // Remove a list of pixel axes but not their associated 00346 // world axes from a <src>CoordinateSystem</src>. 00347 // The list of pixel axes to be removed is derived from a 00348 // list giving either axes to remove, 00349 // or axes to keep (controlled by whether <src>remove</src> 00350 // is <src>True</src> or <src>False</src>. The replacement values (see functions 00351 // <src>CoordinateSystem::removePixelAxis</src>) for the pixel axes 00352 // can be given. If the length of the replacement value 00353 // vector is not the number of pixel axes to be removed then 00354 // the reference pixel will be used (e.g. use zero length 00355 // vectors). 00356 static Bool removePixelAxes(CoordinateSystem& cSys, 00357 Vector<Double>& pixelReplacement, 00358 const Vector<Int>& pixelAxes, 00359 const Bool remove); 00360 00361 // Physically (nont just virtually) drop coordinates from the CoordinateSystem 00362 // if all axes are fully removed. For coordinates with axes partially removed 00363 // (world/pixel) preserve that removal state in the output CS. No effort 00364 // is made to deal in any way with transposed systems, unless perserveAxesOrder 00365 // is True, and then the ordering of the axes of the output coordinate system 00366 // will be the same as the input cSysIn (sans dropped axes of course). 00367 static Bool dropRemovedAxes ( 00368 CoordinateSystem& cSysOut, const CoordinateSystem& cSysIn, 00369 Bool preserveAxesOrder=False 00370 ); 00371 00372 // Setup Measures conversion machine for MDirections. 00373 // Returns True if the machine was needed and set. Returns False 00374 // if the machine was not needed and not set. 00375 static Bool makeDirectionMachine(LogIO& os, MDirection::Convert& machine, 00376 const DirectionCoordinate& dirCoordTo, 00377 const DirectionCoordinate& dirCoordFrom, 00378 const ObsInfo& obsTo, 00379 const ObsInfo& obsFrom); 00380 00381 // Setup Measures conversion machines for MFrequencies. 00382 // Returns False if a trial conversion failed, else returns True. 00383 // There must be both a Direction and a Spectral 00384 // Coordinate in the CoordinateSystem when making the Frequency machine, 00385 // else an exception occurs. 00386 static Bool makeFrequencyMachine(LogIO& os, MFrequency::Convert& machine, 00387 Int coordinateTo, Int coordinateFrom, 00388 const CoordinateSystem& coordsTo, 00389 const CoordinateSystem& coordsFrom, 00390 const Unit& unit=Unit(String("Hz"))); 00391 00392 // Setup Measures conversion machines for MFrequencies. 00393 // Returns False if a trial conversion failed, else returns True. 00394 static Bool makeFrequencyMachine(LogIO& os, MFrequency::Convert& machine, 00395 MFrequency::Types typeTo, MFrequency::Types typeFrom, 00396 const MDirection& dirTo, const MDirection& dirFrom, 00397 const MEpoch& epochTo, const MEpoch& epochFrom, 00398 const MPosition& posTo, const MPosition& posFrom, 00399 const Unit& unit=Unit(String("Hz"))); 00400 00401 // Find the Sky in the CoordinateSystem. Assumes only one DirectionCoordinate. 00402 // <src>pixelAxes</src> and <src>worldAxes</src> say where 00403 // in the CS the DirectionCoordinate axes are (long then lat). 00404 // Returns False and an error message if it can't find the sky. 00405 static Bool findSky(String& errorMessage, Int& dirCoord, Vector<Int>& pixelAxes, 00406 Vector<Int>& worldAxes, const CoordinateSystem& cSys); 00407 00408 // Do the specified axes hold the sky ? Returns False if no DirectionCoordinate 00409 // or if only one axis of the DirectionCoordinate is held or the specified 00410 // pixel axes don't pertain to the DirectionCoordinate. 00411 static Bool holdsSky (Bool& holdsOneSkyAxis, const CoordinateSystem& cSys, 00412 Vector<Int> pixelAxes); 00413 00414 00415 // Find the Stokes for the specified pixel. If there is no Stokes in the 00416 // CoordinateSystem, returns Stokes::I 00417 static Stokes::StokesTypes findSingleStokes (LogIO& os, const CoordinateSystem& cSys, 00418 uInt pixel=0); 00419 00420 // Set the world axis units in the CS to 'deg' for Direction. For Spectral 00421 // set the velocity handling to use 'km/s' units. Other coordinates 00422 // are not touched. 00423 static void setNiceAxisLabelUnits(CoordinateSystem& cSys); 00424 00425 // Set world axis units for specific Coordinate. Returnd False if fails to set units 00426 // with error in cSys.errorMessage(). 00427 static Bool setCoordinateUnits (CoordinateSystem& cSys, const Vector<String>& units, 00428 uInt which); 00429 00430 // Set a unit for all unremoved world axes in the DirectionCoordinate in the 00431 // CS. Returns False if fails to set unit with error in cSys. If no DC 00432 // returns True 00433 static Bool setDirectionUnit (CoordinateSystem& cSys, const String& unit, Int which=-1); 00434 00435 // Set Direction conversion layer of DirectionCoordinate in CoordinateSystem 00436 // so that pixel<->world go to the specified direction system (a valid 00437 // MDirection::Types string). Returns False with error if direction 00438 // system invalid. If no DirectionCoordinate returns True 00439 static Bool setDirectionConversion (String& errorMsg, CoordinateSystem& cSys, 00440 const String directionSystem); 00441 00442 // Set spectral state of SpectralCoordinate in CoordinateSystem. 00443 // Unit must be consistent with Hz or m/s and the doppler a valid MDoppler string. 00444 // For no change, leave either String empty. 00445 // Returns False if invalid inputs (and CS not changed) and an error message. 00446 static Bool setSpectralState (String& errorMsg, CoordinateSystem& cSys, 00447 const String& unit, const String& spcquant); 00448 00449 // Set velocity state of SpectralCoordinate in CoordinateSystem. 00450 // Unit must be consistent m/s and the doppler a valid MDoppler string. 00451 // For no change, leave either String empty. 00452 // Returns False if invalid inputs (and CS not changed) and an error message. 00453 static Bool setVelocityState (String& errorMsg, CoordinateSystem& cSys, 00454 const String& unit, const String& spcquant); 00455 00456 //#/// Kept setRestFrequency for CASA-4.2 00457 // Does the CoordinateSystem hold just the sky? 00458 // Returns True if CS pixel axis 0 is the longitude and 1 latitude 00459 // else returns False 00460 static Bool isSky (LogIO& os, const CoordinateSystem& cSys); 00461 00462 //#/// Kept setRestFrequency for CASA-4.2 00463 // Set rest frequency of SpectralCoordinate in CoordinateSystem. 00464 // Unit must be consistent with Hz or m. 00465 // Returns False if invalid inputs (and CS not changed) and an error message. 00466 static Bool setRestFrequency (String& errorMsg, CoordinateSystem& cSys, 00467 const String& unit, 00468 const Double& value); 00469 00470 //#/// Kept setSpectralConversion for old casarest 00471 // Set Spectral conversion layer of SpectralCoordinate in CoordinateSystem 00472 // so that pixel<->world go to the specified frequency system (a valid 00473 // MFrequency::Types string). Returns False if frequency system invalid 00474 // or if no DirectionCoordinate or if cant get Date/Epoch 00475 static Bool setSpectralConversion (String& errorMsg, CoordinateSystem& cSys, 00476 const String frequencySystem); 00477 00478 // Set default format unit and doppler velocity state of SpectralCoordinate in CoordinateSystem. 00479 // Unit can be consistent with Hz or m/s 00480 // Returns False if invalid inputs (and CS not changed) and an error message. 00481 static Bool setSpectralFormatting (String& errorMsg, CoordinateSystem& cSys, 00482 const String& unit, const String& spcquant); 00483 00484 // Convert an absolute pixel coordinate to world and format with 00485 // default Coordinate formatting 00486 // <group> 00487 static String formatCoordinate(const IPosition& pixel, const CoordinateSystem& cSys, Int precision = -1); 00488 static String formatCoordinate(const Vector<Double>& pixel, const CoordinateSystem& cSys, Int precision = -1); 00489 // </group> 00490 00491 // Generate axis label String from coordinate. Specify coordinate axis, 00492 // whether world or pixel labels required, whether absolute or 00493 // relative. For spectral coordinates, doVel says if you want to 00494 // use the velocity information contained in it to generate the label 00495 static String axisLabel (const Coordinate& coord, uInt axisInCoordinate=0, 00496 Bool doWorld=True, Bool doAbs=True, Bool doVel=False); 00497 00498 // <group name=Coordinate comparison> 00499 // Check how the coordinates of this and that compare. 00500 // The return value tells how they compare. 00501 // <br>-1: left is subset 00502 // <br>0: equal 00503 // <br>1: left is superset 00504 // <br>9: invalid (mismatch) 00505 static Int compareCoordinates (const CoordinateSystem& thisCsys, 00506 const CoordinateSystem& thatCsys); 00507 00508 // Convert the world axes map given in worldAxes to a pixel axes map. 00509 static Vector<Int> toPixelAxes (const CoordinateSystem& thisCsys, 00510 const CoordinateSystem& thatCsys, 00511 const Vector<Int>& worldAxes); 00512 00513 // Check if the axes in the pixel axes map are in ascending order. 00514 static Bool checkOrder (const Vector<Int>& pixelAxes); 00515 00516 // Find the new and stretch axes when comparing the old and new 00517 // coordinates and shapes (helper for ExtendImage). 00518 static Bool findExtendAxes (IPosition& newAxes, 00519 IPosition& stretchAxes, 00520 const IPosition& newShape, 00521 const IPosition& oldShape, 00522 const CoordinateSystem& newCsys, 00523 const CoordinateSystem& oldCsys); 00524 // </group> 00525 00526 // Fix up Cylindrical parameters in any DirectionCoordinate for when the longitude 00527 // is outside of [-180,180] range. If it returns False, it failed and an error 00528 // message is returned as well. This function should be called on any 00529 // CS made from an imported image like FITS 00530 static Bool cylindricalFix (CoordinateSystem& cSys, String& errorMessage, const IPosition& shape); 00531 00532 // Apply the binning factors to the CS and create a new one reflecting the binning 00533 // You can optionally throw an exception if factors is non-unit for any Stokes axis 00534 static CoordinateSystem makeBinnedCoordinateSystem (const IPosition& factors, 00535 const CoordinateSystem& cSysIn, 00536 Bool failOnStokes=False); 00537 private: 00538 // Sets pos to the position found for tel in the database, or 00539 // raises an exception + error message. 00540 static void findObservatoryOrRaiseException(LogIO& os, MPosition& pos, 00541 const String& tel); 00542 }; 00543 00544 00545 } //# NAMESPACE CASACORE - END 00546 00547 #endif