casacore
Loading...
Searching...
No Matches
LinearXform.h
Go to the documentation of this file.
1//# LinearXform.h: Perform a linear transform between input and output vectors
2//# Copyright (C) 1997-2003
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_LINEARXFORM_H
27#define COORDINATES_LINEARXFORM_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/casa/Arrays/ArrayFwd.h>
31
32#include <wcslib/lin.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36class String;
37
38// <summary>
39// Perform a linear transform between input and output vectors
40// </summary>
41
42// <use visibility=local>
43
44// <reviewed reviewer="Peter Barnes" date="1999/12/24" tests="tLinearXform">
45// </reviewed>
46
47// <prerequisite>
48// <li> General knowledge of Casacore Arrays
49// <li> Knowledge of FITS terminology in coordinate transformations
50// </prerequisite>
51//
52// <synopsis>
53// This class represents the common linear part of a FITS coordinate
54// transformation. In particular it does the following:
55// <srcblock>
56// world = cdelt * PC * (pixel - crpix)
57// </srcblock>
58// Where PC is an NxN matrix; pixel, crpix (reference pixel) and world are
59// length N vectors; and cdelt (increment) is an NxN diagonal matrix,
60// represented as a length N vector.
61//
62// Normally this class isn't used directly, rather it is used indirectly through
63// a class like <linkto class=LinearCoordinate>LinearCoordinate</linkto>.
64//
65// The actual computations are performed by WCSLIB, written by Mark Calabretta
66// of the ATNF.
67// </synopsis>
68//
69// <example>
70// Let's make a LinearXform housing two axes with a unit
71// diagonal PC matrix and convert from pixel to world
72//
73// <srcblock>
74// Vector<Double> crpix(2), cdelt(2);
75// crpix(0) = 10.0; crpix(1) = 20.0;
76// cdelt(0) = 1.0; cdelt(1) = -1.0;
77// LinearXform lxf(crpix, cdelt);
78//
79// String errMsg;
80// Vector<Double> world, pixel(2);
81// pixel = 10.0;
82// Bool ok = lxf.reverse(world, pixel, errMsg);
83// if (ok) {
84// cerr << "pixel, world = " << pixel << world << endl;
85// } else {
86// cerr << "Error : " << errMsg << endl;
87// }
88// </srcblock>
89// The answer should be a world vector with values 0 and -10.
90// </example>
91//
92// <motivation>
93// Factor out the common linear part of coordinate transformations.
94// </motivation>
95//
96// <thrown>
97// <li> AipsError
98// </thrown>
99//
100// <todo asof="1997/01/13">
101// <li> Allow different numbers of pixel and world axes.
102// </todo>
103//
104
105
107{
108public:
109 // Construct with specified number of axes. The reference pixel is
110 // assumed to be 0, and the increment is assumed to be unity, and the
111 // PC matrix is assumed to be diagonal.
113
114 // Construct the linear transformation from the supplied reference pixel
115 // and increment. The PC matrix is the unit matrix.
116 // <src>crpix</src> and <src>cdelt</src> must have the same number
117 // of elements.
119
120 // Construct a linear transformation, supplying all of the reference pixel,
121 // increment and PC matrix.
122 // The vectors must be of the same length ("n") and the number of rows and
123 // columns in the matrix must also be n.
125 const Matrix<Double> &pc);
126
127 // Copy constructor (copy sematics)
129
130 // Assignment (copy sematics)
132
133 // Destructor
135
136 // Returns the number of world axes, which for this class is also the
137 // number of pixel axes.
139
140 // Convert world coordinates to pixel coordinates (forward), or pixel
141 // coordinates to world (reverse). If the conversion works True is returned,
142 // otherwise False is returned and errorMsg is set. The output vectors
143 // are resized appropriately.
144 // <group>
146 String &errorMsg) const;
148 String &errorMsg) const;
149 // </group>
150
151 // Retrieve the value of crpix, cdelt, and pc.
152 // <group>
156 // </group>
157
158 // Set the value of crpix, cdelt, and pc. Note that since you can only
159 // set one of them, you cannot change the dimensionality of the transform
160 // using these functions. Instead use assignment on a temporary, i.e.:
161 // <src> linxform = LinearXform (crpix,crval,pc); </src>
162 // <group>
163 void crpix(const Vector<Double> &newvals);
164 void cdelt(const Vector<Double> &newvals);
165 void pc(const Matrix<Double> &newvals);
166 // </group>
167
168 // Invert the LinearXform ready for use in a Fourier Transformed Coordinate.
169 // It is the callers responsibility to delete the pointer. If it fails
170 // the pointer is 0 and an error message is provided
172 const Vector<Double>& crpix,
173 const Vector<Double>& scale) const;
174
175 // Comparison function. Any private Double data members are compared
176 // with the specified fractional tolerance. You can specify axes to
177 // exclude from the comparison if you wish.
178 // <group>
179 Bool near(const LinearXform& other,
180 Double tol=1e-6) const;
181 Bool near(const LinearXform& other,
182 const Vector<Int>& excludeAxes,
183 Double tol=1e-6) const;
184 // </group>
185
186private:
187 // A WCSLIB C-structure.
188 mutable linprm linprm_p;
189
192};
193
194} //# NAMESPACE CASACORE - END
195
196#endif
void cdelt(const Vector< Double > &newvals)
Matrix< Double > pc() const
Vector< Double > crpix() const
Retrieve the value of crpix, cdelt, and pc.
LinearXform(const Vector< Double > &crpix, const Vector< Double > &cdelt)
Construct the linear transformation from the supplied reference pixel and increment.
uInt nWorldAxes() const
Returns the number of world axes, which for this class is also the number of pixel axes.
LinearXform(const Vector< Double > &crpix, const Vector< Double > &cdelt, const Matrix< Double > &pc)
Construct a linear transformation, supplying all of the reference pixel, increment and PC matrix.
Vector< Double > cdelt() const
LinearXform * fourierInvert(String &errMsg, const Vector< Bool > &axes, const Vector< Double > &crpix, const Vector< Double > &scale) const
Invert the LinearXform ready for use in a Fourier Transformed Coordinate.
void crpix(const Vector< Double > &newvals)
Set the value of crpix, cdelt, and pc.
LinearXform(uInt naxis=1)
Construct with specified number of axes.
~LinearXform()
Destructor.
LinearXform(const LinearXform &other)
Copy constructor (copy sematics)
Bool forward(Vector< Double > &pixel, const Vector< Double > &world, String &errorMsg) const
Convert world coordinates to pixel coordinates (forward), or pixel coordinates to world (reverse).
LinearXform & operator=(const LinearXform &other)
Assignment (copy sematics)
Bool near(const LinearXform &other, const Vector< Int > &excludeAxes, Double tol=1e-6) const
Bool reverse(Vector< Double > &world, const Vector< Double > &pixel, String &errorMsg) const
linprm linprm_p
A WCSLIB C-structure.
Bool near(const LinearXform &other, Double tol=1e-6) const
Comparison function.
void pc(const Matrix< Double > &newvals)
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
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
double Double
Definition aipstype.h:53