casacore
Loading...
Searching...
No Matches
UVWMachine.h
Go to the documentation of this file.
1// # UVWMachine.h: Converts UVW coordinates between coordinate systems
2// # Copyright (C) 1998,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#ifndef MEASURES_UVWMACHINE_H
26#define MEASURES_UVWMACHINE_H
27
28// # Includes
29#include <casacore/casa/aips.h>
30#include <casacore/casa/Arrays/ArrayFwd.h>
31#include <casacore/measures/Measures.h>
32#include <casacore/measures/Measures/MCDirection.h>
33#include <casacore/casa/Quanta/MVPosition.h>
34#include <casacore/casa/Quanta/RotMatrix.h>
35
36namespace casacore { // # NAMESPACE CASACORE - BEGIN
37
38// # Forward Declarations
39class MeasFrame;
40
41// <summary> Converts UVW coordinates between coordinate systems </summary>
42
43// <use visibility=export>
44
45// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tUVWMachine.cc" demos="">
46// </reviewed>
47
48// <prerequisite>
49// <li> <linkto class=MDirection>MDirection</linkto> class
50// </prerequisite>
51//
52// <etymology>
53// From UVW coordinates and machinery
54// </etymology>
55//
56// <synopsis>
57// The construction of a UVWMachine class object creates a machine that can
58// convert UVW coordinates from one coordinate system to another. In addition
59// it can also supply the phase rotation necessary to move to a new position.
60//
61// The constructors need an input
62// <linkto class=MDirection>MDirection</linkto> to specify the input UVW
63// coordinates reference direction and coordinate system.
64// An EW flag can be specified to indicate the different type of UVW
65// coordinates. I.e. projection along polar axis rather than towards
66// observing direction (not implemented yet).
67// A project flag, if set, will re-project the resulting UV plane onto the
68// in-direction reference plane.
69//
70// The constructors also need an output coordinate system
71// (<linkto class=MeasRef>MDirection::Ref</linkto>) or an output
72// MDirection (including the reference coordinate system). The first case
73// indicates that the real position on the sky does not change (only the
74// coordinate system used); the second indicates that the UVW should be
75// for a new position on the sky (in addition to maybe a different
76// coordinate system). In the first case only the UVW coordinates will change,
77// in the second the UVW positions will change, but also the phase of the
78// observed data will have to change. For some conversions a reference
79// <linkto class=MeasFrame>frame</linkto> is needed (to indicate e.g. the
80// position or time). This frame can be part of one of the constructor
81// references, but can also be specified separately in the constructor. A
82// change in the frame parameter can be made outside the UVWMachine
83// by e.g. <em>frame.reset(anMEpoch)</em>.
84// <note role=caution>
85// If the frame is changed by the user of the conversion machine, the
86// machine has to be reinitialised before using it for output by using
87// <tt>reCalculate()</tt>.
88//
89// Projection entails a rotation. For changes to a fixed frame (i.e. not
90// changing with e.g. time), the rotation matrix is calculated only once. In
91// other cases it has to be calculated per series of uvw conversions. The
92// latter case can hence be time consuming.
93// </note>
94// <note role=tip>
95// If either the input or output direction/reference specifies a planet, action
96// is special. Planets are assumed to be in J2000 positions, since that is
97// the only way to carry them from conversion to conversion (and also have a
98// variable phase-center; which can, btw, always be obtained by the
99// phaseCenter() member).</note>
100// Note that a reCalculate() is necessary between calls of the engine,
101// since the planetary position will change from time to time (i.e. with
102// the Frame).
103//
104// If no explicit output coordinate is given (i.e. no phase shift necessary),
105// and the conversion from input to output is an essential NOP, and no
106// reprojection to the input plane is required, the machine will bypass all
107// calculations. This state can be inspected by the <src>isNOP()</src> method.
108//
109// If you want to convert to say an azimuth/elevation map of the Sun, this
110// can be done to have either two conversion engines (original to Sun, then
111// Sun to AzEl), or by conversion of the Sun to AzEl before entering the
112// engine.
113// <note role=tip>
114// The output of the machine is either a set of rotation matrices that can
115// be used to convert UVW coordinates (and, if necessary, phases); or the
116// UVW conversion and actual phase can be calculated from a given
117// UVW coordinate (or set of coordinates).
118// </note>
119// <note role=tip> Since e.g. in an EW interferometer (or any set of baselines
120// on a line) the phase correction and UVW transform scales with the length
121// of the baseline, conversion of a nominal (say 1m) baseline suffices to
122// easily calculate others. The same is true for baselines in a plane,
123// where a conversion of two orthogonal baselines in that plane will suffice.
124// </note>
125// </synopsis>
126//
127// <example>
128// <srcblock>
129// // Given a current phase stopping Center
130// MDirection indir(Quantity(3.25745692, "rad"),
131// Quantity(0.040643336,"rad"),
132// MDirection::Ref(MDirection::B1950));
133// // Conversion to J2000 is set by:
134// UVWMachine uvm(MDirection::Ref(MDirection::J2000), indir);
135// // The rotation matrix to go to new UVW is obtained by:
136// RotMatrix rm(uvm.rotationUVM());
137// // If an UVW specified:
138// MVPosition uvw(-739.048461, -1939.10604, 1168.62562);
139// // This can be converted by e.g.:
140// uvw *= rm;
141// // Or, alternatively, by e.g.:
142// uvm.convertUVW(uvw);
143// </srcblock>
144// </example>
145//
146// <motivation>
147// To aid making maps in different coordinate systems
148// </motivation>
149//
150// <todo asof="1998/01/21">
151// <li> add EW UVW coordinates
152// <li> check if non right-handed coordinates systems (like AzEl) are
153// handled correctly
154// <li> provide a MVuvw and Muvw class to cater for second order effects
155// appropiately
156// </todo>
157
159 public:
160 // # Constructors
161 // Constructors have an EW flag, which will give a projection parallel to
162 // the polar axis rather than in the direction of the fieldcenter, and a
163 // project flag. The last will correct the UV coordinates to re-project
164 // them onto the plane specified by the in direction
165 // <group>
166 // Construct a UVW conversion machine from the in coordinate and its
167 // system to the out coordinate system (output absolute direction
168 // remains the same)
169 UVWMachine(const MDirection::Ref &out, const MDirection &in, Bool EW = False,
170 Bool project = False);
171 // Construct a UVW conversion machine from the in coordinate and its
172 // system to the out coordinate and its system
173 UVWMachine(const MDirection &out, const MDirection &in, Bool EW = False, Bool project = False);
174 // Construct UVW conversion machine with an explicitly given frame
175 // <group>
176 UVWMachine(const MDirection::Ref &out, const MDirection &in, const MeasFrame &frame,
177 Bool EW = False, Bool project = False);
178 UVWMachine(const MDirection &out, const MDirection &in, const MeasFrame &frame, Bool EW = False,
179 Bool project = False);
180 // </group>
181 // </group>
182 // Copy constructor
183 UVWMachine(const UVWMachine &other);
184 // Copy assignments
186
187 // # Destructor
189
190 // # Operators
191 // Return converted UVW coordinates
192 // <group>
197 // </group>
198
199 // # Member functions
200 // Return the new phase center coordinates
201 const MDirection &phaseCenter() const;
202 // Return if the engine is an effective NOP
203 Bool isNOP() { return nop_p; }
204 // Return a rotation matrix that can be used to convert UVW coordinates:
205 // UVW(new) = UVW(old) * rotationUVW()
206 const RotMatrix &rotationUVW() const;
207 // Return a position vector that can produce the phase correction:
208 // dPhase = rotationPhase * UVW(new)
209 const MVPosition &rotationPhase() const;
210 // replace UVW with converted values
211 // <group>
212 void convertUVW(Vector<Double> &uv) const;
214 void convertUVW(MVPosition &uv) const;
216 // </group>
217 // Get phase shift (in implied units of UVW), and change input uvw as well
218 // <group>
223 // </group>
224 // Replace UVW with converted, and return phase
225 // <group>
230 // </group>
231
232 // Recalculate the parameters for the machine after e.g. a frame change
234
235 private:
236 // # Data
237 // EW flag
239 // Projection flag
241 // Zero phase flag (for speed)
243 // No conversion necessary flag
245 // Old phase center
247 // New coordinate reference
249 // Old phase center in new coordinates
251 // New phase center
253 // Rotation Matrix to go from input UVW to coordinate system
255 // Rotation matrix to go from old system to new system
257 // Rotation Matrix to go from new coordinate system to output UVW
259 // Rotation Matrix to project UV-plane onto
261 // UVW rotation
263 // UVW rotation including projection
265 // Phase rotation
267 // Conversion engine
269
270 // # Constructors
271 // default constructor: not implemented
273
274 // # Private Member Functions
275 // Initialise machinery
276 void init();
277 // Planet handling
279 // Copy data members
280 void copy(const UVWMachine &other);
281};
282
283} // namespace casacore
284
285#endif
MeasConvert< MDirection > Convert
Measure Convert (i.e.
Definition MDirection.h:244
MeasRef< MDirection > Ref
Measure reference (i.e.
Definition MDirection.h:242
UVWMachine(const MDirection &out, const MDirection &in, Bool EW=False, Bool project=False)
Construct a UVW conversion machine from the in coordinate and its system to the out coordinate and it...
UVWMachine(const UVWMachine &other)
Copy constructor.
RotMatrix rot4_p
Rotation Matrix to project UV-plane onto.
Definition UVWMachine.h:260
MVPosition operator()(const MVPosition &uv) const
Vector< Vector< Double > > operator()(const Vector< Vector< Double > > &uv) const
void convertUVW(Vector< MVPosition > &uv) const
RotMatrix uvrot_p
UVW rotation.
Definition UVWMachine.h:262
const RotMatrix & rotationUVW() const
Return a rotation matrix that can be used to convert UVW coordinates: UVW(new) = UVW(old) * rotationU...
Vector< Double > operator()(const Vector< Double > &uv) const
Return converted UVW coordinates.
MVPosition phrot_p
Phase rotation.
Definition UVWMachine.h:266
void convertUVW(Double &phase, Vector< Double > &uv) const
Replace UVW with converted, and return phase.
void planetinit()
Planet handling.
Double getPhase(Vector< Double > &uv) const
Get phase shift (in implied units of UVW), and change input uvw as well.
void convertUVW(Vector< Vector< Double > > &uv) const
RotMatrix rot3_p
Rotation Matrix to go from new coordinate system to output UVW.
Definition UVWMachine.h:258
MDirection outin_p
Old phase center in new coordinates.
Definition UVWMachine.h:250
void convertUVW(Double &phase, MVPosition &uv) const
Vector< Double > getPhase(Vector< Vector< Double > > &uv) const
UVWMachine & operator=(const UVWMachine &other)
Copy assignments.
Vector< Double > getPhase(Vector< MVPosition > &uv) const
UVWMachine(const MDirection::Ref &out, const MDirection &in, const MeasFrame &frame, Bool EW=False, Bool project=False)
Construct UVW conversion machine with an explicitly given frame.
Bool proj_p
Projection flag.
Definition UVWMachine.h:240
UVWMachine(const MDirection &out, const MDirection &in, const MeasFrame &frame, Bool EW=False, Bool project=False)
RotMatrix rot1_p
Rotation Matrix to go from input UVW to coordinate system.
Definition UVWMachine.h:254
Bool ew_p
EW flag.
Definition UVWMachine.h:238
void convertUVW(Vector< Double > &phase, Vector< MVPosition > &uv) const
MDirection::Ref outref_p
New coordinate reference.
Definition UVWMachine.h:248
Vector< MVPosition > operator()(const Vector< MVPosition > &uv) const
Bool isNOP()
Return if the engine is an effective NOP.
Definition UVWMachine.h:203
void init()
Initialise machinery.
void convertUVW(Vector< Double > &uv) const
replace UVW with converted values
void convertUVW(MVPosition &uv) const
Bool nop_p
No conversion necessary flag.
Definition UVWMachine.h:244
void convertUVW(Vector< Double > &phase, Vector< Vector< Double > > &uv) const
Bool zp_p
Zero phase flag (for speed).
Definition UVWMachine.h:242
Double getPhase(MVPosition &uv) const
MDirection in_p
Old phase center.
Definition UVWMachine.h:246
MDirection out_p
New phase center.
Definition UVWMachine.h:252
void reCalculate()
Recalculate the parameters for the machine after e.g.
const MVPosition & rotationPhase() const
Return a position vector that can produce the phase correction: dPhase = rotationPhase * UVW(new).
void copy(const UVWMachine &other)
Copy data members.
UVWMachine()
default constructor: not implemented
const MDirection & phaseCenter() const
Return the new phase center coordinates.
MDirection::Convert conv_p
Conversion engine.
Definition UVWMachine.h:268
RotMatrix rot2_p
Rotation matrix to go from old system to new system.
Definition UVWMachine.h:256
UVWMachine(const MDirection::Ref &out, const MDirection &in, Bool EW=False, Bool project=False)
Constructors have an EW flag, which will give a projection parallel to the polar axis rather than in ...
RotMatrix uvproj_p
UVW rotation including projection.
Definition UVWMachine.h:264
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
TableExprNode phase(const TableExprNode &node)
The phase (i.e.
Definition ExprNode.h:1281
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
double Double
Definition aipstype.h:53