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