casacore
MDirection.h
Go to the documentation of this file.
1 //# MDirection.h: A Measure: astronomical direction
2 //# Copyright (C) 1995-2000,2002,2004,2007
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: aips2-request@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 //# $Id$
28 
29 #ifndef MEASURES_MDIRECTION_H
30 #define MEASURES_MDIRECTION_H
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/measures/Measures/MeasBase.h>
35 #include <casacore/measures/Measures/MeasRef.h>
36 #include <casacore/casa/Quanta/MVDirection.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 class MDirection;
42 class MCDirection;
43 template <class M> class MeasConvert;
44 template <class M> class ArrayMeasColumn;
45 template <class M> class ScalarMeasColumn;
46 
47 //# Typedefs
48 
49 // <summary>
50 // A Measure: astronomical direction
51 // </summary>
52 
53 // <use visibility=export>
54 
55 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos="">
56 // </reviewed>
57 
58 // <prerequisite>
59 // <li> <linkto class=Measure>Measure</linkto> class
60 // </prerequisite>
61 //
62 // <etymology>
63 // </etymology>
64 //
65 // <synopsis>
66 // MDirection forms a derived Measure class for a direction in space.<br>
67 // An MDirection can be generated from a
68 // <linkto class=MVDirection>MVDirection</linkto> or a pair of
69 // <linkto class=Quantum>Quantities</linkto> specifying a longitudinal and a
70 // latitudinal angle.<br>
71 // The different reference types that can be used for a Direction are:
72 // <ul>
73 // <li>MDirection::J2000 -- mean equator and equinox at J2000.0 (FK5)
74 // <li>MDirection::JNAT --- geocentric natural frame
75 // <li>MDirection::JMEAN -- mean equator and equinox at frame epoch
76 // <li>MDirection::JTRUE -- true equator and equinox at frame epoch
77 // <li>MDirection::APP ---- apparent geocentric position
78 // <li>MDirection::B1950 -- mean epoch and ecliptic at B1950.0. The epoch
79 // is taken from the frame epoch; or from the aipsrc variable
80 // measures.b1950.d_epoch; or has default 2000.0
81 // <li>MDirection::B1950_VLA -- mean epoch(1979.9)) and ecliptic at B1950.0
82 // <li>MDirection::BMEAN -- mean equator and equinox at frame epoch
83 // <li>MDirection::BTRUE -- true equator and equinox at frame epoch
84 // <li>MDirection::GALACTIC -- galactic coordinates
85 // <li>MDirection::HADEC -- topocentric HA and declination
86 // <li>MDirection::AZEL --- topocentric Azimuth and Elevation (N through E)
87 // <li>MDirection::AZELSW - topocentric Azimuth and Elevation (S through W)
88 // <li>MDirection::AZELNE - topocentric Azimuth and Elevation (N through E)
89 // <li>MDirection::AZELGEO --- geodetic Azimuth and Elevation (N through E)
90 // <li>MDirection::AZELSWGEO - geodetic Azimuth and Elevation (S through W)
91 // <li>MDirection::AZELNEGEO - geodetic Azimuth and Elevation (N through E)
92 // <li>MDirection::ECLIPTC -- ecliptic for J2000 equator and equinox
93 // <li>MDirection::MECLIPTIC -- ecliptic for mean equator of date
94 // <li>MDirection::TECLIPTIC -- ecliptic for true equator of date
95 // <li>MDirection::SUPERGAL -- supergalactic coordinates
96 // <li>MDirection::ITRF -- coordinates wrt ITRF Earth frame
97 // <li>MDirection::TOPO -- apparent topocentric position
98 // <li>MDirection::ICRS -- International Celestial reference system
99 // <li>MDirection::MERCURY -- the planet: has no data attached
100 // <li>MDirection::VENUS
101 // <li>MDirection::MARS
102 // <li>MDirection::JUPITER
103 // <li>MDirection::SATURN
104 // <li>MDirection::URANUS
105 // <li>MDirection::NEPTUNE
106 // <li>MDirection::PLUTO
107 // <li>MDirection::SUN
108 // <li>MDirection::MOON
109 // <li>MDirection::COMET -- solar system body: no coordinates attached,
110 // only table
111 // <li>MDirection::DEFAULT = J2000
112 // </ul>
113 // <p>
114 // Conversion between the different types is done with the standard
115 // <linkto class=MeasConvert>MeasConvert</linkto> class
116 // (<src>MDirection::Convert</src> in this case).<br>
117 // For some conversion additional <linkto class=MeasFrame>MeasFrame</linkto>
118 // information is essential. The following list specifies which information
119 // is needed if the conversion goes to or from the different types:
120 // <ul>
121 // <li><em>Epoch</em>: all but J2000, B1950, GALACTIC, SUPGAL, ECLIPTIC, ICRS
122 // <li><em>Positiom</em>: HADEC, AZEL, AZELGEO
123 // </ul>
124 // The conversion between B1950 and J2000 may have an Epoch. If none given
125 // an epoch of 2000.0 is assumed for the conversion, unless an aipsrc
126 // variable <em>measures.b1950.d_epoch</em> is given.
127 //
128 // Conversions are based on the IAU system of
129 // <linkto class=Precession>precession</linkto> and
130 // <linkto class=Nutation>nutation</linkto> (with
131 // IERS corrections if available); and on series expansions of the DE200
132 // planetary ephemeris (J system; for B sytem older expansions) for the
133 // <linkto class=Aberration>aberration</linkto> and the
134 // <linkto class=SolarPos>solar position</linkto>.<br>
135 // The <em>HADEC</em> position has corrections for polar motion and the
136 // equation of equinoxes; the <em>AZEL</em> will include Earth tides and
137 // refraction at a later stage.<br>
138 // Note that conversion between B1950 and J2000 can only be approximate, and is
139 // based on FK4 to FK5 conversion. The best conversion is to convert first
140 // to an apparent position at the time of observation, and convert from there
141 // to the other standard (the correct route will be followed).<br>
142 // Another problem can arise if the source has proper motion and/or radial
143 // velocities. These should be taken into account. An
144 // MCatalog class will maybe take care of that.
145 // <note role=warning>
146 // The offset that can be specified in the MDirection::Ref is an MDirection
147 // offset, and can not be used for specifying angular offsets. shift()
148 // methods are available for these cases.
149 // </note>
150 // <p>
151 // To aid in formatting of the angles without having to check all difference
152 // referencetypes, the following global types are provided:
153 // <ul>
154 // <li> GRADEC for types that are probably expressed in HM,DM
155 // <li> GHADEC for types that are probably expressed in +-HM,DM
156 // <li> GAZEL for types that are probably expressed in +-deg,deg
157 // <li> GLONGLAT for types that are probably expressed in deg,deg
158 // </ul>
159 // they can be obtained with the globalType() method.
160 // </synopsis>
161 //
162 // <example>
163 // See <linkto module=Measures>Measures</linkto> module description for
164 // extensive examples.
165 // </example>
166 //
167 // <motivation>
168 // </motivation>
169 //
170 // <todo asof="2000/06/15">
171 // <li>
172 // </todo>
173 
174 class MDirection : public MeasBase<MVDirection, MeasRef<MDirection> > {
175 
176 public:
177 //# Friends
178 // Conversion of data
179  friend class MeasConvert<MDirection>;
180 
181 //# Enumerations
182 // Types of known MDirections
183 // <note role=warning> The order defines the order in the translation matrix FromTo
184 // in the getConvert routine. Do not change the order without
185 // changing the array. Additions should be made before N_types, and
186 // an additional row and column should be coded in FromTo, and
187 // in showType().</note>
188  enum Types {
212  // Planets. First one should be Mercury
213  MERCURY = 32,
223  // Comet or other table-described solar system body
226  // All extra bits
227  EXTRA = 32,
228  // Defaults
230  // Synonyms
233  // Global types
234  enum GlobalTypes {
240 
241  //# Typedefs
242  // Measure value container for this class (i.e. MDirection::MVType)
244  // Measure conversion routines for this class (i.e. MDirection::MCType)
246  // Measure reference (i.e. MDirection::Ref)
248  // Measure Convert (i.e. MDirection::Convert)
250  // Measure table Columns (e.g., MDirection::ScalarColumn)
253  // Reference enum Types (included originally for gcc 2.95)
255 
256 //# Constructors
257 // <note role=tip> In the following constructors and other functions, all
258 // <em>MeasRef</em> can be replaced with simple <src>Measure::TYPE</src>
259 // where no offsets or frames are needed in the reference. </note>
260 // Default constructor; generates the J2000 pole direction
261  MDirection();
262 // Create from data and reference
263 // <group>
264  MDirection(const MVDirection &dt);
265  MDirection(const MVDirection &dt, const MDirection::Ref &rf);
267  MDirection(const Quantity &dt, const Quantity &dt1);
268  MDirection(const Quantity &dt, const Quantity &dt1,
269  const MDirection::Ref &rf);
270  MDirection(const Quantity &dt, const Quantity &dt1,
271  MDirection::Types rf);
272  MDirection(const Quantum<Vector<Double> > &dt);
273  MDirection(const Quantum<Vector<Double> > &dt,
274  const MDirection::Ref &rf);
275  MDirection(const Quantum<Vector<Double> > &dt,
276  MDirection::Types rf);
277  MDirection(const Measure *dt);
278  MDirection(const MeasValue *dt);
279  MDirection(const MDirection::Ref &rf);
281 // </group>
282 
283 //# Destructor
284  virtual ~MDirection();
285 
286 // Make an MDirection object given the name of a moving source (SUN, etc.)
287 // or of a known standard source (CygA, etc.).
288  static MDirection makeMDirection(const String& sourceName);
289 
290 //# Operators
291 
292 //# General Member Functions
293 // Tell me your type ('Direction')
294 // <group>
295  virtual const String &tellMe() const;
296  static const String &showMe();
297 // </group>
298 // Tell me your reference type (as Register())
299  // N.B. as defined in MDirection.cc, it does NOT return the type of an
300  // instance, i.e. it just returns Register(static_cast<MDirection *>(0)).
301  virtual uInt type() const;
302 // Assert you are a direction
303  static void assure(const Measure &in);
304 // Tell me the global type (like GRADEC) for tp (tp like MDirection::J2000)
306 // Translate reference code tp. The uInt version has a check for valid codes
307  // (i.e. it is a safe cast).
308  // <thrown>
309  // <li> AipsError in the uInt interface if illegal code given
310  // </thrown>
311  // <group>
312  static MDirection::Types castType(uInt tp);
313  static const String &showType(MDirection::Types tp);
314  static const String &showType(uInt tp);
315  // </group>
316 // Translate string to reference code
317 // <group>
318  static Bool getType(MDirection::Types &tp, const String &in);
319  Bool giveMe(MDirection::Ref &mr, const String &in);
320 // </group>
321  // Set the offset in the reference (False if non-matching Measure)
322  virtual Bool setOffset(const Measure &in);
323  // Set the reference type to the specified String. False if illegal
324  // string, reference set to DEFAULT.
325  virtual Bool setRefString(const String &in);
326  // Get the default reference type
327  virtual const String &getDefaultType() const;
328  // Get a list of all known reference codes. nall returns the number in list,
329  // nextra the number of specials (like planets) that should be at
330  // end of list). typ returns the list of corresponding types.
331  // <group>
332  virtual const String* allTypes(Int &nall, Int &nextra,
333  const uInt *&typ) const;
334  static const String* allMyTypes(Int &nall, Int &nextra,
335  const uInt *&typ);
336  // </group>
337  // Check if all internal tables of types (both enum and String) are
338  // complete and correct. This function is called automatically if and when
339  // necessary.
340  // <thrown>
341  // <li> AipsError if a (programming) error in the types.
342  // </thrown>
343  // <group>
344  virtual void checkTypes() const;
345  static void checkMyTypes();
346  // </group>
347  // Get the reference type (for records, including codes like R_)
348  virtual String getRefString() const;
349  // Get my type (as Register)
350  // N.B. Being static, it does NOT return the type of an instance, i.e. use it
351  // as MDirection::myType(), not md.myType().
352  static uInt myType();
353  // Tell me if you are a pure model (e.g. a planet)
354  virtual Bool isModel() const;
355 
356  // Get Measure data
357  // <group>
359  Quantum<Vector<Double> > getAngle(const Unit &inunit) const;
360  // </group>
361  // Shift the direction in longitude (radians if Double) and/or latitude.
362  // If the trueAngle switch is True, the longitude shift will be in
363  // angular units perpendicular to the direction to pole, along a great
364  // circle. See <linkto class=MVDirection>MVDirection</linkto>
365  // for more details.
366  // <group>
367  void shift(const Quantum<Double> &lng,
368  const Quantum<Double> &lat, Bool trueAngle=False);
369  void shift(Double lng, Double lat, Bool trueAngle=False);
370  void shiftLongitude(const Quantity &lng, Bool trueAngle=False);
371  void shiftLongitude(Double lng, Bool trueAngle=False);
372  void shiftLatitude(const Quantum<Double> &lat, Bool trueAngle=False);
373  void shiftLatitude(Double lat, Bool trueAngle=False);
374  void shift(const MVDirection &shft, Bool trueAngle=False);
375  // </group>
376  // Shift over an angle off in the direction pa. pa is measured from North,
377  // in the direction of increasing longitude.
378  // See <linkto class=MVDirection>MVDirection</linkto>
379  // for implementation.
380  // <group>
381  void shiftAngle(const Quantum<Double> &off,
382  const Quantum<Double> &pa);
383  void shiftAngle(Double off, Double pa);
384  // </group>
385 
386 // Make a copy
387 // <group>
388  virtual Measure *clone() const;
389 // </group>
390 
391  // Convert to a String in astronomer-friendly format based on
392  // reference frame
393  String toString() const;
394 
395 private:
396 
397 //# Data
398 
399 //# Member functions
400 
401 };
402 
403 
404 } //# NAMESPACE CASACORE - END
405 
406 #endif
407 
A Measure: astronomical direction.
Definition: MDirection.h:174
int Int
Definition: aipstype.h:50
Conversion of Measures.
Definition: MBaseline.h:44
MeasRef< MDirection > Ref
Measure reference (i.e.
Definition: MDirection.h:247
static void assure(const Measure &in)
Assert you are a direction.
static MDirection::GlobalTypes globalType(uInt tp)
Tell me the global type (like GRADEC) for tp (tp like MDirection::J2000)
virtual void checkTypes() const
Check if all internal tables of types (both enum and String) are complete and correct.
virtual Bool setOffset(const Measure &in)
Set the offset in the reference (False if non-matching Measure)
static Bool getType(MDirection::Types &tp, const String &in)
Translate string to reference code.
ArrayMeasColumn< MDirection > ArrayColumn
Definition: MDirection.h:252
MCDirection MCType
Measure conversion routines for this class (i.e.
Definition: MDirection.h:245
Physical quantities within reference frame.
Definition: Measure.h:235
Quantum< Vector< Double > > getAngle() const
Get Measure data.
GlobalTypes
Global types.
Definition: MDirection.h:234
Base class for all measures.
Definition: MeasBase.h:75
Read only access to table array Measure columns.
Definition: MBaseline.h:45
MDirection conversion routines.
Definition: MCDirection.h:86
Types
Types of known MDirections Warning: The order defines the order in the translation matrix FromTo in ...
Definition: MDirection.h:188
MVDirection MVType
Measure value container for this class (i.e.
Definition: MDirection.h:243
defines physical units
Definition: Unit.h:189
static void checkMyTypes()
void shiftLongitude(const Quantity &lng, Bool trueAngle=False)
Comet or other table-described solar system body.
Definition: MDirection.h:224
Base class for values in a Measure.
Definition: MeasValue.h:107
virtual Bool setRefString(const String &in)
Set the reference type to the specified String.
LatticeExprNode pa(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds 180/pi*atan2(left,right)/2.
virtual const String * allTypes(Int &nall, Int &nextra, const uInt *&typ) const
Get a list of all known reference codes.
virtual Bool isModel() const
Tell me if you are a pure model (e.g.
void shiftLatitude(const Quantum< Double > &lat, Bool trueAngle=False)
virtual Measure * clone() const
Make a copy.
virtual uInt type() const
Tell me your reference type (as Register()) N.B.
Bool giveMe(MDirection::Ref &mr, const String &in)
double Double
Definition: aipstype.h:55
static MDirection::Types castType(uInt tp)
Translate reference code tp.
virtual String getRefString() const
Get the reference type (for records, including codes like R_)
typedef WHATEVER_SUN_TYPEDEF(MDirection) Types Types
Reference enum Types (included originally for gcc 2.95)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void shift(const Quantum< Double > &lng, const Quantum< Double > &lat, Bool trueAngle=False)
Shift the direction in longitude (radians if Double) and/or latitude.
static const String & showMe()
const Bool False
Definition: aipstype.h:44
static uInt myType()
Get my type (as Register) N.B.
static const String & showType(MDirection::Types tp)
void shiftAngle(const Quantum< Double > &off, const Quantum< Double > &pa)
Shift over an angle off in the direction pa.
static MDirection makeMDirection(const String &sourceName)
Make an MDirection object given the name of a moving source (SUN, etc.) or of a known standard source...
static const String * allMyTypes(Int &nall, Int &nextra, const uInt *&typ)
virtual const String & getDefaultType() const
Get the default reference type.
virtual const String & tellMe() const
Tell me your type (&#39;Direction&#39;)
String toString() const
Convert to a String in astronomer-friendly format based on reference frame.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
MeasConvert< MDirection > Convert
Measure Convert (i.e.
Definition: MDirection.h:249
MDirection()
Tip: In the following constructors and other functions, all MeasRef can be replaced with simple Meas...
Read only access to table scalar Measure columns.
Definition: MBaseline.h:46
Vector of three direction cosines.
Definition: MVDirection.h:106
this file contains all the compiler specific defines
Definition: mainpage.dox:28
ScalarMeasColumn< MDirection > ScalarColumn
Measure table Columns (e.g., MDirection::ScalarColumn)
Definition: MDirection.h:251
unsigned int uInt
Definition: aipstype.h:51