casacore
Loading...
Searching...
No Matches
CoordinateSystem.h
Go to the documentation of this file.
1//# CoordinateSystem.h: Interconvert pixel and image coordinates.
2//# Copyright (C) 1997,1998,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_COORDINATESYSTEM_H
28#define COORDINATES_COORDINATESYSTEM_H
29
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Arrays/ArrayFwd.h>
32#include <casacore/coordinates/Coordinates/Coordinate.h>
33#include <casacore/measures/Measures/MDirection.h>
34#include <casacore/measures/Measures/MFrequency.h>
35#include <casacore/coordinates/Coordinates/ObsInfo.h>
36#include <casacore/casa/Containers/Block.h>
37#include <casacore/measures/Measures/MDoppler.h>
38#include <map>
39
40namespace casacore { //# NAMESPACE CASACORE - BEGIN
41
42class DirectionCoordinate;
43class LinearCoordinate;
44class SpectralCoordinate;
45class StokesCoordinate;
46class QualityCoordinate;
47class TabularCoordinate;
48class IPosition;
49class LogIO;
50
51
52// <summary>
53// Interconvert pixel and world coordinates.
54// </summary>
55
56// <use visibility=export>
57
58// <reviewed reviewer="Peter Barnes" date="1999/12/24" tests="tCoordinateSystem">
59// </reviewed>
60//
61// <prerequisite>
62// <li> <linkto class=Coordinate>Coordinate</linkto>
63// </prerequisite>
64
65// <synopsis>
66// CoordinateSystem is the normal interface to coordinate systems,
67// typically attached to an
68// <linkto class=ImageInterface>ImageInterface</linkto>, however the
69// coordinate system can be manipulated on its own. CoordinateSystem
70// is in turn composed from various classes derived from the base class
71// <linkto class=Coordinate>Coordinate</linkto>.
72// <p>
73// The fundamental operations available to the user of a
74// CoordinateSystem are:
75// <ol>
76// <li> Transform a world (physical) coordinate to a pixel coordinate
77// or vice versa via the methods toWorld and toPixel.
78// <li> Compose a CoordinateSystem from one or more independent groups,
79// typically the sky-plane transformation will be one group, and the
80// spectral axis will be another group. Each group consists of a linear
81// transformation (in FITS terms, apply <src>CRPIX, PC, CDELT</src>)
82// to turn the pixel coordinates into relative world coordinates,
83// followed by a (possibly) nonlinear projection to world coordinates
84// (i.e. apply <src>CTYPE and CRVAL</src>), typically a sky projection
85// or a frequency to velocity conversion. Note that an arbitrary rotation
86// or linear transformation can be applied by changing the
87// matrix.
88// <li> Transpose the world and/or pixel axes.
89// <li> One or more pixel or world axes may be removed. You are encouraged to
90// leave all the world axes if you remove a pixel axis.
91// Removing a world axis also removes the corresponding pixel axis.
92// <li> Calculate the CoordinateSystem that results from a subimage
93// operation.
94// </ol>
95//
96// Note that all the knowledge to do with removing and transposing axes is
97// maintained by the CoordinateSystem. The individual Coordinates, of which it
98// is made, know nothing about this.
99// <p>
100// Although the CoordinateSystem exists in the absence of an image, the usual
101// place you will find one is attached to an object derived from ImageInterface
102// such as PagedImage. When you do so, the physical (or pixel) axes in the image
103// map one to one with the pixel axes contained in the CoordinateSystem.
104// It cannot be any other way as when you create a PagedImage, it is checked
105// that there are equal numbers of image and CoordinateSystem pixel axes.
106// It is up to the creator of the PagedImage to make sure that they are
107// in the correct order.
108// <p>
109// However, the CoordinateSystem may have more world axes than pixel axes
110// because it is possible to remove a pixel axis but not its associated
111// world axis (for example for a moment image). Now, if you use
112// the CoordinateSystem functions
113// referencePixel and referenceValue, you will find the vector of reference
114// values will have more values than the vector of reference pixels,
115// if a pixel axis has been removed but not the world axis. You
116// must use the ancilliary functions provided
117// to find out what is where.
118// <p>
119// Let's consider an example where a CoordinateSystem consisted of
120// a DirectionCoordinate and a SpectralCoordinate. Let us say that
121// the first two pixel axes of the image associate (roughly of course
122// because lines of constant RA and DEC are not parallel with
123// the pixel coordinates) with the DirectionCoordinate (RA and DEC say)
124// and the third pixel axis is the SpectralCoordinate.
125// Now imagine we collapse the image along the second pixel axis (roughly,
126// the DEC axis). For the output image, we remove the second pixel axis
127// from the CoordinateSystem, but leave the world axis intact. This enables
128// us to still be able to make coordinate conversions for the first (roughly RA)
129// pixel axis. Thus, CoordinateSystem::referenceValue would return a Vector of
130// length 3 (for RA, DEC and spectral), but CoordinateSystem::referencePixel
131// would return a vector length 2 (for RA and spectral).
132// <p>
133// Now this CoordinateSystem has two Coordinates, a DirectionCoordinate and
134// a SpectralCoordinate, and let us state that that is the order in which
135// they exist in the CoordinateSystem (you can change them about if you wish);
136// they are coordinates number 0 and 1. The DirectionCoordinate has two axes
137// (RA and DEC) and the SpectralCoordinate has one axis. Only the
138// CoordinateSystem knows about removed axes, the DirectionCoordinate
139// itself is ignorant that it has been bisected. If you want to find
140// out what axis in the Coordinate system is where, you can use
141// the functions findPixelAxis or findWorldAxis.
142//
143// If we asked the former to find pixel axis 0, it would tell us that the
144// Coordinate number was 0 (the DirectionCoordinate) and that the axis in
145// that coordinate was 0 (the first axis in a DirectionCoordinate
146// is always longitude, the second always latitude). If we asked it to find
147// pixel axis 1, it would tell us that the coordinate number was 1
148// (the SpectralCoordinate) and that the axis in that coordinate was 0
149// (there is only one axis in a SpectralCoordinate). If we asked for
150// pixelAxis 2 that would generate an error because our squashed image
151// only has 2 pixel axes.
152//
153// Now, if we asked findWorldAxis similar questions,
154// it would tell us that worldAxis 0 in the CoordinateSystem can be found in
155// coordinate 0 (the DirectionCoordinate) in axis 0 of that DirectionCoordinate.
156// Similarly, worldAxis 1 in the CoordinateSystem (which has not been removed)
157// is in coordinate 0 (the DirectionCoordinate) in axis 1 of that
158// Finally, worldAxis 2 in the CoordinateSystem is in coordinate 1
159// (the SpectralCoordinate) in axis 0 of that SpectralCoordinate.
160// <p>
161// Other handy functions are pixelAxes and worldAxes.
162// These list the pixel and world axes in
163// the CoordinateSystem for the specified coordinate. Thus, if we asked
164// pixelAxes to find the pixel axes for coordinate 0 (the DirectionCoordinate)
165// in the CoordinateSystem it would return a vector [0, -1] indicating
166// the second axis of the DirectionCoordinate has been removed. However,
167// the worldAxes function would return [0,1] as no world axis has been removed.
168// Similarly, if operated on coordinate 1 (the SpectralCoordinate), pixelAxes
169// would return [1] and worldAxes would return [2].
170//
171// Because you can transpose the CoordinateSystem about, you should NEVER ASSUME
172// ANYTHING except that the pixel axes of the CoordinateSystem map to the pixel
173// axes of the image when you first construct the image.
174//
175// <p>
176// SpectralCoordinate and DirectionCoordinate both have a (non-virtual) function
177// called <src>setReferenceConversion</src>. This enables an extra conversion
178// layer so that conversion between pixel and world can go to a reference frame
179// other than the construction reference. When you use the function
180// <src>convert</src>, these layers are active, but ONLY if the
181// requested conversion is purely between pixel and world. For
182// a SpectralCoordinate this must always be true (only has one axis)
183// but for the DirectionCoordinate you might request a mixed
184// pixel/world conversion. In this case, the extra conversion layer
185// is ill-defined and not active (for the DirectionCoordinate part of it).
186// </synopsis>
187
188// <note role=caution>
189// All pixels coordinates are zero relative.
190// </note>
191
192// <example>
193// See the example in <linkto module=Coordinates>Coordinates.h</linkto>
194// and tCoordinateSystem.cc
195// </example>
196
197// <motivation>
198// Coordinate systems for images.
199// </motivation>
200//
201// <thrown>
202// <li> AipsError
203// </thrown>
204//
205// <todo asof="1997/01/13">
206// <li> Undelete individual removed axes.
207// <li> Non-integral pixel shifts/decimations in subimage operations?
208// <li> Copy-on-write for efficiency?
209// <li> Check if the classes are thread safe in general
210// </todo>
211//
212
213
215{
216public:
217 // Default constructor. This is an empty CoordinateSystem.
219
220 // Copying constructor (copy semantics)
222
223 // Assignment (copy semantics).
225
226 // Destructor
228
229 // Add another Coordinate to this CoordinateSystem. This addition is done
230 // by copying, so that if coord changes the change is NOT
231 // reflected in the CoordinateSystem.
232 void addCoordinate(const Coordinate &coord);
233
234 // Transpose the CoordinateSystem so that world axis 0 is
235 // newWorldOrder(0) and so on for all the other axes.
236 // newPixelOrder works similarly. Normally you will give the
237 // same transformation vector for both the world and pixel transformations,
238 // however this is not required.
239 void transpose(const Vector<Int> &newWorldOrder,
240 const Vector<Int> &newPixelOrder);
241
242 // Find the world and pixel axis mappings to the supplied CoordinateSystem
243 // from the current coordinate system. <src>False</src> is
244 // returned if either the supplied or current coordinate system,
245 // has no world axes (and a message recoverable with function
246 // errorMessage indicating why). Otherwise <src>True</src> is returned.
247 // worldAxisMap(i) is the location of world axis <src>i</src> (from the
248 // supplied CoordinateSystem, cSys, in the current CoordinateSystem.
249 // worldAxisTranspose(i) is the location of world axis
250 // <src>i</src> (from the current CoordinateSystem) in the supplied
251 // CoordinateSystem, cSys. The output vectors
252 // are resized appropriately by this function. A value of -1
253 // in either vector means that the axis could not be found in the other
254 // CoordinateSystem. The vector <src>refChange</src> says
255 // if the types are the same, is there a reference type change
256 // (e.g. TOPO versus LSR for the SpectralCoordinate,
257 // or J2000 versus GALACTIC for DirectionCoordinate). Thus
258 // if refChange(i) is True, it means world axis i in the
259 // current CoordinateSystem was matched, but has a different
260 // reference type to that of the supplied CoordinateSystem.
261 // <group>
262 Bool worldMap (Vector<Int>& worldAxisMap,
263 Vector<Int>& worldAxisTranspose,
264 Vector<Bool>& refChange,
265 const CoordinateSystem& cSys) const;
266 Bool pixelMap (Vector<Int>& pixelAxisMap,
267 Vector<Int>& pixelAxisTranspose,
268 const CoordinateSystem& cSys) const;
269 // </group>
270
271 // Remove a world or pixel axis. When its value is required for forward or
272 // backwards transformations, use <src>replacement</src>
273 // <br>
274 // When a world axis is removed, the corresponding pixel axis is removed
275 // too, because it makes no sense having a pixel axis without world
276 // coordinates.
277 // <br>
278 // Removing a pixel axis without removing the corresponding world axis
279 // is, however, possible and meaningful. It can be used when e.g. a
280 // frequency plane is taken from a cube. The plane has 2 pixel axes, but
281 // the 3rd world axis can still describe the frequency coordinate.
282 // See also the functions in <linkto class=CoordinateUtil>CoordinateUtil</linkto>
283 // for removing lists of pixel/world axes (tricky because they shift down)
284 //
285 // False is returned (an error in <src>errorMessage()</src> will be set)
286 // if the axis is illegal, else returns True.
287 // <group>
288 Bool removeWorldAxis(uInt axis, Double replacement);
289 Bool removePixelAxis(uInt axis, Double replacement);
290 // </group>
291
292 // Return a CoordinateSystem appropriate for a shift of origin
293 // (the shift is subtracted from the reference pixel)
294 // and change of increment (the increments are multipled
295 // by the factor). Both vectors should be of length nPixelAxes().
296 //
297 // The newShape vector is only needed for the StokesCoordinate,
298 // if any. If this vector is of length zero, the new StokesCoordinate
299 // is formed from all of the available input Stokes after application
300 // of the shift and increment factor. Otherwise,
301 // the new Stokes axis length is equal to that specified after
302 // appliction of the shift and increment and excess values
303 // discarded. In addition, for any StokesCoordinate, the
304 // shift and factor must be integer. So <src>Int(value+0.5)</src>
305 // is taken before they are used.
306 // <group>
308 const Vector<Float> &incrFac,
309 const Vector<Int>& newShape) const;
310 void subImageInSitu (const Vector<Float> &originShift,
311 const Vector<Float> &incrFac,
312 const Vector<Int>& newShape);
313 // </group>
314
315 // Untranspose and undelete all axes. Does not undo the effects of
316 // subimaging.
318
319 // Returns the number of Coordinates that this CoordinateSystem contains.
320 // The order might be unrelated to the axis order through the results of
321 // transposing and removing axes.
323
324 // For a given Coordinate say where its world and pixel axes are in
325 // this CoordinateSystem. The position in the returned Vector is its
326 // axis number in the Coordinate, and its value is the axis
327 // number in the CoordinateSystem. If the value is less than zero the axis
328 // has been removed from this CoordinateSystem.
329 // <group>
330 Vector<Int> worldAxes(uInt whichCoord) const;
331 Vector<Int> pixelAxes(uInt whichCoord) const;
332 // </group>
333
334 // Return the type of the given Coordinate.
335 Coordinate::Type type(uInt whichCoordinate) const;
336
337 // Returns the type of the given Coordinate as a string.
338 String showType(uInt whichCoordinate) const;
339
340 // Return the given Coordinate as a reference to the base
341 // class object.
342 const Coordinate& coordinate(uInt which) const;
343
344 // Return the given Coordinate.
345 // Throws an exception if retrieved as the wrong type.
346 // The versions which take no parameters will return the
347 // first (or in most cases only) coordinate of the requested type.
348 // If no such coordinate exists, an exception is thrown.
349 // <group>
353
357
361 // </group>
362
363 // Replace one Coordinate with another. The mapping of the coordinate axes
364 // to the CoordinateSystem axes is unchanged, therefore the number of world
365 // and pixel axes must not be changed. You can, somewhat dangerously,
366 // change the type of the coordinate however. For example, replace a
367 // SpectralCoordinate with a 1-D Linearcoordinate. It is dangerous because
368 // the world replacement values (see removeWorldAxis) have to be scaled.
369 // The algorithm tries to find a scale factor between the old and new
370 // units and applies it to the replacement values. If it can't find
371 // a scale factor (non-conformant units) then the reference value is
372 // used for any world replacement values. If the latter occurs,
373 // it returns False, else True is returned.
374 Bool replaceCoordinate(const Coordinate &newCoordinate, uInt whichCoordinate);
375
376 // Find the Coordinate number that corresponds to the given type.
377 // Since there might be more than one Coordinate of a given type you
378 // can call this multiple times setting <src>afterCoord</src> to
379 // the last value found. Returns -1 if a Coordinate of the desired
380 // type is not found.
381 Int findCoordinate(Coordinate::Type type, Int afterCoord = -1) const;
382
383 // Given an axis number (pixel or world) in the CoordinateSystem,
384 // find the corresponding coordinate number and axis in that Coordinate.
385 // The returned values are set to -1 if the axis does not exist.
386 // <group>
387 void findWorldAxis(Int &coordinate, Int &axisInCoordinate,
388 uInt axisInCoordinateSystem) const;
389 void findPixelAxis(Int &coordinate, Int &axisInCoordinate,
390 uInt axisInCoordinateSystem) const;
391 // </group>
392
393 // Find the world axis for the given pixel axis in a CoordinateSystem.
394 // Returns -1 if the world axis is unavailable (e.g. if it has been
395 // removed).
396 Int pixelAxisToWorldAxis(uInt pixelAxis) const;
397
398 // Find the pixel axis for the given world axis in a CoordinateSystem.
399 // Returns -1 if the pixel axis is unavailable (e.g. if it has been
400 // removed).
401 Int worldAxisToPixelAxis(uInt worldAxis) const;
402
403 // Return the name of the record field in which the coordinate is stored.
405
406 // Returns <src>Coordinate::COORDSYS</src>
407 virtual Coordinate::Type type() const;
408
409 // Always returns "System"
410 virtual String showType() const;
411
412 // Sums the number of axes in the Coordinates that the CoordinateSystem
413 // contains, allowing for removed axes.
414 // <group>
415 virtual uInt nPixelAxes() const;
416 virtual uInt nWorldAxes() const;
417 // </group>
418
419
420 // Convert a pixel position to a world position or vice versa. Returns True
421 // if the conversion succeeds, otherwise it returns <src>False</src> and
422 // <src>errorMessage()</src> contains an error message.
423 // The input vector must be of length <src>nPixelAxes</src> or
424 // <src>nWorldAxes</src>. The output vector is resized appropriately.
425 // if <src>useConversionFrame</src>, if the coordinate has a conversion layer frame
426 // (such as can be present in spectral and direction coordinates), it
427 // is used. Else, the native frame is used for the conversion.
428 // <group>
429 virtual Bool toWorld(Vector<Double> &world,
430 const Vector<Double> &pixel, Bool useConversionFrame=True) const;
431 // This one throws an exception rather than returning False. After all, that's
432 // what exceptions are for.
433 virtual Vector<Double> toWorld(const Vector<Double> &pixel) const;
434 virtual Bool toPixel(Vector<Double> &pixel,
435 const Vector<Double> &world) const;
436 // This one throws an exception rather than returning False.
437 virtual Vector<Double> toPixel(const Vector<Double> &world) const;
438 // </group>
439
440 // convert a pixel "length" to a world "length"
442 const Double nPixels,
443 const uInt pixelAxis
444 ) const;
445
446 // This is provided as a convenience since it is a very commonly desired
447 // operation through CoordinateSystem. The output vector is resized.
448 Bool toWorld(Vector<Double> &world, const IPosition &pixel) const;
449 Vector<Double> toWorld(const IPosition& pixel) const;
450
451 // Batch up a lot of transformations. The first (most rapidly varying) axis
452 // of the matrices contain the coordinates. Returns False if any conversion
453 // failed and <src>errorMessage()</src> will hold a message.
454 // The <src>failures</src> array (True for fail, False for success)
455 // is the length of the number of conversions and
456 // holds an error status for each conversion.
457 // <group>
459 const Matrix<Double>& pixel,
460 Vector<Bool>& failures) const;
462 const Matrix<Double>& world,
463 Vector<Bool>& failures) const;
464 // </group>
465
466
467 // Mixed pixel/world coordinate conversion.
468 // <src>worldIn</src> and <src>worldAxes</src> are of length n<src>worldAxes</src>.
469 // <src>pixelIn</src> and <src>pixelAxes</src> are of length nPixelAxes.
470 // <src>worldAxes(i)=True</src> specifies you have given a world
471 // value in <src>worldIn(i)</src> to convert to pixel.
472 // <src>pixelAxes(i)=True</src> specifies you have given a pixel
473 // value in <src>pixelIn(i)</src> to convert to world.
474 // You cannot specify the same axis via <src>worldAxes</src>
475 // and pixelAxes.
476 // Values in <src>pixelIn</src> are converted to world and
477 // put into <src>worldOut</src> in the appropriate world axis
478 // location. Values in <src>worldIn</src> are copied to
479 // <src>worldOut</src>.
480 // Values in <src>worldIn</src> are converted to pixel and
481 // put into <src>pixelOut</src> in the appropriate pixel axis
482 // location. Values in <src>pixelIn</src> are copied to
483 // <src>pixelOut</src>. Vectors
484 // <src>worldMin</src> and <src>worldMax</src> specify the range of the world
485 // coordinate (in the world axis units of that world axis
486 // in the coordinate system) being solved for in a mixed calculation
487 // for each world axis. They are only actually used for DirectionCoordinates
488 // and for all other coordinates the relevant elements are ignored.
489 // Functions <src>setWorldMixRanges, worldMixMin, worldMixMax</src> can be
490 // used to compute and recover the world ranges. If you don't know
491 // the values, use functions <src>setDefaultWorldMixRanges, worldMixMin, worldMixMax</src>.
492 // Removed axes are handled (for example, a removed pixel
493 // axis with remaining corresponding world axis will
494 // correctly be converted to world using the replacement
495 // value).
496 // Returns True if the conversion succeeds, otherwise it returns <src>False</src> and
497 // <src>errorMessage()</src> contains an error message. The output vectors
498 // are resized.
499 virtual Bool toMix(Vector<Double>& worldOut,
500 Vector<Double>& pixelOut,
501 const Vector<Double>& worldIn,
502 const Vector<Double>& pixelIn,
503 const Vector<Bool>& worldAxes,
504 const Vector<Bool>& pixelAxes,
505 const Vector<Double>& worldMin,
506 const Vector<Double>& worldMax) const;
507
508 // Compute and recover the world min and max ranges, for use in function <src>toMix</src>,
509 // for a lattice of the given shape (must be of length <src>nPixelAxes()</src>).
510 // Removed pixel axes (with remaining world axes are handled). With
511 // the retrieval functions, the output vectors are resized. They return
512 // False if they fail (and then <src>setDefaultWorldMixRanges</src> generates the ranges)
513 // with a reason in <src>errorMessage()</src>.
514 // The <src>setDefaultWorldMixRanges</src> function
515 // gives you a useful default range if you don't know the shape.
516 // The only Coordinate type for which these ranges are actually
517 // used in <src>toMix</src> is DirectionCoordinate (because its coupled). For
518 // the rest the functionality is provided but never used
519 // by toMix.
520 //<group>
523 virtual Vector<Double> worldMixMin () const;
524 virtual Vector<Double> worldMixMax () const;
525 //</group>
526
527 // Make absolute coordinates relative and vice-versa (relative
528 // to the reference pixel/value). The vectors must be of length
529 // <src>nPixelAxes()</src> or <src>nWorldAxes()</src>
530 //<group>
531 virtual void makePixelRelative (Vector<Double>& pixel) const;
532 virtual void makePixelAbsolute (Vector<Double>& pixel) const;
533 virtual void makeWorldRelative (Vector<Double>& world) const;
534 virtual void makeWorldAbsolute (Vector<Double>& world) const;
535 //</group>
536
537 // Make absolute coordinates relative and vice versa with respect
538 // to the given reference value. Add the other functions in this grouping
539 // as needed. The vectors must be of length
540 // <src>nPixelAxes()</src> or <src>nWorldAxes()</src>
541 //<group>
543 const Vector<Double>& refVal) const;
544 //</group>
545
546 // Batch up a lot of absolute/relative transformations.
547 // Parameters as above for
548 // <src>toWorldMany</src> and <src>toPixelMany</src>
549 // <group>
550 virtual void makePixelRelativeMany (Matrix<Double>& pixel) const;
551 virtual void makePixelAbsoluteMany (Matrix<Double>& pixel) const;
552 virtual void makeWorldRelativeMany (Matrix<Double>& world) const;
553 virtual void makeWorldAbsoluteMany (Matrix<Double>& world) const;
554 // </group>
555
556
557 // General coordinate conversion. Only works if no axes
558 // have been removed and no axis reordering has occurred.
559 // That is pixel axes and world axes are the same.
560 //
561 // Specify the input coordinate values, input units,
562 // whether value is absolute (or relative). For output
563 // specify units and abs/rel. Units may be 'pix' and velocity consistent
564 // units (e.g. m/s). Specify doppler types if velocities
565 // involved. The pixel offsets allow for the input
566 // and output pixel coordinates to be something other than 0-rel.
567 // If your pixel coordinates are 1-rel input and output, set the
568 // offsets to -1 and 1
569 //
570 // The Matrix interface lets you do many conversions efficiently.
571 // Use <src>Matrix(nAxes, nConversions) </src> and
572 // <src>Matrix.column()=coordinate</src> or
573 // <src>Matrix(axis, iConversion)</src> to get the order right.
574 //
575 // These functions invoke <src>toMix</src>
576 // so make sure you call <src>setWorldMixRanges</src>
577 // first to set up the world ranges.
578 // <group>
580 const Vector<Double>& coordin,
581 const Vector<Bool>& absIn,
582 const Vector<String>& unitsIn,
583 MDoppler::Types dopplerIn,
584 const Vector<Bool>& absOut,
585 const Vector<String>& unitsOut,
586 MDoppler::Types dopplerOut,
587 Double pixInOffset = 0.0,
588 Double pixOutOffset = 0.0);
590 const Matrix<Double>& coordIn,
591 const Vector<Bool>& absIn,
592 const Vector<String>& unitsIn,
593 MDoppler::Types dopplerIn,
594 const Vector<Bool>& absOut,
595 const Vector<String>& unitsOut,
596 MDoppler::Types dopplerOut,
597 Double pixInOffset = 0.0,
598 Double pixOutOffset = 0.0);
599 // </group>
600
601 // Return the requested attribute.
602 // <group>
606 virtual Vector<Double> increment() const;
608 // </group>
609
610 // Set the requested attribute. Note that these just
611 // change the internal values, they do not cause any recomputation.
612 // <group>
613 virtual Bool setWorldAxisNames(const Vector<String> &names);
614 virtual Bool setReferencePixel(const Vector<Double> &refPix);
616 virtual Bool setIncrement(const Vector<Double> &inc);
617 virtual Bool setReferenceValue(const Vector<Double> &refval);
618 // </group>
619
620 // Set/get the units. Adjust the increment and
621 // reference value by the ratio of the old and new units. This implies that
622 // the units must be known <linkto class=Unit>Unit</linkto> strings, and
623 // that they must be compatible, e.g. they can't change from time to
624 // length. If <src>throwException=True</src>, throw an exception rather than
625 // returning False on failure.
626 // <group>
627 virtual Bool setWorldAxisUnits(const Vector<String> &units);
629 Bool throwException);
631 // </group>
632
633 // Comparison function. Any private Double data members are compared
634 // with the specified fractional tolerance. Don't compare on the specified
635 // pixel axes in the CoordinateSystem. If the comparison returns
636 // <src>False</src>, errorMessage() contains a message about why.
637 // <group>
638 virtual Bool near(const Coordinate& other, Double tol=1e-6) const;
639 virtual Bool near(const Coordinate& other,
640 const Vector<Int>& excludePixelAxes,
641 Double tol=1e-6) const;
642 // </group>
643
644 // This function compares this and the other coordinate system,
645 // but ONLY for the non-removed pixel axes. It is less strict
646 // than near, which, for example, insists the number of coordinates
647 // is the same in each CS
648 Bool nearPixel (const CoordinateSystem& other, Double tol=1e-6) const;
649
650
651 // Format a world value nicely through the
652 // common format interface. See <linkto class=Coordinate>Coordinate</linkto>
653 // for basics.
654 //
655 // You specify a world value and its corresponding world axis in
656 // the CoordinateSystem.
657 //
658 // For the specified worldAxis, the coordinate
659 // number in the CoordinateSystem is found and the actual derived Coordinate
660 // class object for that number is created. The arguments to the formatting
661 // function are then passed on to the formatter for that Coordinate. So
662 // refer to the other derived Coordinate classes for specifics on the
663 // formatting.
664 virtual String format(
665 String& units,
667 Double worldValue,
668 uInt worldAxis,
669 Bool isAbsolute=True,
670 Bool showAsAbsolute=True,
671 Int precision=-1, Bool usePrecForMixed=False
672 ) const;
673
674 // Miscellaneous information related to an observation, for example the
675 // observation date.
676 // <group>
678 void setObsInfo(const ObsInfo &obsinfo);
679 // </group>
680
681 // Find the CoordinateSystem (you can safely caste the pointer to a CoordinateSystem)
682 // for when we Fourier Transform ourselves. This pointer
683 // must be deleted by the caller. Axes specifies which pixel axes of the Coordinate
684 // System you wish to transform. Shape specifies the shape of the image
685 // associated with all the axes of the CoordinateSystem. Currently you have
686 // no control over the reference pixel, it is always shape/2.
688 const Vector<Int>& shape) const;
689
690
691 // Save the CoordinateSystem into the supplied record using the supplied field name.
692 // The field must not exist, otherwise <src>False</src> is returned.
693 // If the CoordinateSystem is empty <src>False</src> is also returned.
694 // If <src>False</src> is returned, errorMessage() contains a message about why.
695 virtual Bool save(RecordInterface &container,
696 const String &fieldName) const;
697
698 // Restore the CoordinateSystem from a record. The <src>fieldName</src>
699 // can be empty, in which case the CoordinateSystem is restored
700 // directly from the Record, rather than a subrecord of it.
701 // A null pointer means that the restoration did not succeed - probably
702 // because fieldName doesn't exist or doesn't contain a CoordinateSystem.
703 static CoordinateSystem *restore(const RecordInterface &container,
704 const String &fieldName);
705
706 // Make a copy of the CoordinateSystem using new. The caller is responsible for calling
707 // delete.
708 virtual Coordinate* clone() const;
709
710 // Convert a CoordinateSystem to FITS, i.e. fill in ctype etc. In the record
711 // the keywords are vectors, it is expected that the actual FITS code will
712 // split them into scalars and upcase the names. Returns False if one of the
713 // keywords is already taken.
714 //
715 // If writeWCS is True, attempt to write the WCS convention (Greisen and
716 // Calabretta "Representation of celestial coordinates in FITS").
717 // Use <src>oneRelative=True</src> to convert zero-relative pixel coordinates to
718 // one-relative FITS coordinates.
719 //
720 // prefix gives the prefix for the FITS keywords. E.g.,
721 // if prefix="c" then crval, cdelt etc.
722 // if prefix="d" then drval, ddelt etc.
723 //# Much of the work in to/from fits should be moved to the individual
724 //# classes.
727 Bool oneRelative,
728 Char prefix = 'c', Bool writeWCS=True,
729 Bool preferVelocity=True,
730 Bool opticalVelocity=True,
731 Bool preferWavelength=False,
732 Bool airWavelength=False) const;
733
734 // Probably even if we return False we should set up the best linear
735 // coordinate that we can.
736 // Use oneRelative=True to convert one-relative FITS pixel coordinates to
737 // zero-relative Casacore coordinates.
738 // On output, <src>stokesFITSValue</src>
739 // holds the FITS value of any unofficial Stokes (beam, optical depth,
740 // spectral index) for the last unofficial value accessed (-1 if none).
741 // The idea is that if the Stokes axis is of length one and holds an
742 // unofficial value, you should drop the STokes axis and convert that
743 // value to <src>ImageInfo::ImageTypes</src> with
744 // <src>ImageInfo::imageTypeFromFITSValue</src>.
745 // If on input, <src>stokesFITSValue</src> is positive, then a warning
746 // is issued if any unofficial values are encountered.
747 // Otherwise no warning is issued.
748 //# cf comment in toFITS.
749 static Bool fromFITSHeader(Int& stokesFITSValue,
750 CoordinateSystem &coordsys,
751 RecordInterface& recHeader,
752 const Vector<String>& header,
753 const IPosition& shape,
754 uInt which=0);
755
756// List all header information. By default, the reference
757// values and pixel increments are converted to a "nice" unit before
758// formatting (e.g. RA is shown as HH:MM:SS.S).
759// For spectral axes, both frequency and velocity information is listed. You
760// can specify what velocity definition you want with <src>velocityType</src>
761// If you wish, you can specify two shapes; a lattice and tile shape
762// (perhaps an image from which the CoordinateSystem came)
763// If you give (both of) these, they are included in the listing. If you pass
764// in zero length <src>IPositions</src> then they are not included in
765// the listing. If <src>postlocally=True</src> the formatted summary lines
766// are written locally only to the sink, and then returned by the return value
767// vector.
769 const IPosition& latticeShape,
770 const IPosition& tileShape, Bool postLocally=False) const;
771
772 // Does this coordinate system have a spectral axis?
774
775 // What number is the spectral axis?
776 // If doWorld=True, the world axis number is returned.
777 // Otherwise, the pixel axis number is returned.
778 // Returns -1 if the spectral axis (world c.q. pixel) does not exist.
780
781 // what number is the spectral coordinate?
782 // Returns -1 if no spectral coordinate exists.
784
785
786 // does this coordinate system have a polarizaion/stokes coordinate?
790
791 // Given a stokes or polarization parameter, find the pixel location.
792 // Note the client is responsible for any boundedness checks
793 // (eg finite number of stokes in an image).
794 Int stokesPixelNumber(const String& stokesString) const;
795
796 // what is the number of the polarization/stokes coordinate?
797 // Returns -1 if no stokes coordinate exists.
799
800 // What is the number of the polarization/stokes axis?
801 // If doWorld=True, the world axis number is returned.
802 // Otherwise, the pixel axis number is returned.
803 // Returns -1 if the stokes axis (world c.q. pixel) does not exist.
805
806 // Does this coordinate system have a quality axis?
808
809 // what number is the quality axis? Returns -1 if no quality axis exists.
811
812 // what is the number of the quality coordinate?
813 // Returns -1 if no quality coordinate exists.
815
816 // Given a quality parameter, find the pixel location.
817 // Note the client is responsible for any boundedness checks
818 // (eg finite number of quality in an image).
819 Int qualityPixelNumber(const String& qualityString) const;
820
821 String qualityAtPixel(const uInt pixel) const;
822
824
826
827 // Get the pixel axis numbers of the direction coordinate in this object.
828 // The order of the returned axis numbers is always longitude axis first,
829 // latitude axis second.
831
832 String stokesAtPixel(const uInt pixel) const;
833
835
837
839
840 // Get the 0 based order of the minimal match strings specified in <src>order</src>.
841 // If <src>requireAll</src> is True, checks are done to ensure that all axes in
842 // the coordinate system are uniquely specified in <src>order</src>.
843 // If <src>allowFriendlyNames</src> is True, the following (fully specified) strings
844 // will match the specified axes:
845 // "spectral" matches both "frequency" and "velocity".
846 // "ra" matches "right ascension".
848 Bool allowFriendlyNames=False) const;
849
850 // Is the abscissa in the DirectionCoordinate the longitude axis?
851 // Throws exception if there is no DirectionCoordinate or if either of
852 // the direction pixel axes have been removed.
853 // For a normal direction coordinate, this will return True.
855
856 // Set Spectral conversion layer of SpectralCoordinate in CoordinateSystem
857 // so that pixel<->world go to the specified frequency system (a valid
858 // MFrequency::Types string). Returns False if frequency system invalid
859 // or if no DirectionCoordinate or if cant get Date/Epoch.
860 // <group>
861 Bool setSpectralConversion (String& errorMsg, const String frequencySystem);
862 // This version throws an exception rather than returning False.
863 void setSpectralConversion (const String frequencySystem);
864 //</group>
865
866 // Set rest frequency of SpectralCoordinate in CoordinateSystem.
867 // Unit must be consistent with Hz or m.
868 // Returns False if invalid inputs (and CS not changed) and an error message.
869 Bool setRestFrequency (String& errorMsg, const Quantity& freq);
870
871private:
872 // Where we store copies of the coordinates we are created with.
874
875 // For coordinate[i] axis[j],
876 // world_maps_p[i][j], if >=0 gives the location in the
877 // input vector that maps to this coord/axis,
878 // <0 means that the axis has been removed
879 // world_tmp_p[i] a temporary vector length coord[i]->nworldAxes()
880 // replacement_values_p[i][j] value to use for this axis if removed
884
885 // Same meanings as for the world*'s above.
889
890 // These temporaries all needed for the toMix function
897
898 // Miscellaneous information about the observation associated with this
899 // Coordinate System.
901
902 const static String _class;
903 static std::mutex _mapInitMutex;
904 static std::map<String, String> _friendlyAxisMap;
905
906 static void _initFriendlyAxisMap();
907
908 // Helper functions to group common code.
909 Bool mapOne(Vector<Int>& worldAxisMap,
910 Vector<Int>& worldAxisTranspose,
911 Vector<Bool>& refChange,
912 const CoordinateSystem& cSys,
913 const CoordinateSystem& cSys2,
914 const uInt coord, const uInt coord2) const;
915
916 void copy(const CoordinateSystem &other);
917 void clear();
919
920 // Delete some pointer blocks
923
924 // Delete temporary maps
925 void deleteTemps (const uInt which);
926
927 // Many abs/rel conversions
928 // <group>
931 // </group>
932
933 // Do subImage for Stokes
934 StokesCoordinate stokesSubImage(const StokesCoordinate& sc, Int originShift, Int pixincFac,
935 Int newShape) const;
936
937 // Do subImage for Quality
938 QualityCoordinate qualitySubImage(const QualityCoordinate& qc, Int originShift, Int pixincFac,
939 Int newShape) const;
940
941 // Strip out coordinates with all world and pixel axes removed
943
944 // All these functions are in support of the <src>list</src> function
945 // <group>
946 void listDirectionSystem(LogIO& os) const;
947 void listFrequencySystem(LogIO& os, MDoppler::Types velocityType) const;
948 void listPointingCenter (LogIO& os) const;
949 void getFieldWidths (LogIO& os, uInt& widthAxis, uInt& widthCoordType,
950 uInt& widthCoordNumber, uInt& widthName,
951 uInt& widthProj, uInt& widthShape,
952 uInt& widthTile, uInt& widthRefValue,
953 uInt& widthRefPixel, uInt& widthInc,
954 uInt& widthUnits, Int& precRefValSci,
955 Int& precRefValFloat, Int& precRefValRADEC,
956 Int& precRefPixFloat, Int& precIncSci, String& nameAxis,
957 String& nameCoordType, String& nameCoordNumber, String& nameName, String& nameProj,
958 String& nameShape, String& nameTile,
959 String& nameRefValue, String& nameRefPixel,
960 String& nameInc, String& nameUnits,
961 MDoppler::Types velocityType,
962 const IPosition& latticeShape, const IPosition& tileShape) const;
963
964 void listHeader (LogIO& os, Coordinate* pc, uInt& widthAxis, uInt& widthCoordType, uInt& widthCoordNumber,
965 uInt& widthName, uInt& widthProj,
966 uInt& widthShape, uInt& widthTile, uInt& widthRefValue,
967 uInt& widthRefPixel, uInt& widthInc, uInt& widthUnits,
968 Bool findWidths, Int coordinate, Int axisInCoordinate, Int pixelAxis,
969 Int precRefValSci, Int precRefValFloat, Int precRefValRADEC, Int precRefPixFloat,
970 Int precIncSci, const IPosition& latticeShape, const IPosition& tileShape) const;
971 void listVelocity (LogIO& os, Coordinate* pc, uInt widthAxis,
972 uInt widthCoordType, uInt widthCoordNumber,
973 uInt& widthName, uInt widthProj,
974 uInt widthShape, uInt widthTile, uInt& widthRefValue,
975 uInt widthRefPixel, uInt& widthInc, uInt& widthUnits,
976 Bool findWidths, Int axisInCoordinate, Int pixelAxis,
977 MDoppler::Types velocityType, Int precRefValSci, Int precRefValFloat,
978 Int precRefValRADEC, Int precRefPixFloat, Int precIncSci) const;
979 void clearFlags (LogIO& os) const;
981 MDoppler::Types velocityType, const String& velUnits) const;
982 // </group>
983
984 void _downcase(Vector<String>& vec) const
985 { for (uInt i=0; i<vec.size(); ++i) vec[i].downcase(); }
986
987};
988
989} //# NAMESPACE CASACORE - END
990
991#endif
992
size_t size() const
Definition ArrayBase.h:103
const SpectralCoordinate & spectralCoordinate(uInt which) const
virtual void makeWorldRelative(Vector< Double > &world) const
void setObsInfo(const ObsInfo &obsinfo)
const TabularCoordinate & tabularCoordinate(uInt which) const
const DirectionCoordinate & directionCoordinate(uInt which) const
String coordRecordName(uInt which) const
Return the name of the record field in which the coordinate is stored.
PtrBlock< Vector< Double > * > pixelOut_tmps_p
String qualityAtPixel(const uInt pixel) const
Bool mapOne(Vector< Int > &worldAxisMap, Vector< Int > &worldAxisTranspose, Vector< Bool > &refChange, const CoordinateSystem &cSys, const CoordinateSystem &cSys2, const uInt coord, const uInt coord2) const
Helper functions to group common code.
static Bool fromFITSHeader(Int &stokesFITSValue, CoordinateSystem &coordsys, RecordInterface &recHeader, const Vector< String > &header, const IPosition &shape, uInt which=0)
Probably even if we return False we should set up the best linear coordinate that we can.
Bool replaceCoordinate(const Coordinate &newCoordinate, uInt whichCoordinate)
Replace one Coordinate with another.
Vector< String > list(LogIO &os, MDoppler::Types doppler, const IPosition &latticeShape, const IPosition &tileShape, Bool postLocally=False) const
List all header information.
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 pixel/world coordinate conversion.
Bool velocityIncrement(Double &velocityInc, SpectralCoordinate &sc, MDoppler::Types velocityType, const String &velUnits) const
Int qualityPixelNumber(const String &qualityString) const
Given a quality parameter, find the pixel location.
Bool hasQualityAxis() const
Does this coordinate system have a quality axis?
Bool hasLinearCoordinate() const
PtrBlock< Vector< Bool > * > pixelAxes_tmps_p
static void _initFriendlyAxisMap()
const SpectralCoordinate & spectralCoordinate() const
Int qualityCoordinateNumber() const
what is the number of the quality coordinate? Returns -1 if no quality coordinate exists.
const LinearCoordinate & linearCoordinate(uInt which) const
Return the given Coordinate.
String stokesAtPixel(const uInt pixel) const
Int polarizationCoordinateNumber() const
what is the number of the polarization/stokes coordinate? Returns -1 if no stokes coordinate exists.
virtual Vector< Double > toPixel(const Vector< Double > &world) const
This one throws an exception rather than returning False.
void listDirectionSystem(LogIO &os) const
All these functions are in support of the list function.
virtual void makeWorldAbsolute(Vector< Double > &world) const
static CoordinateSystem * restore(const RecordInterface &container, const String &fieldName)
Restore the CoordinateSystem from a record.
virtual Bool toWorld(Vector< Double > &world, const Vector< Double > &pixel, Bool useConversionFrame=True) const
Convert a pixel position to a world position or vice versa.
void restoreOriginal()
Untranspose and undelete all axes.
virtual uInt nPixelAxes() const
Sums the number of axes in the Coordinates that the CoordinateSystem contains, allowing for removed a...
Bool removeWorldAxis(uInt axis, Double replacement)
Remove a world or pixel axis.
Int polarizationAxisNumber(Bool doWorld=False) const
What is the number of the polarization/stokes axis? If doWorld=True, the world axis number is returne...
Bool convert(Vector< Double > &coordOut, const Vector< Double > &coordin, const Vector< Bool > &absIn, const Vector< String > &unitsIn, MDoppler::Types dopplerIn, const Vector< Bool > &absOut, const Vector< String > &unitsOut, MDoppler::Types dopplerOut, Double pixInOffset=0.0, Double pixOutOffset=0.0)
General coordinate conversion.
QualityCoordinate qualitySubImage(const QualityCoordinate &qc, Int originShift, Int pixincFac, Int newShape) const
Do subImage for Quality.
void findWorldAxis(Int &coordinate, Int &axisInCoordinate, uInt axisInCoordinateSystem) const
Given an axis number (pixel or world) in the CoordinateSystem, find the corresponding coordinate numb...
StokesCoordinate stokesSubImage(const StokesCoordinate &sc, Int originShift, Int pixincFac, Int newShape) const
Do subImage for Stokes.
virtual void makePixelAbsoluteMany(Matrix< Double > &pixel) const
const QualityCoordinate & qualityCoordinate(uInt which) const
CoordinateSystem(const CoordinateSystem &other)
Copying constructor (copy semantics)
Coordinate::Type type(uInt whichCoordinate) const
Return the type of the given Coordinate.
Vector< Int > pixelAxes(uInt whichCoord) const
Int pixelAxisToWorldAxis(uInt pixelAxis) const
Find the world axis for the given pixel axis in a CoordinateSystem.
virtual Bool setWorldMixRanges(const IPosition &shape)
Compute and recover the world min and max ranges, for use in function toMix, for a lattice of the giv...
PtrBlock< Coordinate * > coordinates_p
Where we store copies of the coordinates we are created with.
void cleanUpSpecCoord(PtrBlock< SpectralCoordinate * > &in, PtrBlock< SpectralCoordinate * > &out)
Delete some pointer blocks.
virtual Coordinate::Type type() const
Returns Coordinate::COORDSYS
CoordinateSystem subImage(const Vector< Float > &originShift, const Vector< Float > &incrFac, const Vector< Int > &newShape) const
Return a CoordinateSystem appropriate for a shift of origin (the shift is subtracted from the referen...
void deleteTemps(const uInt which)
Delete temporary maps.
String showType(uInt whichCoordinate) const
Returns the type of the given Coordinate as a string.
PtrBlock< Vector< Double > * > world_tmps_p
virtual Bool near(const Coordinate &other, Double tol=1e-6) const
Comparison function.
PtrBlock< Block< Int > * > pixel_maps_p
Same meanings as for the world*'s above.
virtual Bool setIncrement(const Vector< Double > &inc)
uInt nCoordinates() const
Returns the number of Coordinates that this CoordinateSystem contains.
Bool removePixelAxis(uInt axis, Double replacement)
Vector< Int > getWorldAxesOrder(Vector< String > &myNames, Bool requireAll, Bool allowFriendlyNames=False) const
Get the 0 based order of the minimal match strings specified in order.
virtual Bool setWorldAxisUnits(const Vector< String > &units)
Set/get the units.
PtrBlock< Vector< Double > * > pixel_tmps_p
virtual Vector< Double > increment() const
static std::map< String, String > _friendlyAxisMap
Bool setSpectralConversion(String &errorMsg, const String frequencySystem)
Set Spectral conversion layer of SpectralCoordinate in CoordinateSystem so that pixel<->world go to t...
Int findCoordinate(Coordinate::Type type, Int afterCoord=-1) const
Find the Coordinate number that corresponds to the given type.
const StokesCoordinate & stokesCoordinate() const
virtual Vector< Double > toWorld(const Vector< Double > &pixel) const
This one throws an exception rather than returning False.
Bool toWorld(Vector< Double > &world, const IPosition &pixel) const
This is provided as a convenience since it is a very commonly desired operation through CoordinateSys...
const StokesCoordinate & stokesCoordinate(uInt which) const
virtual void makePixelRelative(Vector< Double > &pixel) const
Make absolute coordinates relative and vice-versa (relative to the reference pixel/value).
virtual Vector< Double > referenceValue() const
Bool setWorldAxisUnits(const Vector< String > &units, Bool throwException)
void listPointingCenter(LogIO &os) const
void addCoordinate(const Coordinate &coord)
Add another Coordinate to this CoordinateSystem.
Int spectralAxisNumber(Bool doWorld=False) const
What number is the spectral axis? If doWorld=True, the world axis number is returned.
void listFrequencySystem(LogIO &os, MDoppler::Types velocityType) const
virtual String showType() const
Always returns "System".
void transpose(const Vector< Int > &newWorldOrder, const Vector< Int > &newPixelOrder)
Transpose the CoordinateSystem so that world axis 0 is newWorldOrder(0) and so on for all the other a...
virtual Vector< Double > referencePixel() const
virtual Bool setWorldAxisNames(const Vector< String > &names)
Set the requested attribute.
ObsInfo obsInfo() const
Miscellaneous information related to an observation, for example the observation date.
Vector< Int > linearAxesNumbers() const
Bool checkAxesInThisCoordinate(const Vector< Bool > &axes, uInt which) const
PtrBlock< Vector< Double > * > worldMin_tmps_p
virtual Vector< String > worldAxisUnits() const
virtual void makePixelRelativeMany(Matrix< Double > &pixel) const
Batch up a lot of absolute/relative transformations.
static std::mutex _mapInitMutex
PtrBlock< Vector< Bool > * > worldAxes_tmps_p
These temporaries all needed for the toMix function.
virtual Vector< Double > worldMixMin() const
virtual void makeWorldRelativeMany(Matrix< Double > &world) const
virtual Bool setReferencePixel(const Vector< Double > &refPix)
void makePixelAbsRelMany(Matrix< Double > &value, Bool toAbs) const
virtual Bool setLinearTransform(const Matrix< Double > &xform)
virtual Bool save(RecordInterface &container, const String &fieldName) const
Save the CoordinateSystem into the supplied record using the supplied field name.
void _downcase(Vector< String > &vec) const
Vector< Int > worldAxes(uInt whichCoord) const
For a given Coordinate say where its world and pixel axes are in this CoordinateSystem.
virtual Coordinate * makeFourierCoordinate(const Vector< Bool > &axes, const Vector< Int > &shape) const
Find the CoordinateSystem (you can safely caste the pointer to a CoordinateSystem) for when we Fourie...
Int worldAxisToPixelAxis(uInt worldAxis) const
Find the pixel axis for the given world axis in a CoordinateSystem.
Bool pixelMap(Vector< Int > &pixelAxisMap, Vector< Int > &pixelAxisTranspose, const CoordinateSystem &cSys) const
virtual String format(String &units, Coordinate::formatType format, Double worldValue, uInt worldAxis, Bool isAbsolute=True, Bool showAsAbsolute=True, Int precision=-1, Bool usePrecForMixed=False) const
Format a world value nicely through the common format interface.
const DirectionCoordinate & directionCoordinate() const
Bool setRestFrequency(String &errorMsg, const Quantity &freq)
Set rest frequency of SpectralCoordinate in CoordinateSystem.
Bool toFITSHeader(RecordInterface &header, IPosition &shape, Bool oneRelative, Char prefix='c', Bool writeWCS=True, Bool preferVelocity=True, Bool opticalVelocity=True, Bool preferWavelength=False, Bool airWavelength=False) const
Convert a CoordinateSystem to FITS, i.e.
virtual Bool setReferenceValue(const Vector< Double > &refval)
Bool hasDirectionCoordinate() const
virtual void makePixelAbsolute(Vector< Double > &pixel) const
virtual ~CoordinateSystem()
Destructor.
Int stokesPixelNumber(const String &stokesString) const
Given a stokes or polarization parameter, find the pixel location.
virtual uInt nWorldAxes() const
Bool hasPolarizationCoordinate() const
does this coordinate system have a polarizaion/stokes coordinate?
void subImageInSitu(const Vector< Float > &originShift, const Vector< Float > &incrFac, const Vector< Int > &newShape)
PtrBlock< Block< Int > * > world_maps_p
For coordinate[i] axis[j], world_maps_p[i][j], if >=0 gives the location in the input vector that map...
Bool nearPixel(const CoordinateSystem &other, Double tol=1e-6) const
This function compares this and the other coordinate system, but ONLY for the non-removed pixel axes.
virtual Vector< String > worldAxisNames() const
Return the requested attribute.
Bool isDirectionAbscissaLongitude() const
Is the abscissa in the DirectionCoordinate the longitude axis? Throws exception if there is no Direct...
void findPixelAxis(Int &coordinate, Int &axisInCoordinate, uInt axisInCoordinateSystem) const
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.
PtrBlock< Vector< Double > * > worldOut_tmps_p
PtrBlock< Vector< Double > * > worldMax_tmps_p
void setSpectralConversion(const String frequencySystem)
This version throws an exception rather than returning False.
void listHeader(LogIO &os, Coordinate *pc, uInt &widthAxis, uInt &widthCoordType, uInt &widthCoordNumber, uInt &widthName, uInt &widthProj, uInt &widthShape, uInt &widthTile, uInt &widthRefValue, uInt &widthRefPixel, uInt &widthInc, uInt &widthUnits, Bool findWidths, Int coordinate, Int axisInCoordinate, Int pixelAxis, Int precRefValSci, Int precRefValFloat, Int precRefValRADEC, Int precRefPixFloat, Int precIncSci, const IPosition &latticeShape, const IPosition &tileShape) const
PtrBlock< Vector< Double > * > world_replacement_values_p
virtual Vector< Double > worldMixMax() const
void copy(const CoordinateSystem &other)
Int spectralCoordinateNumber() const
what number is the spectral coordinate? Returns -1 if no spectral coordinate exists.
Bool worldMap(Vector< Int > &worldAxisMap, Vector< Int > &worldAxisTranspose, Vector< Bool > &refChange, const CoordinateSystem &cSys) const
Find the world and pixel axis mappings to the supplied CoordinateSystem from the current coordinate s...
virtual Bool toPixel(Vector< Double > &pixel, const Vector< Double > &world) const
CoordinateSystem()
Default constructor.
void listVelocity(LogIO &os, Coordinate *pc, uInt widthAxis, uInt widthCoordType, uInt widthCoordNumber, uInt &widthName, uInt widthProj, uInt widthShape, uInt widthTile, uInt &widthRefValue, uInt widthRefPixel, uInt &widthInc, uInt &widthUnits, Bool findWidths, Int axisInCoordinate, Int pixelAxis, MDoppler::Types velocityType, Int precRefValSci, Int precRefValFloat, Int precRefValRADEC, Int precRefPixFloat, Int precIncSci) const
void getFieldWidths(LogIO &os, uInt &widthAxis, uInt &widthCoordType, uInt &widthCoordNumber, uInt &widthName, uInt &widthProj, uInt &widthShape, uInt &widthTile, uInt &widthRefValue, uInt &widthRefPixel, uInt &widthInc, uInt &widthUnits, Int &precRefValSci, Int &precRefValFloat, Int &precRefValRADEC, Int &precRefPixFloat, Int &precIncSci, String &nameAxis, String &nameCoordType, String &nameCoordNumber, String &nameName, String &nameProj, String &nameShape, String &nameTile, String &nameRefValue, String &nameRefPixel, String &nameInc, String &nameUnits, MDoppler::Types velocityType, const IPosition &latticeShape, const IPosition &tileShape) const
virtual Bool toPixelMany(Matrix< Double > &pixel, const Matrix< Double > &world, Vector< Bool > &failures) const
CoordinateSystem stripRemovedAxes(const CoordinateSystem &cSys) const
Strip out coordinates with all world and pixel axes removed.
Vector< Int > directionAxesNumbers() const
Get the pixel axis numbers of the direction coordinate in this object.
const Coordinate & coordinate(uInt which) const
Return the given Coordinate as a reference to the base class object.
Int directionCoordinateNumber() const
Bool convert(Matrix< Double > &coordOut, const Matrix< Double > &coordIn, const Vector< Bool > &absIn, const Vector< String > &unitsIn, MDoppler::Types dopplerIn, const Vector< Bool > &absOut, const Vector< String > &unitsOut, MDoppler::Types dopplerOut, Double pixInOffset=0.0, Double pixOutOffset=0.0)
virtual Bool near(const Coordinate &other, const Vector< Int > &excludePixelAxes, Double tol=1e-6) const
virtual Coordinate * clone() const
Make a copy of the CoordinateSystem using new.
virtual Bool toWorldMany(Matrix< Double > &world, const Matrix< Double > &pixel, Vector< Bool > &failures) const
Batch up a lot of transformations.
virtual Quantity toWorldLength(const Double nPixels, const uInt pixelAxis) const
convert a pixel "length" to a world "length"
PtrBlock< Vector< Double > * > pixel_replacement_values_p
Vector< Double > toWorld(const IPosition &pixel) const
Int linearCoordinateNumber() const
virtual void setDefaultWorldMixRanges()
virtual void makeWorldAbsoluteMany(Matrix< Double > &world) const
void makeWorldAbsRelMany(Matrix< Double > &value, Bool toAbs) const
Many abs/rel conversions.
Bool hasSpectralAxis() const
Does this coordinate system have a spectral axis?
ObsInfo obsinfo_p
Miscellaneous information about the observation associated with this Coordinate System.
CoordinateSystem & operator=(const CoordinateSystem &other)
Assignment (copy semantics).
Int qualityAxisNumber() const
what number is the quality axis? Returns -1 if no quality axis exists.
void clearFlags(LogIO &os) const
virtual Matrix< Double > linearTransform() const
Type
This enum lists the types of the derived classes.
Definition Coordinate.h:141
formatType
This enum is used for formatting world values into Strings.
Definition Coordinate.h:159
Types
Types of known MDopplers Warning: The order defines the order in the translation matrix FromTo in th...
Definition MDoppler.h:146
A drop-in replacement for Block<T*>.
Definition Block.h:812
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
TableExprNode downcase(const TableExprNode &node)
Definition ExprNode.h:1477
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
char Char
Definition aipstype.h:44