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