casacore
CoordinateUtil.h
Go to the documentation of this file.
1 //# CoordinateUtils.h: static functions dealing with coordinates
2 //# Copyright (C) 1997,1998,1999,2000,2001,2002,2004
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef COORDINATES_COORDINATEUTIL_H
29 #define COORDINATES_COORDINATEUTIL_H
30 
31 
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/Arrays/Vector.h>
34 #include <casacore/measures/Measures/Stokes.h>
35 #include <casacore/coordinates/Coordinates/Coordinate.h>
36 
37 #include <casacore/measures/Measures/MDirection.h> //# For enums
38 #include <casacore/measures/Measures/MFrequency.h>
39 #include <casacore/measures/Measures/MeasConvert.h>
40 
41 namespace casacore { //# NAMESPACE CASACORE - BEGIN
42 
43 class CoordinateSystem;
44 class DirectionCoordinate;
45 class ObsInfo;
46 class String;
47 class LogIO;
48 class MEpoch;
49 class MPosition;
50 class Unit;
51 
52 
53 // <summary>Functions for creating default CoordinateSystems</summary>
54 // <use visibility=export>
55 
56 // <reviewed reviewer="" date="" tests="" demos="">
57 // </reviewed>
58 
59 // <prerequisite>
60 // <li> <linkto class="CoordinateSystem">CoordinateSystem</linkto>
61 // </prerequisite>
62 //
63 // <etymology>
64 // CoordinateUtils follows the Casacore naming convention for static functions
65 // that are associated with a class.
66 // </etymology>
67 //
68 // <synopsis>
69 // This file contains declarations for static functions that manipulate
70 // coordinate systems. It currently contains functions for:
71 // <ul>
72 // <li> Adding default axes to a CoordinateSystem
73 // <li> Creating a default CoordinateSystem
74 // <li> Finding specified axes in a CoordinateSystem
75 // </ul>
76 //
77 // The functions for adding default axes to a CoordinateSystem can add
78 // either a RA/DEC pair of axes, a Polarisation Axis, or a Spectral Axis to
79 // a user supplied coordinate system. The default values for these functions
80 // are:
81 // <ul>
82 // <li> <src>addDirAxes</src> this adds a DirectionCoordinate with a
83 // reference pixel of (0,0) corresponding to an RA/DEC of (0,0) in a
84 // J2000 reference frame. The pixel increment is 1 arc-minute.
85 // <li> <src>addIQUVAxis</src> this adds a polarization axis with four
86 // elements corresponding to the Stokes (I,Q,U,V) components.
87 // <li> <src>addIAxis</src> this adds a polarization axis with one
88 // element corresponding to the Stokes I component only
89 // <li> <src>addFreqAxis</src> this adds a spectral axis with a reference
90 // frequency of 1.415GHz on channel 0. The channel bandwidth (pixel
91 // increment) is 1kHz, and the reference frame is the kinematical Local Standard of
92 // rest (<linkto class="MFrequency">MFrequency</linkto>::LSRK).
93 // </ul>
94 //
95 // The <src>defaultCoords</src> functions, create from scratch a
96 // CoordinateSystem using the above described <src>addXXXAxis</src>
97 // functions to add the required number of dimensions to the
98 // CoordinateSystem. Only 2, 3 or 4 dimensional coordinate systems can be
99 // constructed using these functions. The coordinate systems always have
100 // RA/Dec axes. Three dimensional Systems add a spectral axis and
101 // four-dimensional systems add an IQUV polarization axis. An exception
102 // (AipsError) is thrown if <src>defaultCoords(uInt)</src> is called with a
103 // parameter that is not 2, 3, or 4.
104 //
105 // The <src>defaultCoordsXX</src> functions return the coordinate system by
106 // value (which involves a copy of the CoordinateSystem) and hence are not
107 // as effcient as the <src>addXXXAxis</src> functions.
108 //
109 // If the default axes provided by these functions are not quite what is
110 // required it is possible to use member functions of the
111 // <linkto class="CoordinateSystem">CoordinateSystem</linkto>
112 // and <linkto class="Coordinate">Coordinate</linkto> classes
113 // (<linkto class="DirectionCoordinate">DirectionCoordinate</linkto>,
114 // <linkto class="StokesCoordinate">StokesCoordinate</linkto>,
115 // <linkto class="SpectralCoordinate">SpectralCoordinate</linkto> etc.)
116 // to tweak the appropriate parameters of the specified axis.
117 //
118 // Now we turn to the functions for finding axes in a CoordinateSystem. With
119 // a CoordinateSystem object it is not required that the first Coordinate
120 // axis in the the CoordinateSystem map to the first pixel axis in an
121 // image. Hence it is necessary to determine which pixel axis corresponds to a
122 // specified Coordinate and this can be done using these functions. Some
123 // coordinate types, in particular DirectionCoordinate, usually map to more
124 // than one pixel axis (DirectionsCoordinates are inherently two-dimensional).
125 //
126 // This group contains declarations for static functions that search
127 // CoordinateSystem's for a coordinate of the specified type. It returns the
128 // pixel axis (zero relative) of the specified coordinate type. If the supplied
129 // Coordinate system does not contain the specified coordinate type the
130 // returned value is function specific (but usually -1). If the supplied
131 // CoordinateSystem contains two or more of the specified coordinateType then
132 // an exception (AipsError) is thrown.
133 //
134 // Finally functions are provided for removing lists of pixel/world axes
135 // from a CoordinateSystem.
136 // This process is made a little awkward by the fact that when you
137 // remove one axis, all the rest shuffle down one, so it is
138 // provided here. Generally, one only needs to remove one axis
139 // (in which case you should use the CoordinateSystem::removeWorldAxis and
140 // CoordinateSystem::removcePixelAxis functions), but on occaision,
141 // the multiple need is there.
142 // </synopsis>
143 //
144 // <example>
145 // I use these functions when creating test images.
146 // <srcblock>
147 // PagedImage(IPosition(4,256,256,4,32), CoordinateUtil::defaultCoords4D(),
148 // String("test.image"));
149 // </srcblock>
150 // </example>
151 //
152 // <example>
153 // Functions are needed to handle images without specifying a canonical
154 // coordinate order. For example suppose we want to find the spectral aixs
155 // of a PagedImage object.
156 //
157 // <srcblock>
158 // const Int spectralAxis = CoordinateUtil::findSpectralAxis(image.coordinates());
159 // cout << "The spectral axis is of shape " << image.shape()(spectralAxis) << endl;
160 // </srcblock>
161 // </example>
162 //
163 // <example>
164 // Here we remove the first and last world axes, and their associated
165 // pixel axes from a 3D CoordinateSystem. The reference values and
166 // reference pixels are used for the replacement values.
167 //
168 // <srcblock>
169 // CoordinateSystem cSys = CoordinateUtil::defaultCoords3D();
170 // Vector<Int> worldAxes(2);
171 // worldAxes(0) = 0; worldAxes(1) = cSys.nWorldAxes()-1;
172 // Vector<Double> worldRep;
173 // Bool ok = CoordinateUtil::removeAxes(cSys, worldRep, worldAxes, True);
174 // cout << "For world axes used " << worldRep << " for replacement" << endl;
175 // </srcblock>
176 // </example>
177 //
178 //
179 // <motivation>
180 // I got fed up writing small functions to create and find coordinates when writing
181 // test programs involving Images and ComponentModels.
182 // </motivation>
183 //
184 // <thrown>
185 // <li> AipsError
186 // </thrown>
187 //
188 // <todo asof="1997/01/23">
189 // Many of these methods belong in the CoordinateSystem class,
190 // eg all the add* methods, and in fact CoordinateSystem already has analogs
191 // for many of them. The factory methods which create a CoordinateSystem
192 // could also arguably go in CoordinateSystem as static methods. Having a separate
193 // utility class that really just has methods that operate on or create CoordinateSystem
194 // objects makes no sense. CoordinateUtil is the antithesis of object oriented design,
195 // and we need to endeavor to expunge it from our system.
196 // </todo>
197 
198 // <linkfrom anchor=defaultAxes classes="CoordinateSystem">
199 // Static functions for creating <here>default</here> coordinate systems
200 // </linkfrom>
201 
203 {
204 public:
205 
206 // Add a RA/DEC pair of direction axes (ie. a DirectionCoordinate) to the
207 // user supplied CoordinateSystem. See the synopsis above for the current
208 // default values.
209 static void addDirAxes(CoordinateSystem& coords);
210 
211 // Add a Stokes I,Q,U,V axis to the user supplied CoordinateSystem.
212 static void addIQUVAxis(CoordinateSystem& coords);
213 
214 // Add a Stokes I (only) axis to the user supplied CoordinateSystem.
215 static void addIAxis(CoordinateSystem& coords);
216 
217 // Add a Stokes axis of length 1 to 4 selected from I,Q,U,V
218 // E.g. if shape=2 you get IQ. Returns False if shape
219 // is not in the range 1 to 4
221 
222 // Add Linear axes. The LinearCoordinate can have > 1 axes (like
223 // the DirectionCoordinate has 2). The number of axes is given
224 // by the length of the names argument. If you supply a shape,
225 // it will be used to set the reference pixel to 1/2 the shape.
226 // If the shape does not have the same number of elements as
227 // the names variable, the reference pixel will be 0
228 static void addLinearAxes (CoordinateSystem & coords,
229  const Vector<String>& names,
230  const IPosition& shape);
231 
232 // Add a spectral axis to the user supplied CoordinateSystem. See the
233 // synopsis above for the current default values.
234 static void addFreqAxis(CoordinateSystem& coords);
235 
236 
237 // Add one axis for each of the specified coordinate types.
238 // Returns the number of axes added.
239 // If silent==True, existing axes are silently ignored.
240 // This should really be a method of CoordinateSystem, but the
241 // code was moved from ImageUtilities which makes heavy use
242 // of CoordUtil methods (which aren't available to CoordinateSystem)
243 static uInt addAxes (
244  CoordinateSystem& csys,
245  Bool direction,
246  Bool spectral, const String& stokes,
247  Bool linear, Bool tabular,
248  Bool silent=False
249 );
250 
251 // Return a 2-dimensional coordinate system with RA/DEC axes only.
253 
254 // Return a 3-dimensional coordinate system with RA/DEC axes and a spectral axis.
256 
257 // Return a 4-dimensional coordinate system with RA/DEC axes, an IQUV
258 // polarisation axis and a spectral axis.
260 
261 // Calls one of the above three functions depending of the arguement. An
262 // AipsError is thrown if dims is not 2, 3, or 4.
264 
265 // If doLinear=False, Tries to make a standard RA/DEC/Stokes/Frequency CoordinateSystem
266 // depending upon the shape. The shape for the Stokes axis
267 // must be <= 4. If axis 2 can't be Stokes it will be a Spectral
268 // axis instead. AFter the standard types, the rest (if any)
269 // of the CoordinateSystem consists of LinearCoordinates.
270 // If doLinear=True, then you just get a linear coordinate system
272  Bool doLinear=False);
273 
274 //
275 // Find which pixel axis in the CoordinateSystem corresponds to the
276 // SpectralCoordinate. If there is no SpectralCoordinate in the coordinate
277 // system then return -1.
278 static Int findSpectralAxis(const CoordinateSystem & coords);
279 
280 // Find the SpectralCoordinate in the CoordinateSystem, and then
281 // return the most general description of where it is.
282 // If there is no SpectralCoordinate in the CoordinateSystem then return
283 // -1 for coordinate. If the world or pixel axis has been removed,
284 // return -1 for that value.
285 static void findSpectralAxis(Int& pixelAxis, Int& worldAxis, Int& coordinate,
286  const CoordinateSystem & coords);
287 
288 // Find which pixel axes correspond to the DirectionCoordinate in the
289 // supplied coordinate system and return this as a Vector. If there is no
290 // DirectionCoordinate in the CoordinateSystem then return a Vector of zero
291 // length. Normally the returned Vector will have a length of two.
292 // However, if the pixel axis has been removed, then the resultant
293 // vector will take the value -1 for that axis.
295 
296 // Find which pixel axes correspond to the DirectionCoordinate in the supplied coordinate
297 // system and return the most general description of where it is. If there is
298 // no DirectionCoordinate then coordinate is returned with value -1.
299 // Values of -1 in the returned vectors indicate an axis has been removed.
300 static void findDirectionAxes(Vector<Int>& pixelAxes, Vector<Int>& worldAxes,
301  Int& coordinate, const CoordinateSystem & coords);
302 
303 // Find which pixel axis is the polarisation axis in the supplied
304 // CoordinateSystem and return this. If there is no StokesCoordinate in the
305 // CoordinateSystem return a negative number. The actual polarisations on the
306 // returned pixel axis are returned in the whichPols Vector. Each element of
307 // this Vector is a Stokes::StokesTypes enumerator and the length of the Vector
308 // is the same as the length of the polarisation axis. If there is no
309 // polarisation axis the whichPols returns a unit length Vector containing
310 // Stokes::I
312  const CoordinateSystem& coords);
313 
314 // Find the StokesCoordinate in the CoordinateSystem, and then
315 // return the most general description of where it is.
316 // If there is no StokesCoordinate in the CoordinateSystem then return
317 // -1 for coordinate. If the world or pixel axis has been removed,
318 // return -1 for that value.
319 static void findStokesAxis(Int& pixelAxis, Int& worldAxis, Int& coordinate,
320  const CoordinateSystem & coords);
321 
322 // Find Coordinate type for this pixel or world axis
323 // <group>
326 // </group>
327 
328 // Remove a list of world axes and their associated
329 // pixel axes from a <src>CoordinateSystem</src>. The list of world
330 // axes to be removed is derived from a list giving either axes to remove,
331 // or axes to keep (controlled by whether <src>remove</src>
332 // is <src>True</src> or <src>False</src>. The replacement values (see functions
333 // <src>CoordinateSystem::removeWorldAxis</src>) for the world axes
334 // can be given. For the associated pixel axes, the pixel replacement
335 // coordinate is found by converting the world coordinate
336 // to a pixel coordinate. If the length of the replacement value
337 // vector is not the number of world axes to be removed then
338 // the reference values will be used (e.g. use zero length
339 // vectors).
341  Vector<Double>& worldReplacement,
342  const Vector<Int>& worldAxes,
343  const Bool remove);
344 
345 // Remove a list of pixel axes but not their associated
346 // world axes from a <src>CoordinateSystem</src>.
347 // The list of pixel axes to be removed is derived from a
348 // list giving either axes to remove,
349 // or axes to keep (controlled by whether <src>remove</src>
350 // is <src>True</src> or <src>False</src>. The replacement values (see functions
351 // <src>CoordinateSystem::removePixelAxis</src>) for the pixel axes
352 // can be given. If the length of the replacement value
353 // vector is not the number of pixel axes to be removed then
354 // the reference pixel will be used (e.g. use zero length
355 // vectors).
357  Vector<Double>& pixelReplacement,
358  const Vector<Int>& pixelAxes,
359  const Bool remove);
360 
361 // Physically (nont just virtually) drop coordinates from the CoordinateSystem
362 // if all axes are fully removed. For coordinates with axes partially removed
363 // (world/pixel) preserve that removal state in the output CS. No effort
364 // is made to deal in any way with transposed systems, unless perserveAxesOrder
365 // is True, and then the ordering of the axes of the output coordinate system
366 // will be the same as the input cSysIn (sans dropped axes of course).
368  CoordinateSystem& cSysOut, const CoordinateSystem& cSysIn,
369  Bool preserveAxesOrder=False
370 );
371 
372 // Setup Measures conversion machine for MDirections.
373 // Returns True if the machine was needed and set. Returns False
374 // if the machine was not needed and not set.
376  const DirectionCoordinate& dirCoordTo,
377  const DirectionCoordinate& dirCoordFrom,
378  const ObsInfo& obsTo,
379  const ObsInfo& obsFrom);
380 
381 // Setup Measures conversion machines for MFrequencies.
382 // Returns False if a trial conversion failed, else returns True.
383 // There must be both a Direction and a Spectral
384 // Coordinate in the CoordinateSystem when making the Frequency machine,
385 // else an exception occurs.
387  Int coordinateTo, Int coordinateFrom,
388  const CoordinateSystem& coordsTo,
389  const CoordinateSystem& coordsFrom,
390  const Unit& unit=Unit(String("Hz")));
391 
392 // Setup Measures conversion machines for MFrequencies.
393 // Returns False if a trial conversion failed, else returns True.
395  MFrequency::Types typeTo, MFrequency::Types typeFrom,
396  const MDirection& dirTo, const MDirection& dirFrom,
397  const MEpoch& epochTo, const MEpoch& epochFrom,
398  const MPosition& posTo, const MPosition& posFrom,
399  const Unit& unit=Unit(String("Hz")));
400 
401 // Find the Sky in the CoordinateSystem. Assumes only one DirectionCoordinate.
402 // <src>pixelAxes</src> and <src>worldAxes</src> say where
403 // in the CS the DirectionCoordinate axes are (long then lat).
404 // Returns False and an error message if it can't find the sky.
405  static Bool findSky(String& errorMessage, Int& dirCoord, Vector<Int>& pixelAxes,
406  Vector<Int>& worldAxes, const CoordinateSystem& cSys);
407 
408 // Do the specified axes hold the sky ? Returns False if no DirectionCoordinate
409 // or if only one axis of the DirectionCoordinate is held or the specified
410 // pixel axes don't pertain to the DirectionCoordinate.
411  static Bool holdsSky (Bool& holdsOneSkyAxis, const CoordinateSystem& cSys,
412  Vector<Int> pixelAxes);
413 
414 
415 // Find the Stokes for the specified pixel. If there is no Stokes in the
416 // CoordinateSystem, returns Stokes::I
418  uInt pixel=0);
419 
420 // Set the world axis units in the CS to 'deg' for Direction. For Spectral
421 // set the velocity handling to use 'km/s' units. Other coordinates
422 // are not touched.
424 
425 // Set world axis units for specific Coordinate. Returnd False if fails to set units
426 // with error in cSys.errorMessage().
428  uInt which);
429 
430 // Set a unit for all unremoved world axes in the DirectionCoordinate in the
431 // CS. Returns False if fails to set unit with error in cSys. If no DC
432 // returns True
433  static Bool setDirectionUnit (CoordinateSystem& cSys, const String& unit, Int which=-1);
434 
435 // Set Direction conversion layer of DirectionCoordinate in CoordinateSystem
436 // so that pixel<->world go to the specified direction system (a valid
437 // MDirection::Types string). Returns False with error if direction
438 // system invalid. If no DirectionCoordinate returns True
440  const String directionSystem);
441 
442 // Set spectral state of SpectralCoordinate in CoordinateSystem.
443 // Unit must be consistent with Hz or m/s and the doppler a valid MDoppler string.
444 // For no change, leave either String empty.
445 // Returns False if invalid inputs (and CS not changed) and an error message.
446  static Bool setSpectralState (String& errorMsg, CoordinateSystem& cSys,
447  const String& unit, const String& spcquant);
448 
449 // Set velocity state of SpectralCoordinate in CoordinateSystem.
450 // Unit must be consistent m/s and the doppler a valid MDoppler string.
451 // For no change, leave either String empty.
452 // Returns False if invalid inputs (and CS not changed) and an error message.
453  static Bool setVelocityState (String& errorMsg, CoordinateSystem& cSys,
454  const String& unit, const String& spcquant);
455 
456  //#/// Kept setRestFrequency for CASA-4.2
457 // Does the CoordinateSystem hold just the sky?
458 // Returns True if CS pixel axis 0 is the longitude and 1 latitude
459 // else returns False
460  static Bool isSky (LogIO& os, const CoordinateSystem& cSys);
461 
462  //#/// Kept setRestFrequency for CASA-4.2
463 // Set rest frequency of SpectralCoordinate in CoordinateSystem.
464 // Unit must be consistent with Hz or m.
465 // Returns False if invalid inputs (and CS not changed) and an error message.
466  static Bool setRestFrequency (String& errorMsg, CoordinateSystem& cSys,
467  const String& unit,
468  const Double& value);
469 
470  //#/// Kept setSpectralConversion for old casarest
471 // Set Spectral conversion layer of SpectralCoordinate in CoordinateSystem
472 // so that pixel<->world go to the specified frequency system (a valid
473 // MFrequency::Types string). Returns False if frequency system invalid
474 // or if no DirectionCoordinate or if cant get Date/Epoch
476  const String frequencySystem);
477 
478 // Set default format unit and doppler velocity state of SpectralCoordinate in CoordinateSystem.
479 // Unit can be consistent with Hz or m/s
480 // Returns False if invalid inputs (and CS not changed) and an error message.
482  const String& unit, const String& spcquant);
483 
484 // Convert an absolute pixel coordinate to world and format with
485 // default Coordinate formatting
486 // <group>
487  static String formatCoordinate(const IPosition& pixel, const CoordinateSystem& cSys, Int precision = -1);
488  static String formatCoordinate(const Vector<Double>& pixel, const CoordinateSystem& cSys, Int precision = -1);
489 // </group>
490 
491 // Generate axis label String from coordinate. Specify coordinate axis,
492 // whether world or pixel labels required, whether absolute or
493 // relative. For spectral coordinates, doVel says if you want to
494 // use the velocity information contained in it to generate the label
495  static String axisLabel (const Coordinate& coord, uInt axisInCoordinate=0,
496  Bool doWorld=True, Bool doAbs=True, Bool doVel=False);
497 
498  // <group name=Coordinate comparison>
499  // Check how the coordinates of this and that compare.
500  // The return value tells how they compare.
501  // <br>-1: left is subset
502  // <br>0: equal
503  // <br>1: left is superset
504  // <br>9: invalid (mismatch)
505  static Int compareCoordinates (const CoordinateSystem& thisCsys,
506  const CoordinateSystem& thatCsys);
507 
508  // Convert the world axes map given in worldAxes to a pixel axes map.
509  static Vector<Int> toPixelAxes (const CoordinateSystem& thisCsys,
510  const CoordinateSystem& thatCsys,
511  const Vector<Int>& worldAxes);
512 
513  // Check if the axes in the pixel axes map are in ascending order.
514  static Bool checkOrder (const Vector<Int>& pixelAxes);
515 
516  // Find the new and stretch axes when comparing the old and new
517  // coordinates and shapes (helper for ExtendImage).
518  static Bool findExtendAxes (IPosition& newAxes,
519  IPosition& stretchAxes,
520  const IPosition& newShape,
521  const IPosition& oldShape,
522  const CoordinateSystem& newCsys,
523  const CoordinateSystem& oldCsys);
524  // </group>
525 
526  // Fix up Cylindrical parameters in any DirectionCoordinate for when the longitude
527  // is outside of [-180,180] range. If it returns False, it failed and an error
528  // message is returned as well. This function should be called on any
529  // CS made from an imported image like FITS
530  static Bool cylindricalFix (CoordinateSystem& cSys, String& errorMessage, const IPosition& shape);
531 
532  // Apply the binning factors to the CS and create a new one reflecting the binning
533  // You can optionally throw an exception if factors is non-unit for any Stokes axis
535  const CoordinateSystem& cSysIn,
536  Bool failOnStokes=False);
537 private:
538  // Sets pos to the position found for tel in the database, or
539  // raises an exception + error message.
541  const String& tel);
542 };
543 
544 
545 } //# NAMESPACE CASACORE - END
546 
547 #endif
static String axisLabel(const Coordinate &coord, uInt axisInCoordinate=0, Bool doWorld=True, Bool doAbs=True, Bool doVel=False)
Generate axis label String from coordinate.
static void addFreqAxis(CoordinateSystem &coords)
Add a spectral axis to the user supplied CoordinateSystem.
static Int compareCoordinates(const CoordinateSystem &thisCsys, const CoordinateSystem &thatCsys)
static CoordinateSystem defaultCoords2D()
Return a 2-dimensional coordinate system with RA/DEC axes only.
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 wh...
static Bool setSpectralConversion(String &errorMsg, CoordinateSystem &cSys, const String frequencySystem)
Set Spectral conversion layer of SpectralCoordinate in CoordinateSystem so that pixel<->world go to t...
static void addIQUVAxis(CoordinateSystem &coords)
Add a Stokes I,Q,U,V axis to the user supplied CoordinateSystem.
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 ...
static void addLinearAxes(CoordinateSystem &coords, const Vector< String > &names, const IPosition &shape)
Add Linear axes.
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 Exten...
static Vector< Int > findDirectionAxes(const CoordinateSystem &coords)
Find which pixel axes correspond to the DirectionCoordinate in the supplied coordinate system and ret...
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 ret...
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.
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,...
static Bool setVelocityState(String &errorMsg, CoordinateSystem &cSys, const String &unit, const String &spcquant)
Set velocity state of SpectralCoordinate in CoordinateSystem.
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.
static void addDirAxes(CoordinateSystem &coords)
Add a RA/DEC pair of direction axes (ie.
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.
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.
static Bool findSky(String &errorMessage, Int &dirCoord, Vector< Int > &pixelAxes, Vector< Int > &worldAxes, const CoordinateSystem &cSys)
Find the Sky in the CoordinateSystem.
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.
static void findObservatoryOrRaiseException(LogIO &os, MPosition &pos, const String &tel)
Sets pos to the position found for tel in the database, or raises an exception + error message.
static Bool addStokesAxis(CoordinateSystem &coords, uInt shape)
Add a Stokes axis of length 1 to 4 selected from I,Q,U,V E.g.
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.
static Bool setRestFrequency(String &errorMsg, CoordinateSystem &cSys, const String &unit, const Double &value)
Set rest frequency of SpectralCoordinate in CoordinateSystem.
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.
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.
static Bool setCoordinateUnits(CoordinateSystem &cSys, const Vector< String > &units, uInt which)
Set world axis units for specific Coordinate.
static CoordinateSystem defaultCoords3D()
Return a 3-dimensional coordinate system with RA/DEC axes and a spectral axis.
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 t...
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 l...
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.
static Bool checkOrder(const Vector< Int > &pixelAxes)
Check if the axes in the pixel axes map are in ascending order.
static Coordinate::Type findPixelAxis(const CoordinateSystem &cSys, Int axis)
Find Coordinate type for this pixel or world axis.
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.
static Bool setDirectionConversion(String &errorMsg, CoordinateSystem &cSys, const String directionSystem)
Set Direction conversion layer of DirectionCoordinate in CoordinateSystem so that pixel<->world go to...
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.
static Bool setSpectralState(String &errorMsg, CoordinateSystem &cSys, const String &unit, const String &spcquant)
Set spectral state of SpectralCoordinate in CoordinateSystem.
static void setNiceAxisLabelUnits(CoordinateSystem &cSys)
Set the world axis units in the CS to 'deg' for Direction.
static Coordinate::Type findWorldAxis(const CoordinateSystem &cSys, Int axis)
static void addIAxis(CoordinateSystem &coords)
Add a Stokes I (only) axis to the user supplied CoordinateSystem.
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 th...
static Int findSpectralAxis(const CoordinateSystem &coords)
Find which pixel axis in the CoordinateSystem corresponds to the SpectralCoordinate.
static CoordinateSystem makeCoordinateSystem(const IPosition &shape, Bool doLinear=False)
If doLinear=False, Tries to make a standard RA/DEC/Stokes/Frequency CoordinateSystem depending upon t...
static String formatCoordinate(const Vector< Double > &pixel, const CoordinateSystem &cSys, Int precision=-1)
static CoordinateSystem defaultCoords(uInt dims)
Calls one of the above three functions depending of the arguement.
static CoordinateSystem defaultCoords4D()
Return a 4-dimensional coordinate system with RA/DEC axes, an IQUV polarisation axis and a spectral a...
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 rem...
static Stokes::StokesTypes findSingleStokes(LogIO &os, const CoordinateSystem &cSys, uInt pixel=0)
Find the Stokes for the specified pixel.
Type
This enum lists the types of the derived classes.
Definition: Coordinate.h:144
Types
Types of known MFrequencies Warning: The order defines the order in the translation matrix FromTo in...
Definition: MFrequency.h:176
StokesTypes
The Stokes types are defined by this enum.
Definition: Stokes.h:66
String: the storage and methods of handling collections of characters.
Definition: String.h:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
const Bool False
Definition: aipstype.h:44
unsigned int uInt
Definition: aipstype.h:51
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
Definition: ExprNode.h:1987
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
const Bool True
Definition: aipstype.h:43
double Double
Definition: aipstype.h:55