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 
254 //# Constructors
255 // <note role=tip> In the following constructors and other functions, all
256 // <em>MeasRef</em> can be replaced with simple <src>Measure::TYPE</src>
257 // where no offsets or frames are needed in the reference. </note>
258 // Default constructor; generates the J2000 pole direction
260 // Create from data and reference
261 // <group>
263  MDirection(const MVDirection &dt, const MDirection::Ref &rf);
265  MDirection(const Quantity &dt, const Quantity &dt1);
266  MDirection(const Quantity &dt, const Quantity &dt1,
267  const MDirection::Ref &rf);
268  MDirection(const Quantity &dt, const Quantity &dt1,
269  MDirection::Types rf);
272  const MDirection::Ref &rf);
274  MDirection::Types rf);
275  MDirection(const Measure *dt);
276  MDirection(const MeasValue *dt);
279 // </group>
280 
281 //# Destructor
282  virtual ~MDirection();
283 
284 // Make an MDirection object given the case-insensitive name of a
285 // moving source (ZENITH, SUN, etc.),
286 // or of a known standard source (CygA, etc.).
287  static MDirection makeMDirection(const String& sourceName);
288 
289 //# Operators
290 
291 //# General Member Functions
292 // Tell me your type ('Direction')
293 // <group>
294  virtual const String &tellMe() const;
295  static const String &showMe();
296 // </group>
297 // Tell me your reference type (as Register())
298  // N.B. as defined in MDirection.cc, it does NOT return the type of an
299  // instance, i.e. it just returns Register(static_cast<MDirection *>(0)).
300  virtual uInt type() const;
301 // Assert you are a direction
302  static void assure(const Measure &in);
303 // Tell me the global type (like GRADEC) for tp (tp like MDirection::J2000)
305 // Translate reference code tp. The uInt version has a check for valid codes
306  // (i.e. it is a safe cast).
307  // <thrown>
308  // <li> AipsError in the uInt interface if illegal code given
309  // </thrown>
310  // <group>
312  static const String &showType(MDirection::Types tp);
313  static const String &showType(uInt tp);
314  // </group>
315 // Translate string to reference code
316 // <group>
317  static Bool getType(MDirection::Types &tp, const String &in);
319 // </group>
320  // Set the offset in the reference (False if non-matching Measure)
321  virtual Bool setOffset(const Measure &in);
322  // Set the reference type to the specified String. False if illegal
323  // string, reference set to DEFAULT.
324  virtual Bool setRefString(const String &in);
325  // Get the default reference type
326  virtual const String &getDefaultType() const;
327  // Get a list of all known reference codes. nall returns the number in list,
328  // nextra the number of specials (like planets) that should be at
329  // end of list). typ returns the list of corresponding types.
330  // <group>
331  virtual const String* allTypes(Int &nall, Int &nextra,
332  const uInt *&typ) const;
333  static const String* allMyTypes(Int &nall, Int &nextra,
334  const uInt *&typ);
335  // </group>
336  // Check if all internal tables of types (both enum and String) are
337  // complete and correct. This function is called automatically if and when
338  // necessary.
339  // <thrown>
340  // <li> AipsError if a (programming) error in the types.
341  // </thrown>
342  // <group>
343  virtual void checkTypes() const;
344  static void checkMyTypes();
345  // </group>
346  // Get the reference type (for records, including codes like R_)
347  virtual String getRefString() const;
348  // Get my type (as Register)
349  // N.B. Being static, it does NOT return the type of an instance, i.e. use it
350  // as MDirection::myType(), not md.myType().
351  static uInt myType();
352  // Tell me if you are a pure model (e.g. a planet)
353  virtual Bool isModel() const;
354 
355  // Get Measure data
356  // <group>
358  Quantum<Vector<Double> > getAngle(const Unit &inunit) const;
359  // </group>
360  // Shift the direction in longitude (radians if Double) and/or latitude.
361  // If the trueAngle switch is True, the longitude shift will be in
362  // angular units perpendicular to the direction to pole, along a great
363  // circle. See <linkto class=MVDirection>MVDirection</linkto>
364  // for more details.
365  // <group>
366  void shift(const Quantum<Double> &lng,
367  const Quantum<Double> &lat, Bool trueAngle=False);
368  void shift(Double lng, Double lat, Bool trueAngle=False);
369  void shiftLongitude(const Quantity &lng, Bool trueAngle=False);
370  void shiftLongitude(Double lng, Bool trueAngle=False);
371  void shiftLatitude(const Quantum<Double> &lat, Bool trueAngle=False);
372  void shiftLatitude(Double lat, Bool trueAngle=False);
373  void shift(const MVDirection &shft, Bool trueAngle=False);
374  // </group>
375  // Shift over an angle off in the direction pa. pa is measured from North,
376  // in the direction of increasing longitude.
377  // See <linkto class=MVDirection>MVDirection</linkto>
378  // for implementation.
379  // <group>
380  void shiftAngle(const Quantum<Double> &off,
381  const Quantum<Double> &pa);
383  // </group>
384 
385 // Make a copy
386 // <group>
387  virtual Measure *clone() const;
388 // </group>
389 
390  // Convert to a String in astronomer-friendly format based on
391  // reference frame
392  String toString() const;
393 
394 private:
395 
396 //# Data
397 
398 //# Member functions
399 
400 };
401 
402 
403 } //# NAMESPACE CASACORE - END
404 
405 #endif
406 
Bool giveMe(MDirection::Ref &mr, const String &in)
static void checkMyTypes()
void shift(const Quantum< Double > &lng, const Quantum< Double > &lat, Bool trueAngle=False)
Shift the direction in longitude (radians if Double) and/or latitude.
virtual Measure * clone() const
Make a copy.
virtual String getRefString() const
Get the reference type (for records, including codes like R_)
MeasConvert< MDirection > Convert
Measure Convert (i.e.
Definition: MDirection.h:249
void shift(Double lng, Double lat, Bool trueAngle=False)
void shiftLatitude(Double lat, Bool trueAngle=False)
MDirection(MDirection::Types rf)
static Bool getType(MDirection::Types &tp, const String &in)
Translate string to reference code.
MDirection(const Quantum< Vector< Double > > &dt)
void shift(const MVDirection &shft, Bool trueAngle=False)
static const String * allMyTypes(Int &nall, Int &nextra, const uInt *&typ)
MVDirection MVType
Measure value container for this class (i.e.
Definition: MDirection.h:243
ArrayMeasColumn< MDirection > ArrayColumn
Definition: MDirection.h:252
virtual Bool setRefString(const String &in)
Set the reference type to the specified String.
virtual void checkTypes() const
Check if all internal tables of types (both enum and String) are complete and correct.
virtual uInt type() const
Tell me your reference type (as Register()) N.B.
Quantum< Vector< Double > > getAngle(const Unit &inunit) const
static const String & showType(uInt tp)
MDirection(const Quantity &dt, const Quantity &dt1, const MDirection::Ref &rf)
MDirection(const MDirection::Ref &rf)
void shiftLongitude(Double lng, Bool trueAngle=False)
MDirection(const Quantity &dt, const Quantity &dt1)
static MDirection makeMDirection(const String &sourceName)
Make an MDirection object given the case-insensitive name of a moving source (ZENITH,...
virtual Bool isModel() const
Tell me if you are a pure model (e.g.
MDirection(const MVDirection &dt, MDirection::Types rf)
void shiftLongitude(const Quantity &lng, Bool trueAngle=False)
MDirection(const Quantum< Vector< Double > > &dt, const MDirection::Ref &rf)
MeasRef< MDirection > Ref
Measure reference (i.e.
Definition: MDirection.h:247
MCDirection MCType
Measure conversion routines for this class (i.e.
Definition: MDirection.h:245
static MDirection::Types castType(uInt tp)
Translate reference code tp.
Types
Types of known MDirections Warning: The order defines the order in the translation matrix FromTo in ...
Definition: MDirection.h:188
@ EXTRA
All extra bits.
Definition: MDirection.h:227
@ COMET
Comet or other table-described solar system body.
Definition: MDirection.h:224
@ DEFAULT
Defaults.
Definition: MDirection.h:229
virtual Bool setOffset(const Measure &in)
Set the offset in the reference (False if non-matching Measure)
void shiftAngle(Double off, Double pa)
Quantum< Vector< Double > > getAngle() const
Get Measure data.
MDirection(const Quantum< Vector< Double > > &dt, MDirection::Types rf)
static const String & showMe()
virtual const String * allTypes(Int &nall, Int &nextra, const uInt *&typ) const
Get a list of all known reference codes.
static MDirection::GlobalTypes globalType(uInt tp)
Tell me the global type (like GRADEC) for tp (tp like MDirection::J2000)
GlobalTypes
Global types.
Definition: MDirection.h:234
String toString() const
Convert to a String in astronomer-friendly format based on reference frame.
static void assure(const Measure &in)
Assert you are a direction.
MDirection(const MVDirection &dt)
Create from data and reference.
static uInt myType()
Get my type (as Register) N.B.
virtual const String & tellMe() const
Tell me your type ('Direction')
virtual const String & getDefaultType() const
Get the default reference type.
MDirection()
Tip: In the following constructors and other functions, all MeasRef can be replaced with simple Measu...
void shiftAngle(const Quantum< Double > &off, const Quantum< Double > &pa)
Shift over an angle off in the direction pa.
MDirection(const MeasValue *dt)
static const String & showType(MDirection::Types tp)
MDirection(const MVDirection &dt, const MDirection::Ref &rf)
void shiftLatitude(const Quantum< Double > &lat, Bool trueAngle=False)
ScalarMeasColumn< MDirection > ScalarColumn
Measure table Columns (e.g., MDirection::ScalarColumn)
Definition: MDirection.h:251
MDirection(const Quantity &dt, const Quantity &dt1, MDirection::Types rf)
MDirection(const Measure *dt)
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
LatticeExprNode pa(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds 180/pi*atan2(left,right)/2.
const Bool False
Definition: aipstype.h:44
unsigned int uInt
Definition: aipstype.h:51
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
double Double
Definition: aipstype.h:55