casacore
Loading...
Searching...
No Matches
coordinates
Coordinates.h
Go to the documentation of this file.
1
// # Coordinates.h : Classes to interconvert computation positions with physical
2
// # Copyright (C) 1996,1997,1998,1999,2000,2001
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_COORDINATES_H
27
#define COORDINATES_COORDINATES_H
28
29
// # Module includes
30
#include <casacore/casa/aips.h>
31
#include <casacore/coordinates/Coordinates/Coordinate.h>
32
#include <casacore/coordinates/Coordinates/CoordinateSystem.h>
33
#include <casacore/coordinates/Coordinates/DirectionCoordinate.h>
34
#include <casacore/coordinates/Coordinates/LinearCoordinate.h>
35
#include <casacore/coordinates/Coordinates/LinearXform.h>
36
#include <casacore/coordinates/Coordinates/Projection.h>
37
#include <casacore/coordinates/Coordinates/SpectralCoordinate.h>
38
#include <casacore/coordinates/Coordinates/StokesCoordinate.h>
39
#include <casacore/coordinates/Coordinates/TabularCoordinate.h>
40
#include <casacore/coordinates/Coordinates/CoordinateUtil.h>
41
42
namespace
casacore
{
// # NAMESPACE CASACORE - BEGIN
43
44
// <module>
45
//
46
// <summary>
47
// Classes to interconvert pixel and world (physical) coordinates
48
// </summary>
49
50
// <prerequisite>
51
// <li> Knowledge of astronomical coordinate conversions in general. Probably the
52
// best documents are the papers by Mark Calabretta and Eric Greisen.
53
// The initial draft from 1996 can be found at
54
// http://www.atnf.csiro.au/~mcalabre. It is this draft that the
55
// Coordinate classes are based upon. Since then, this paper has evolved
56
// into three which can be found at the above address, and will be published in the
57
// Astronomy and Astrophysics Supplement Series (probably in 2000).
58
// The design has changed since the initial draft. When these papers
59
// are finalized, and the IAU has ratified the new standards, WCSLIB
60
// (Mark Calabretta's implementation of these conventions) will be
61
// revised for the new designs. At that time, the Coordinate classes
62
// may also be revised.
63
// <li> Generic Casacore classes; especially those in the
64
// <linkto module=Arrays>Arrays</linkto> module.
65
// <li> The <linkto module=Measures>Measures</linkto> module.
66
// </prerequisite>
67
//
68
69
// <reviewed reviewer="Peter Barnes" date="1999/12/24">
70
// </reviewed>
71
72
// <synopsis>
73
// The primary notion is that a <linkto class=Coordinate>Coordinate</linkto>
74
// can interconvert between a length "n" Vector<Double> (the
75
// pixel coordinate) and a length "m" Vector<Double> (the
76
// "world" coordinate). Note that "m" and "n" do not in
77
// principle have to be the same (so that one can get both the RA and DEC from
78
// an image slice, for example), however in practice they currently always are.
79
// Each Coordinate has the full mapping from pixel to world coordinates, i.e.
80
// it has a reference value, reference pixel, increments, and an arbitrary
81
// transformation matrix. To go from a pixel to a world coordinate the following
82
// steps are applied:
83
// <ol>
84
// <li> The reference pixel is subtracted from the pixel position.
85
// <li> The result is multiplied by the transformation matrix.
86
// <li> The result is multiplied by an increment per output axis to convert
87
// it into physical coordinates.
88
// <li> For some coordinate types (e.g., Direction), a non-linear function is
89
// applied to this result.
90
// </ol>
91
//
92
// The classes are arranged as follows. The base class is
93
// <linkto class=Coordinate>Coordinate</linkto> which defines the
94
// interface. Classes derived from it are
95
// <ol>
96
// <li> <linkto class=DirectionCoordinate>DirectionCoordinate</linkto>
97
// <li> <linkto class=LinearCoordinate>LinearCoordinate</linkto>
98
// <li> <linkto class=SpectralCoordinate>SpectralCoordinate</linkto>
99
// <li> <linkto class=TabularCoordinate>TabularCoordinate</linkto>
100
// <li> <linkto class=StokesCoordinate>StokesCoordinate</linkto>
101
// <li> <linkto class=CoordinateSystem>CoordinateSystem</linkto>
102
// </ol>
103
//
104
// Other classes are <linkto class=Projection>Projection</linkto>
105
// which is used to specify an astronomical projection for
106
// DirectionCoordinates, and <linkto class=LinearXform>LinearXform</linkto>
107
// a helper class which the application programmer will not interact with.
108
//
109
// <linkto class=CoordinateSystem>CoordinateSystem</linkto> is
110
// the class that application programmers will usually interact
111
// with. A CoordinateSystem consists of a collection of the other
112
// classes derived from Coordinate. Normally one group will be for
113
// RA/DEC, another for a Stokes axis, and another group for the spectral axis.
114
// The axes may be transposed arbitrarily, for example RA could be
115
// the first axis, and DEC the third.
116
//
117
// Normally the CoordinateSystem being manipulated will be embedded in a PagedImage
118
// or other object. Note that the axes of the PagedImage do not
119
// necessarily map directly to the axes in the CoordinateSystem. Functionality
120
// is provided to determine this mapping.
121
//
122
// One or more axes from the CoordinateSystem may be removed. Pixel axes and/or
123
// world axes may be removed. You are encouraged to leave all the world axes
124
// when you remove pixel axes.
125
// <br>
126
// If a world axis is removed, the corresponding pixel axis is also removed.
127
// This means that one can be sure that a pixel axis always has a
128
// corresponding world axis (it makes no sense otherwise). The opposite is
129
// not necessarily true: a world axis can exist without a pixel axis.
130
//
131
// The linear transformation and sky projection computations are carried out in an
132
// underlying library -- WCSLIB -- written by Mark Calabretta of the ATNF.
133
//
134
// </synopsis>
135
//
136
//
137
// <note role=caution>
138
// All pixels coordinates are zero relative.
139
// </note>
140
//
141
// <example>
142
// First, let's make a DirectionCoordinate --- used to represent a direction,
143
// usually an RA/DEC, but it could also be, e.g., an AZ/EL pair.
144
// <srcblock>
145
// Matrix<Double> xform(2,2); // 1
146
// xform = 0.0; xform.diagonal() = 1.0; // 2
147
// Quantum<Double> refLon(135.0, "deg");
148
// Quantum<Double> refLat(60.0, "deg");
149
// Quantum<Double> incLon(-1.0, "deg");
150
// Quantum<Double> incLat(1.0, "deg");
151
// DirectionCoordinate radec(MDirection::J2000, // 3
152
// Projection(Projection::SIN), // 4
153
// refLon, refLat, // 5
154
// incLon, incLat, // 6
155
// xform, // 7
156
// 128, 128); // 8
157
// </srcblock>
158
// <ul>
159
// <li> <i>1-2:</i>Here we set up a diagonal transformation matrix.
160
// Normally this matrix should be diagonal, however if you wanted
161
// to introduce a rotation or skew, you would do it through this
162
// matrix.
163
// <li> <i>3:</i>This defines the astronomical type of the world
164
// coordinate. Most of the time it will probably be J2000
165
// or B1950, but there are many other possibilities as listed
166
// in the <linkto class=MDirection>MDirection</linkto> class
167
// header.
168
// <li> <i>4:</i>The <linkto class=Projection>Projection</linkto> class
169
// defines the "geometry" that is used to map <src>xy<-->world</src>. SIN
170
// is the most common projection for radio interferometers. Note that
171
// SIN can optionally take parameters as defined in Calabretta and Greisen.
172
// If not provided, they default to 0.0, which is the "old" SIN
173
// convention.
174
// <li> <i>5:</i>Set the reference position to RA=135, DEC=60 degrees.
175
// Note that the native units of a DirectionCoordinate is radians.
176
// <li> <i>6:</i> Set the increments to -1 degree in RA, and +1 degree
177
// in DEC.
178
// <li> <i>7:</i> Set the previously defined transformation matrix.
179
// <li> <i>8:</i> Set the zero-relative reference pixel. Note that it does
180
// not have to be incremental. At the reference pixel, the world
181
// coordinate has the reference value.
182
// </ul>
183
//
184
// Although we happeend to create our DirectionCoordinate with Quanta in degrees,
185
// these have been converted to radians by the constructor. We can set the native units
186
// to degrees if we wish as follows:
187
// <srcblock>
188
// Vector<String> units(2); units = "deg"; // 9
189
// radec.setWorldAxisUnits(units); // 10
190
// </srcblock>
191
// The increment and reference value are updated appropriately.
192
//
193
// Set up a couple of vectors to use the world and pixel coordinate values.
194
// <srcblock>
195
// Vector<Double> world(2), pixel(2); // 11
196
// pixel = 138.0; // 12
197
// </srcblock>
198
// We use 138 as an abitrary pixel position which is near the reference pixel
199
// so we can tell if the answers look foolish or not.
200
//
201
// We can actually perform a transformation like this as follows. If
202
// it succeeds we print the value of the world coordinate.
203
// <srcblock>
204
// Bool ok = radec.toWorld(world, pixel); // 13
205
// if (!ok) { // 14
206
// cout << "Error: " << radec.errorMessage() << endl; // 15
207
// return 1; // 16
208
// } // 17
209
// cout << world << " <--- " << pixel << endl; // 18
210
// </srcblock>
211
// There is an overloaded "toWorld" function that produces an MDirection
212
// in case you want to, e.g., find out what the position in B1950 coordinates
213
// would be.
214
//
215
// The reverse transformation takes place similarly:
216
// <srcblock>
217
// ok = radec.toPixel(pixel, world); // 19
218
// </srcblock>
219
//
220
// Suppose we have an image with a Stokes axis. It can be set up as follows:
221
// <srcblock>
222
// Vector<Int> iquv(4);
223
// iquv(0) = Stokes::I; iquv(1) = Stokes::Q; // 21
224
// iquv(2) = Stokes::U; iquv(3) = Stokes::V; // 22
225
// StokesCoordinate stokes(iquv); // 23
226
// </srcblock>
227
// We create an integer array the same length as the Stokes axis, and place
228
// the corresponding Stokes enum into each element of the array. The values
229
// must be unique, e.g. there can only be one "I" plane.
230
// Besides the generic <src>Vector<Double></src> toWorld/toPixel interface,
231
// you can also directly interconvert between Stokes enum and and (zero-relative)
232
// plane number:
233
// <srcblock>
234
// Int plane; // 24
235
// ok = stokes.toPixel(plane, Stokes::Q); // 25
236
// </srcblock>
237
// Here it will return <src>True</src> and set plane to 1. On the other
238
// hand, it would return <src>False</src> for:
239
// <srcblock>
240
// ok = stokes.toPixel(plane, Stokes::XX); // 26
241
// </srcblock>
242
// since "XX" is not one of the Stokes enumerations we used to create this
243
// coordinate.
244
//
245
// A Spectral ("frequency") coordinate may be created as follows:
246
// <srcblock>
247
// SpectralCoordinate spectral(MFrequency::TOPO, // 27
248
// 1.4E+9, // 28
249
// 2.0E+4, // 29
250
// 0, // 30
251
// 1420.40575E+6); // 31
252
// </srcblock>
253
// The default frequency units of a spectral coordinate are Hz, although they
254
// may be changed to whatever is convenient. The first line (27) defines the
255
// type of frequency we have -- topocentric here. The second (28) line
256
// defines the frequency at the reference pixel, 0 (28) here. The channel
257
// increment is defined on line 29. A rest frequency of the spectral may
258
// be provided. It is useful in calculating doppler velocities. These calculations
259
// are carried out by the <linkto class=MFrequency>MFrequency</linkto> and
260
// <linkto class=MDoppler>MDoppler</linkto> classes of the Measures system.
261
// </example>
262
//
263
// <motivation>
264
// The primary motivation is to provide support for converting pixel locations in an
265
// image to physical ("world") positions.
266
// </motivation>
267
268
// <todo asof="2000/01/01">
269
// <li> Add measures interfaces that handle reference frame conversions
270
// <li> offset coordinates
271
// </todo>
272
273
// </module>
274
275
}
// namespace casacore
276
277
#endif
casacore
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition
mainpage.dox:28
Generated by
1.15.0