casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Coordinate.h
Go to the documentation of this file.
1 //# Coordinate.h: Interface for converting between world and pixel coordinates
2 //# Copyright (C) 1997,1999,2000,2001,2002,2003,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 //#
27 //# $Id$
28 
29 
30 #ifndef COORDINATES_COORDINATE_H
31 #define COORDINATES_COORDINATE_H
32 
33 #include <casacore/casa/aips.h>
36 #include <wcslib/wcs.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 
41 template<class T> class Quantum;
42 template<class T> class Matrix;
43 class IPosition;
44 class RecordInterface;
45 class Projection;
46 
47 // <summary>
48 // Interface for converting between world and pixel coordinates.
49 // </summary>
50 
51 // <use visibility=export>
52 
53 // <reviewed reviewer="Peter Barnes" date="1999/12/24">
54 // </reviewed>
55 
56 // <prerequisite>
57 // <li> Knowledge of astronomical coordinate conversions in general. Probably the
58 // best documents are the papers by Mark Calabretta and Eric Greisen.
59 // The initial draft from 1996 can be found at
60 // http://www.atnf.csiro.au/~mcalabre. It is this draft that the
61 // Coordinate classes are based upon. Since then, this paper has evolved
62 // into three which can be found at the above address, and will be published in the
63 // Astronomy and Astrophysics Supplement Series (probably in 2000).
64 // The design has changed since the initial draft. When these papers
65 // are finalized, and the IAU has ratified the new standards, WCSLIB
66 // (Mark Calabretta's implementation of these conventions) will be
67 // revised for the new designs. At that time, the Coordinate classes
68 // may also be revised.
69 // <li> Generic Casacore classes; especially those in the
70 // <linkto module=Arrays>Arrays</linkto> module.
71 // <li> Perhaps some of the information in the
72 // <linkto module=Measures>Measures</linkto> module.
73 // </prerequisite>
74 //
75 // <synopsis>
76 // The Coordinate class defines the generic interface whereby a pixel position
77 // is converted to a world (sky, frequency, stokes, ...) position and vice
78 // versa. The pixel and world coordinates are in general
79 // multi-dimensional values. In general there need not be the same number of
80 // pixel and world axes, although this will normally be the case.
81 //
82 // The fundamental model is that a pixel is first converted into a relative
83 // physical coordinate by:
84 // <ol>
85 // <li> Subtracting a reference pixel value from the pixel location; then
86 // <li> Multiplying this offset by a general transformation matrix (usually
87 // to account for rotation, but any matrix is allowed); then
88 // <li> Multiplying this product by an increment in physical units.
89 // </ol>
90 // After this linear stage, the final coordinate value is computed from this
91 // relative physical unit and a reference value, and possibly some other
92 // parameters. In the case of a sky position, these latter include at least the
93 // projection type. In the case of a purely linear coordinate, the reference value
94 // is merely added to the relative physical coordinate. The interface also
95 // allows the axes to be assigned names (reasonable defaults will be selected),
96 // and for physical units.
97 //
98 // Both absolute and relative coordinates are supported. The main
99 // interface supports conversion between absolute pixel
100 // and absolute world coordinate. There are then functions to
101 // convert absolute coordinates to relative and vice versa.
102 // A relative pixel coordinate is defined according to
103 //
104 // relative = absolute - reference
105 //
106 // A relative world coordinate is similar, although there may
107 // be deviations from this formula (e.g. for DirectionCoordinate
108 // a cos(latitude) term is incorporated and for StokesCoordinate
109 // relative world coordinates are defined to be the same as
110 // absolute world coordinates.
111 //
112 // </synopsis>
113 //
114 // <note role=caution>
115 // All absolute pixels coordinates are zero relative.
116 // </note>
117 //
118 // <example>
119 // This is a base class so there is no direct example, but
120 // see the example in <linkto module=Coordinates>Coordinates.h</linkto>
121 // for use of the derived classes.
122 // </example>
123 //
124 // <motivation>
125 // Encapsulate the common interface to coordinate conversion so that it may
126 // be used polymorphically.
127 // </motivation>
128 //
129 // <thrown>
130 // <li> AipsError
131 // <li> AllocError
132 // </thrown>
133 //
134 // <todo asof="1997/1/13">
135 // <li> Perhaps common FITS related interfaces should go in this class.
136 // </todo>
137 //
138 
140 {
141 public:
142  // This enum lists the types of the derived classes. It is primarly used
143  // in the CoordinateSystem class.
144  enum Type {
145  // Linear axes.
147  // A direction. Usually RA/DEC.
149  // A spectral axis.
151  // A Stokes axis.
153  // A one-dimensional Cooordinate system, usually created from a table
154  // although it can also be purely linear.
156  // to mark DATA and ERROR values
158  // A CoordinateSystem (a collection of Coordinates).
160 
161  // This enum is used for formatting world values into Strings
162  enum formatType {
163  // Default; formatter decides
165  // Scientific format (e.g. -1.2397E+03)
167  // Fixed floating format (e.g. 12.134)
169  // Either scientific or floating point, auto-selected by the C++
170  // STL formatting routines. May not be available for all Coordinate
171  // types.
173  // HHH:MM:SS.SSS style formatting
174  TIME };
175 
176  // Destructor. Needs to be public so the user can delete Coordinate* objects
177  virtual ~Coordinate();
178 
179  // List the type of this Coordinate object.
180  // <group>
181  virtual Type type() const = 0;
182  virtual String showType() const = 0;
184  // </group>
185 
186  // How many world/pixel axes are there in this Coordinate? While the number
187  // of world and pixel axes will generally be the same, it is not a
188  // requirement. For example, in CoordinateSystem you could remove a pixel
189  // axis and leave the corresponding world axis. Also, if we ever implement
190  // a "SlicedCoordinate" class then there would be more world than pixel
191  // coordinates (the pixel coordinate would be a pixel number along the slice,
192  // whereas the world axes would continue to be RA/DEC).
193  // <group>
194  virtual uInt nPixelAxes() const = 0;
195  virtual uInt nWorldAxes() const = 0;
196  // </group>
197 
198  // Convert an absolute pixel position to an absolute world position or vice
199  // versa. Returns True
200  // if the conversion succeeds, otherwise it returns False and method
201  // errorMessage contains an error message. The input vector must be of length
202  // <src>nPixelAxes</src> or <src>nWorldAxes</src>. The output vector
203  // is resized appropriately.
204  // if <src>useConversionFrame</src>, if the coordinate has a conversion layer frame
205  // (such as can be present in spectral and direction coordinates), it
206  // is used. Else, the native frame is used for the conversion.
207  // <group>
208  virtual Bool toWorld(Vector<Double> &world,
209  const Vector<Double> &pixel, Bool useConversionFrame=True) const = 0;
210  virtual Bool toPixel(Vector<Double> &pixel,
211  const Vector<Double> &world) const = 0;
212  // </group>
213 
214  // Mixed absolute pixel/world coordinate conversion.
215  // worldIn and worldAxes are vectors of length <src>nWorldAxes</src>.
216  // <src>pixelIn</src> and <src>pixelAxes</src> are of length <src>nPixelAxes</src>.
217  // <src>worldAxes(i) = True</src> specifies you have given a world
218  // value in <src>worldIn(i)</src> to convert to pixel.
219  // <src>pixelAxes(i)=True</src> specifies you have given a pixel
220  // value in <src>pixelIn(i)</src> to convert to world.
221  // You cannot specify the same axis via <src>worldAxes</src>
222  // and <src>pixelAxes</src>.
223  // Values in <src>pixelIn</src> are converted to world and
224  // put into <src>worldOut</src> in the appropriate world axis
225  // location. Values in <src>worldIn</src> are copied to
226  // <src>worldOut</src>.
227  // Values in <src>worldIn</src> are converted to pixel and
228  // put into <src>pixelOut</src> in the appropriate pixel axis
229  // location. Values in <src>pixelIn</src> are copied to
230  // <src>pixelOut</src>.
231  // <src>worldMin</src> and <src>worldMax</src> specify the range of the world
232  // coordinate (in the world axis units of that world axis
233  // in the CoordinateSystem) being solved for in a mixed calculation
234  // for each world axis. They are only actually needed for DirectionCoordinates
235  // and for all other Coordinates the relevant elements
236  // can be undefined. If you don't know, use -180 to 180
237  // degrees for longitude, and -90 to 90 for latitude.
238  // Removed axes are handled (for example, a removed pixel
239  // axis with remaining corresponding world axis will
240  // correctly be converted to world using the replacement
241  // value).
242  // Returns True if the conversion succeeds, otherwise it returns False and
243  // <src>errorMessage()</src> contains an error message. The output vectors
244  // are resized.
245  virtual Bool toMix(Vector<Double>& worldOut,
246  Vector<Double>& pixelOut,
247  const Vector<Double>& worldIn,
248  const Vector<Double>& pixelIn,
249  const Vector<Bool>& worldAxes,
250  const Vector<Bool>& pixelAxes,
251  const Vector<Double>& worldMin,
252  const Vector<Double>& worldMax) const;
253 
254  // Set the world min and max ranges, for use in function <src>toMix</src>, for
255  // a lattice of the given shape for this coordinate. The default implementation
256  // here sets the range for pixels dangling 25% off the image.
257  // Returns False if fails with a reason in <src>errorMessage()</src>.
258  // setDefaultWorldMixRanges sets the range for each axis to +/-1e99
259  // The ranges remain zero length vectors until you explicitly
260  // initialize them.
261  // <group>
262  virtual Bool setWorldMixRanges (const IPosition& shape);
263  virtual void setDefaultWorldMixRanges ();
266  //</group>
267 
268 
269  // Batch up a lot of transformations. The first (most rapidly varying) axis
270  // of the matrices contain the coordinates. Returns False if any conversion
271  // failed and <src>errorMessage()</src> will hold a message.
272  // The <src>failures</src> array (True for fail, False for success)
273  // is the length of the number of conversions and
274  // holds an error status for each conversion. The default
275  // implementation is provided that works with the "single" version of
276  // <src>toWorld</src> and <src>toPixel</src>, but for maximum efficiency these should be
277  // overridden.
278  // <group>
279  virtual Bool toWorldMany(Matrix<Double>& world,
280  const Matrix<Double>& pixel,
281  Vector<Bool>& failures) const;
282  virtual Bool toPixelMany(Matrix<Double>& pixel,
283  const Matrix<Double>& world,
284  Vector<Bool>& failures) const;
285  // </group>
286 
287  // Make absolute coordinates relative and vice-versa (with
288  // respect to the reference value).
289  // Vectors must be length <src>nPixelAxes()</src> or
290  // <src>nWorldAxes()</src> or memory access errors will occur
291  // <group>
292  virtual void makePixelRelative (Vector<Double>& pixel) const;
293  virtual void makePixelAbsolute (Vector<Double>& pixel) const;
294  virtual void makeWorldRelative (Vector<Double>& world) const;
295  virtual void makeWorldAbsolute (Vector<Double>& world) const;
296  // </group>
297 
298  // Make absolute coordinates relative and vice versa with respect
299  // to the given reference value. Add the other functions in this grouping
300  // as needed. Vectors must be length <src>nPixelAxes()</src> or
301  // <src>nWorldAxes()</src> or memory access errors will occur
302  // <group>
303  virtual void makeWorldAbsoluteRef (Vector<Double>& world,
304  const Vector<Double>& refVal) const;
305  // </group>
306 
307 
308  // Batch up a lot of absolute/relative transformations.
309  // Parameters as above for
310  // <src>toWorldMany</src> and <src>toPixelMany</src>
311  // <group>
312  virtual void makePixelRelativeMany (Matrix<Double>& pixel) const;
313  virtual void makePixelAbsoluteMany (Matrix<Double>& pixel) const;
314  virtual void makeWorldRelativeMany (Matrix<Double>& world) const;
315  virtual void makeWorldAbsoluteMany (Matrix<Double>& world) const;
316  // </group>
317 
318 
319  // Return the requested attributed.
320  // <group>
321  virtual Vector<String> worldAxisNames() const = 0;
322  virtual Vector<Double> referencePixel() const = 0;
323  virtual Matrix<Double> linearTransform() const = 0;
324  virtual Vector<Double> increment() const = 0;
325  virtual Vector<Double> referenceValue() const = 0;
326  virtual Vector<String> worldAxisUnits() const = 0;
327  // </group>
328 
329  // Set the requested attribute. Note that these just
330  // change the internal values, they do not cause any recomputation.
331  // <group>
332  virtual Bool setWorldAxisNames(const Vector<String> &names) = 0;
333  virtual Bool setReferencePixel(const Vector<Double> &refPix) = 0;
334  virtual Bool setLinearTransform(const Matrix<Double> &xform) = 0;
335  virtual Bool setIncrement(const Vector<Double> &inc) = 0;
336  virtual Bool setReferenceValue(const Vector<Double> &refval) = 0;
337  // </group>
338 
339  // Change the units. Adjust the increment and
340  // reference value by the ratio of the old and new units. This implies that
341  // the units must be known <linkto class=Unit>Unit</linkto> strings, and that
342  // they must be compatible, e.g. they can't change from time to length.
343  //
344  // A default implementation is available which does everything except set
345  // the units vector, which must be done in the derived class.
346  virtual Bool setWorldAxisUnits(const Vector<String> &units) = 0;
347 
348  // Find the Coordinate for when we Fourier Transform ourselves. This pointer
349  // must be deleted by the caller. Axes specifies which axes of the Coordinate
350  // you wish to transform. Shape specifies the shape of the image
351  // associated with all the axes of the Coordinate. Currently the
352  // output reference pixel is always shape/2.
353  virtual Coordinate* makeFourierCoordinate (const Vector<Bool>& axes,
354  const Vector<Int>& shape) const;
355 
356  // If the last conversion to world or pixel coordinates resulted in an
357  // error, report that error. If the last conversion succeeded, it is
358  // undefined what this will return (it might well contain the last error
359  // message).
360  const String& errorMessage() const;
361 
362  // Comparison to fractional tolerance (for floating point values).
363  // Don't compare on specified axes in Coordinate. If the comparison
364  // returns False, <src>errorMessage()</src> contains a message.
365  // <group>
366  virtual Bool near(const Coordinate& other,
367  Double tol=1.0e-6) const = 0;
368  virtual Bool near(const Coordinate& other,
369  const Vector<Int>& excludeAxes,
370  Double tol=1.0e-6) const = 0;
371  // </group>
372 
373 
374  // Provide a common interface to getting formatted representations of
375  // coordinate values. Different derived Coordinate types are formatted
376  // in different ways. For example, an RA/DEC DirectionCoordinate
377  // uses an HMS.SS/DMS.SS representation. A Galactic Lat/Long DirectionCoordinate
378  // uses floating format in degrees. Other derived Coordinates are formatted with
379  // scientific format or floating format. The derived class format functions
380  // provide this functionality.
381  //
382  // You may specify the format with the format argument and a value
383  // from the enum <src>Coordinate::formatType</src>. If you give it the value
384  // <src>Coordinate::DEFAULT</src> then a sensible default is used.
385  //
386  // A mechanism for specifying the precision number of significant digits after
387  // decimal point is provided. You can specify the precision directly when
388  // calling format if it is unambiguous how the derived Coordinate is
389  // going to be formatted. For example, a LinearCoordinate is always formatted with
390  // scientific format. However, if you are using these classes polymorphically, you
391  // don't want to have to know this and some derived Coordinates may be formatted
392  // in multiple ways (such as the DirectionCoordinate examples above).
393  // Therefore, the function getPrecision enables
394  // you to set default precisions for the different styles of formatting
395  // used variously in the base and derived classes. This function chooses the
396  // precision from these default values, according to the type of derived
397  // Coordinate that your object is and what value for format that
398  // you give (refer to the derived classes for details on this).
399  //
400  // Some derived classes will format differently depending upon whether
401  // you want to format an absolute or offset world value input via
402  // absolute (e.g. DirectionCoordinates).
403  //
404  // The provided <src>worldValue</src> must be in the native units
405  // of the Coordinate. It may be an absolute (<src>isAbsolute=True</src>)
406  // or relative (<src>isAbsolute=False</src>) value. You may choose to
407  // format the world value as absolute (<src>showAsAbsolute=True</src>) or
408  // relative (<src>showAsAbsolute=False</src>). <src>axis</src>
409  // specifies which axis of the Coordinate this value belongs to.
410  //
411  // <src>units</src> specifies the units in which the input world value
412  // will be formatted.
413  // If <src>units</src> is empty, the native unit for the given axis
414  // is used.
415  //
416  // Some derived classes will format in units different from the
417  // native unit of the Coordinate. The units of
418  // the formatted number are returned in <src>units</src>.
419  // If the <src>units</src> string is provided, the unit must be
420  // consistent with the native unit of the coordinate. The input
421  // world value will be converted to this unit.
422  //
423  // You can also use the Quantum interface. The units of the Quantum
424  // can then be anything consistent with the Coordinate.
425  //
426  // The default implementation here is to format only
427  // with scientific or fixed formats. If precision is negative, a
428  // the default precision is used.
429  //
430  //<group>
431  virtual void getPrecision(Int &precision,
433  Bool showAsAbsolute,
434  Int defPrecScientific,
435  Int defPrecFixed,
436  Int defPrecTime) const;
437  virtual String format(
438  String& units,
440  Double worldValue,
441  uInt axis,
442  Bool isAbsolute=True,
443  Bool showAsAbsolute=True,
444  Int precision=-1,
445  Bool usePrecForMixed=False
446  ) const;
447 
450  const Quantum<Double>& worldValue,
451  uInt axis,
452  Bool isAbsolute=True,
453  Bool showAsAbsolute=True,
454  Int precision=-1);
455  //</group>
456 
457  // Used for persistence. Derived classes will have similar static
458  // restore methods. It will typically only return False if fieldName
459  // has already been defined.
460  virtual Bool save(RecordInterface &container,
461  const String &fieldName) const = 0;
462 
463  // Make a copy of ourself. This pointer has been allocated with
464  // <src>new</src> and must be deleted by the caller.
465  virtual Coordinate *clone() const = 0;
466 
467  // Comparison only made for specified axes in this and other Coordinate
468  // The default implementation should be ok for all Coordinate types
469  // except Stokes and Quality...
470  virtual Bool doNearPixel (const Coordinate& other,
471  const Vector<Bool>& thisAxes,
472  const Vector<Bool>& otherAxes,
473  Double tol=1.0e-6) const;
474 
475  // return the result of rotating the coordinate clockwise through the specified angle.
476  // Rotation occurs about the reference pixel.
477  // Coordinate must have exactly two pixel axes. The return type is the same
478  // as the input type. It is the caller's responsibility to delete the returned pointer
479  // when done with it to prevent a memory leak.
480  // This method ultimately just changes the input coordinate's linear transform matrix.
481  virtual Coordinate* rotate(const Quantum<Double>& angle) const;
482 
483  // Call wcsset on the wcs structure
484  static void set_wcs (::wcsprm& wcs);
485 
486  // Call wcsini on the wcs structure
487  static void init_wcs (::wcsprm& wcs, int naxis);
488 
489  // Call wcssub on the src/dst pair
490  static void sub_wcs(const ::wcsprm &src, int &nsub, int axes[], ::wcsprm &dst);
491 
492  // Call wcssub on the src/dst pair with null nsub/axes
493  static void copy_wcs(const ::wcsprm &src, ::wcsprm &dst);
494 
495 protected:
496  // Default constructor. Make an empty coordinate. Used by derived classes.
497  Coordinate();
498 
499  // Copy constructor (copy semantics)
500  Coordinate(const Coordinate& other);
501 
502  // Assignment (copy semantics)
503  Coordinate& operator=(const Coordinate& other);
504 
505  // Set error message
506  void set_error(const String &errorMsg) const;
507 
508  //
509  Bool find_scale_factor(String &error, Vector<Double> &factor,
510  const Vector<String> &units,
511  const Vector<String> &oldUnits);
512 
513 
514  // Tries to find a canonical unit for input unit (e.g. GHz -> Hz), and
515  // tells you the output name and unit for the Fourier coordinate
516  // pairing with the canonical unit
517  void fourierUnits (String& nameOut, String& unitOut, String& unitInCanon,
518  Coordinate::Type type, Int axis,
519  const String& unitIn,
520  const String& nameIn) const;
521 
522  // Functions to interconvert pixel<->world via wcs. These functions are called
523  // explicitly by the to{world,Pixel} functions in the appropriate wcs-based derived
524  // classes.
525  // <group>
526  Bool toWorldWCS (Vector<Double> &world, const Vector<Double> &pixel, wcsprm& wcs) const;
527  Bool toPixelWCS(Vector<Double> &pixel, const Vector<Double> &world, wcsprm& wcs) const;
528  Bool toWorldManyWCS (Matrix<Double>& world, const Matrix<Double>& pixel,
529  Vector<Bool>& failures, wcsprm& wcs) const;
530  Bool toPixelManyWCS (Matrix<Double>& pixel, const Matrix<Double>& world,
531  Vector<Bool>& failures, wcsprm& wcs) const;
532 
533  // Functions for handling conversion between the current units and
534  // the wcs units. These are called explicitly by the appropriate
535  // derived class.
536  // <src>convertFrom</src>
537  // <group>
538  void toCurrentMany (Matrix<Double>& world, const Vector<Double>& toCurrentFactors) const;
539  void fromCurrentMany(Matrix<Double>& world, const Vector<Double>& toCurrentFactors) const;
540  // </group>
541 
542 
543  // Functions for handling conversion between the current reference frame
544  // and the native one. The default implementations do nothing. They
545  // should be over-ridden in the derived classes.
546  // <group>
547  virtual void convertTo (Vector<Double>&) const
548  {}
549  virtual void convertFrom (Vector<Double>&) const
550  {}
551  // </group>
552 
553  // Functions for handling conversion between the current reference frame
554  // and the native one for many conversions. These functions just
555  // call the virtual functions for single conversions.
556  // <group>
557  void convertToMany (Matrix<Double>& world) const;
558  void convertFromMany (Matrix<Double>& world) const;
559  // </group>
560 
561  // Interconvert between wcs PC cards and Matrix xForm format
562  void pcToXform (Matrix<Double>& xForm, const wcsprm& wcs) const;
563  void xFormToPC (wcsprm& wcs, const Matrix<Double>& xForm) const;
564  // </group>
565 
566  // toMix ranges. Should be set by derived class.
568 
569 private:
570  mutable String error_p;
571 
572  // Check format type
574  const Bool absolute) const;
575 
576  void makeWorldAbsRelMany (Matrix<Double>& value, Bool toAbs) const;
577  void makePixelAbsRelMany (Matrix<Double>& value, Bool toAbs) const;
578 
579 
580 };
581 
582 //###### Inlines
583 
584 inline const String& Coordinate::errorMessage() const
585 {
586  return error_p;
587 }
588 
589 } //# NAMESPACE CASACORE - END
590 
591 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
String formatQuantity(String &units, Coordinate::formatType format, const Quantum< Double > &worldValue, uInt axis, Bool isAbsolute=True, Bool showAsAbsolute=True, Int precision=-1)
virtual ~Coordinate()
Destructor.
Scientific format (e.g.
Definition: Coordinate.h:166
int Int
Definition: aipstype.h:50
static String typeToString(Coordinate::Type type)
virtual Vector< Double > referenceValue() const =0
virtual void setDefaultWorldMixRanges()
Bool find_scale_factor(String &error, Vector< Double > &factor, const Vector< String > &units, const Vector< String > &oldUnits)
virtual Coordinate * rotate(const Quantum< Double > &angle) const
return the result of rotating the coordinate clockwise through the specified angle.
void fourierUnits(String &nameOut, String &unitOut, String &unitInCanon, Coordinate::Type type, Int axis, const String &unitIn, const String &nameIn) const
Tries to find a canonical unit for input unit (e.g.
virtual Vector< String > worldAxisNames() const =0
Return the requested attributed.
virtual Vector< Double > referencePixel() const =0
virtual Type type() const =0
List the type of this Coordinate object.
Default; formatter decides.
Definition: Coordinate.h:164
Vector< Double > worldMixMax() const
Definition: Coordinate.h:265
virtual Bool setReferencePixel(const Vector< Double > &refPix)=0
Vector< Double > worldMin_p
toMix ranges.
Definition: Coordinate.h:567
const String & errorMessage() const
If the last conversion to world or pixel coordinates resulted in an error, report that error...
Definition: Coordinate.h:584
virtual void makeWorldAbsoluteMany(Matrix< Double > &world) const
Vector< Double > worldMixMin() const
Definition: Coordinate.h:264
static void sub_wcs(const ::wcsprm &src, int &nsub, int axes[],::wcsprm &dst)
Call wcssub on the src/dst pair.
Vector< Double > worldMax_p
Definition: Coordinate.h:567
virtual Bool setWorldAxisUnits(const Vector< String > &units)=0
Change the units.
void xFormToPC(wcsprm &wcs, const Matrix< Double > &xForm) 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 absolute pixel/world coordinate conversion.
virtual Vector< String > worldAxisUnits() const =0
formatType
This enum is used for formatting world values into Strings.
Definition: Coordinate.h:162
virtual Bool setWorldAxisNames(const Vector< String > &names)=0
Set the requested attribute.
virtual Bool setReferenceValue(const Vector< Double > &refval)=0
virtual Bool toPixelMany(Matrix< Double > &pixel, const Matrix< Double > &world, Vector< Bool > &failures) const
void fromCurrentMany(Matrix< Double > &world, const Vector< Double > &toCurrentFactors) const
Coordinate()
Default constructor.
virtual String format(String &units, Coordinate::formatType format, Double worldValue, uInt axis, Bool isAbsolute=True, Bool showAsAbsolute=True, Int precision=-1, Bool usePrecForMixed=False) const
Bool toPixelWCS(Vector< Double > &pixel, const Vector< Double > &world, wcsprm &wcs) const
static void init_wcs(::wcsprm &wcs, int naxis)
Call wcsini on the wcs structure.
virtual Matrix< Double > linearTransform() const =0
void makePixelAbsRelMany(Matrix< Double > &value, Bool toAbs) const
virtual void makeWorldRelativeMany(Matrix< Double > &world) const
Either scientific or floating point, auto-selected by the C++ STL formatting routines.
Definition: Coordinate.h:172
Interface for converting between world and pixel coordinates.
Definition: Coordinate.h:139
virtual void makePixelAbsolute(Vector< Double > &pixel) const
double Double
Definition: aipstype.h:55
virtual Bool toPixel(Vector< Double > &pixel, const Vector< Double > &world) const =0
virtual String showType() const =0
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...
virtual void makeWorldAbsolute(Vector< Double > &world) const
virtual Coordinate * clone() const =0
Make a copy of ourself.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void convertFromMany(Matrix< Double > &world) const
A CoordinateSystem (a collection of Coordinates).
Definition: Coordinate.h:159
const Bool False
Definition: aipstype.h:44
virtual Bool setWorldMixRanges(const IPosition &shape)
Set the world min and max ranges, for use in function toMix, for a lattice of the given shape for thi...
A one-dimensional Cooordinate system, usually created from a table although it can also be purely lin...
Definition: Coordinate.h:155
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
virtual void getPrecision(Int &precision, Coordinate::formatType &format, Bool showAsAbsolute, Int defPrecScientific, Int defPrecFixed, Int defPrecTime) const
Provide a common interface to getting formatted representations of coordinate values.
Type
This enum lists the types of the derived classes.
Definition: Coordinate.h:144
virtual void convertTo(Vector< Double > &) const
Functions for handling conversion between the current reference frame and the native one...
Definition: Coordinate.h:547
virtual void convertFrom(Vector< Double > &) const
Definition: Coordinate.h:549
virtual uInt nWorldAxes() const =0
virtual Bool save(RecordInterface &container, const String &fieldName) const =0
Used for persistence.
virtual Bool doNearPixel(const Coordinate &other, const Vector< Bool > &thisAxes, const Vector< Bool > &otherAxes, Double tol=1.0e-6) const
Comparison only made for specified axes in this and other Coordinate The default implementation shoul...
Bool toPixelManyWCS(Matrix< Double > &pixel, const Matrix< Double > &world, Vector< Bool > &failures, wcsprm &wcs) const
void toCurrentMany(Matrix< Double > &world, const Vector< Double > &toCurrentFactors) const
Functions for handling conversion between the current units and the wcs units.
Coordinate & operator=(const Coordinate &other)
Assignment (copy semantics)
virtual Bool toWorld(Vector< Double > &world, const Vector< Double > &pixel, Bool useConversionFrame=True) const =0
Convert an absolute pixel position to an absolute world position or vice versa.
virtual Bool setLinearTransform(const Matrix< Double > &xform)=0
static void set_wcs(::wcsprm &wcs)
Call wcsset on the wcs structure.
const Double e
e and functions thereof:
void convertToMany(Matrix< Double > &world) const
Functions for handling conversion between the current reference frame and the native one for many con...
virtual uInt nPixelAxes() const =0
How many world/pixel axes are there in this Coordinate? While the number of world and pixel axes will...
Bool toWorldManyWCS(Matrix< Double > &world, const Matrix< Double > &pixel, Vector< Bool > &failures, wcsprm &wcs) const
void makeWorldAbsRelMany(Matrix< Double > &value, Bool toAbs) const
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void checkFormat(Coordinate::formatType &format, const Bool absolute) const
Check format type.
virtual void makePixelRelative(Vector< Double > &pixel) const
Make absolute coordinates relative and vice-versa (with respect to the reference value).
virtual void makeWorldRelative(Vector< Double > &world) const
virtual Vector< Double > increment() const =0
Abstract base class for Record classes.
static void copy_wcs(const ::wcsprm &src,::wcsprm &dst)
Call wcssub on the src/dst pair with null nsub/axes.
virtual Bool near(const Coordinate &other, Double tol=1.0e-6) const =0
Comparison to fractional tolerance (for floating point values).
const Bool True
Definition: aipstype.h:43
to mark DATA and ERROR values
Definition: Coordinate.h:157
void pcToXform(Matrix< Double > &xForm, const wcsprm &wcs) const
Interconvert between wcs PC cards and Matrix xForm format.
HHH:MM:SS.SSS style formatting.
Definition: Coordinate.h:174
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
Bool toWorldWCS(Vector< Double > &world, const Vector< Double > &pixel, wcsprm &wcs) const
Functions to interconvert pixel&lt;-&gt;world via wcs.
virtual Bool setIncrement(const Vector< Double > &inc)=0
unsigned int uInt
Definition: aipstype.h:51
virtual Coordinate * makeFourierCoordinate(const Vector< Bool > &axes, const Vector< Int > &shape) const
Find the Coordinate for when we Fourier Transform ourselves.
void set_error(const String &errorMsg) const
Set error message.
virtual void makePixelAbsoluteMany(Matrix< Double > &pixel) const
virtual Bool toWorldMany(Matrix< Double > &world, const Matrix< Double > &pixel, Vector< Bool > &failures) const
Batch up a lot of transformations.
Fixed floating format (e.g.
Definition: Coordinate.h:168
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42
virtual void makePixelRelativeMany(Matrix< Double > &pixel) const
Batch up a lot of absolute/relative transformations.