casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MDirection.h
Go to the documentation of this file.
00001 //# MDirection.h: A Measure: astronomical direction
00002 //# Copyright (C) 1995-2000,2002,2004,2007
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 //# $Id: MDirection.h 21298 2012-12-07 14:53:03Z gervandiepen $
00028 
00029 #ifndef MEASURES_MDIRECTION_H
00030 #define MEASURES_MDIRECTION_H
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <measures/Measures/MeasBase.h>
00035 #include <measures/Measures/MeasRef.h>
00036 #include <casa/Quanta/MVDirection.h>
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 //# Forward Declarations
00041 class MDirection;
00042 class MCDirection;
00043 template <class M> class MeasConvert;
00044 template <class M> class ArrayMeasColumn;
00045 template <class M> class ScalarMeasColumn;
00046 
00047 //# Typedefs
00048 
00049 // <summary>
00050 //  A Measure: astronomical direction
00051 // </summary>
00052 
00053 // <use visibility=export>
00054 
00055 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos="">
00056 // </reviewed>
00057 
00058 // <prerequisite>
00059 //   <li> <linkto class=Measure>Measure</linkto> class 
00060 // </prerequisite>
00061 //
00062 // <etymology>
00063 // </etymology>
00064 //
00065 // <synopsis>
00066 // MDirection forms a derived Measure class for a direction in space.<br>
00067 // An MDirection can be generated from a
00068 // <linkto class=MVDirection>MVDirection</linkto> or a pair of 
00069 // <linkto class=Quantum>Quantities</linkto> specifying a longitudinal and a
00070 // latitudinal angle.<br>
00071 // The different reference types that can be used for a Direction are:
00072 // <ul>
00073 //  <li>MDirection::J2000 -- mean equator and equinox at J2000.0 (FK5)
00074 //  <li>MDirection::JNAT --- geocentric natural frame
00075 //  <li>MDirection::JMEAN -- mean equator and equinox at frame epoch
00076 //  <li>MDirection::JTRUE -- true equator and equinox at frame epoch
00077 //  <li>MDirection::APP ---- apparent geocentric position
00078 //  <li>MDirection::B1950 -- mean epoch and ecliptic at B1950.0. The epoch
00079 //      is taken from the frame epoch; or from the aipsrc variable
00080 //      measures.b1950.d_epoch; or has default 2000.0
00081 //  <li>MDirection::B1950_VLA -- mean epoch(1979.9)) and ecliptic at B1950.0
00082 //  <li>MDirection::BMEAN -- mean equator and equinox at frame epoch
00083 //  <li>MDirection::BTRUE -- true equator and equinox at frame epoch
00084 //  <li>MDirection::GALACTIC -- galactic coordinates
00085 //  <li>MDirection::HADEC -- topocentric HA and declination
00086 //  <li>MDirection::AZEL --- topocentric Azimuth and Elevation (N through E)
00087 //  <li>MDirection::AZELSW - topocentric Azimuth and Elevation (S through W)
00088 //  <li>MDirection::AZELNE - topocentric Azimuth and Elevation (N through E)
00089 //  <li>MDirection::AZELGEO --- geodetic Azimuth and Elevation (N through E)   
00090 //  <li>MDirection::AZELSWGEO - geodetic Azimuth and Elevation (S through W)   
00091 //  <li>MDirection::AZELNEGEO - geodetic Azimuth and Elevation (N through E)   
00092 //  <li>MDirection::ECLIPTC   -- ecliptic for J2000 equator and equinox
00093 //  <li>MDirection::MECLIPTIC -- ecliptic for mean equator of date
00094 //  <li>MDirection::TECLIPTIC -- ecliptic for true equator of date
00095 //  <li>MDirection::SUPERGAL -- supergalactic coordinates
00096 //  <li>MDirection::ITRF -- coordinates wrt ITRF Earth frame
00097 //  <li>MDirection::TOPO -- apparent topocentric position
00098 //  <li>MDirection::ICRS -- International Celestial reference system
00099 //  <li>MDirection::MERCURY -- the planet: has no data attached
00100 //  <li>MDirection::VENUS
00101 //  <li>MDirection::MARS
00102 //  <li>MDirection::JUPITER
00103 //  <li>MDirection::SATURN
00104 //  <li>MDirection::URANUS
00105 //  <li>MDirection::NEPTUNE
00106 //  <li>MDirection::PLUTO
00107 //  <li>MDirection::SUN
00108 //  <li>MDirection::MOON
00109 //  <li>MDirection::COMET  -- solar system body: no coordinates  attached,
00110 //                       only table
00111 //  <li>MDirection::DEFAULT = J2000
00112 // </ul>
00113 // <p>
00114 // Conversion between the different types is done with the standard
00115 // <linkto class=MeasConvert>MeasConvert</linkto> class 
00116 // (<src>MDirection::Convert</src> in this case).<br>
00117 // For some conversion additional <linkto class=MeasFrame>MeasFrame</linkto>
00118 // information is essential. The following list specifies which information
00119 // is needed if the conversion goes to or from the different types:
00120 // <ul>
00121 //   <li><em>Epoch</em>: all but J2000, B1950, GALACTIC, SUPGAL, ECLIPTIC, ICRS
00122 //   <li><em>Positiom</em>: HADEC, AZEL, AZELGEO
00123 // </ul>
00124 // The conversion between B1950 and J2000 may have an Epoch. If none given
00125 // an epoch of 2000.0 is assumed for the conversion, unless an aipsrc
00126 // variable <em>measures.b1950.d_epoch</em> is given.
00127 //
00128 // Conversions are based on the IAU system of 
00129 // <linkto class=Precession>precession</linkto> and 
00130 // <linkto class=Nutation>nutation</linkto> (with
00131 // IERS corrections if available); and on series expansions of the DE200
00132 // planetary ephemeris (J system; for B sytem older expansions) for the
00133 // <linkto class=Aberration>aberration</linkto> and the 
00134 // <linkto class=SolarPos>solar position</linkto>.<br>
00135 // The <em>HADEC</em> position has corrections for polar motion and the
00136 // equation of equinoxes; the <em>AZEL</em> will include Earth tides and
00137 // refraction at a later stage.<br>
00138 // Note that conversion between B1950 and J2000 can only be approximate, and is
00139 // based on FK4 to FK5 conversion. The best conversion is to convert first
00140 // to an apparent position at the time of observation, and convert from there
00141 // to the other standard (the correct route will be followed).<br>
00142 // Another problem can arise if the source has proper motion and/or radial
00143 // velocities. These should be taken into account. An
00144 // MCatalog class will maybe take care of that.
00145 // <note role=warning>
00146 // The offset that can be specified in the MDirection::Ref is an MDirection
00147 // offset, and can not be used for specifying angular offsets. shift()
00148 // methods are available for these cases.
00149 // </note>
00150 // <p>
00151 // To aid in formatting of the angles without having to check all difference
00152 // referencetypes, the following global types are provided:
00153 // <ul>
00154 //  <li> GRADEC for types that are probably expressed in HM,DM
00155 //  <li> GHADEC for types that are probably expressed in +-HM,DM
00156 //  <li> GAZEL for types that are probably expressed in +-deg,deg
00157 //  <li> GLONGLAT for types that are probably expressed in deg,deg
00158 // </ul>
00159 // they can be obtained with the globalType() method. 
00160 // </synopsis>
00161 //
00162 // <example>
00163 // See <linkto module=Measures>Measures</linkto> module description for
00164 // extensive examples.
00165 // </example>
00166 //
00167 // <motivation>
00168 // </motivation>
00169 //
00170 // <todo asof="2000/06/15">
00171 //      <li>
00172 // </todo>
00173 
00174 class MDirection : public MeasBase<MVDirection, MeasRef<MDirection> > { 
00175 
00176 public:
00177 //# Friends
00178 // Conversion of data
00179     friend class MeasConvert<MDirection>;
00180 
00181 //# Enumerations
00182 // Types of known MDirections
00183 // <note role=warning> The order defines the order in the translation matrix FromTo
00184 // in the getConvert routine. Do not change the order without
00185 // changing the array. Additions should be made before N_types, and
00186 // an additional row and column should be coded in FromTo, and
00187 // in showType().</note>
00188     enum Types {
00189       J2000,
00190       JMEAN,
00191       JTRUE,
00192       APP,
00193       B1950,
00194       B1950_VLA,
00195       BMEAN,
00196       BTRUE,
00197       GALACTIC,
00198       HADEC,
00199       AZEL,
00200       AZELSW,
00201       AZELGEO,
00202       AZELSWGEO,
00203       JNAT,
00204       ECLIPTIC,
00205       MECLIPTIC,
00206       TECLIPTIC,
00207       SUPERGAL,
00208       ITRF,
00209       TOPO,
00210       ICRS,
00211       N_Types,
00212       // Planets. First one should be Mercury
00213       MERCURY = 32,
00214       VENUS,
00215       MARS,
00216       JUPITER,
00217       SATURN,
00218       URANUS,
00219       NEPTUNE,
00220       PLUTO,
00221       SUN,
00222       MOON,
00223       // Comet or other table-described solar system body
00224       COMET,
00225       N_Planets,
00226       // All extra bits
00227       EXTRA = 32,
00228       // Defaults
00229       DEFAULT=J2000,
00230       // Synonyms
00231       AZELNE=AZEL,
00232       AZELNEGEO=AZELGEO };
00233   // Global types
00234   enum GlobalTypes {
00235     GRADEC,
00236     GHADEC,
00237     GAZEL,
00238     GLONGLAT,
00239     N_GTypes};
00240 
00241   //# Typedefs
00242   // Measure value container for this class (i.e. MDirection::MVType)
00243   typedef MVDirection MVType;
00244   // Measure conversion routines for this class (i.e. MDirection::MCType)
00245   typedef MCDirection MCType;
00246   // Measure reference (i.e. MDirection::Ref)
00247   typedef MeasRef<MDirection> Ref;
00248   // Measure Convert (i.e. MDirection::Convert)
00249   typedef MeasConvert<MDirection> Convert;
00250   // Measure table Columns (e.g., MDirection::ScalarColumn)
00251   typedef ScalarMeasColumn<MDirection> ScalarColumn;
00252   typedef ArrayMeasColumn<MDirection> ArrayColumn;
00253   // Reference enum Types (included originally for gcc 2.95)  
00254   typedef WHATEVER_SUN_TYPEDEF(MDirection) Types Types;
00255 
00256 //# Constructors
00257 // <note role=tip> In the following constructors and other functions, all 
00258 // <em>MeasRef</em> can be replaced with simple <src>Measure::TYPE</src>
00259 // where no offsets or frames are needed in the reference. </note>
00260 // Default constructor; generates the J2000 pole direction
00261     MDirection();
00262 // Create from data and reference
00263 // <group>
00264     MDirection(const MVDirection &dt);
00265     MDirection(const MVDirection &dt, const MDirection::Ref &rf);
00266     MDirection(const MVDirection &dt, MDirection::Types rf);
00267     MDirection(const Quantity &dt, const Quantity &dt1);
00268     MDirection(const Quantity &dt, const Quantity &dt1, 
00269                const MDirection::Ref &rf);
00270     MDirection(const Quantity &dt, const Quantity &dt1, 
00271                MDirection::Types rf);
00272     MDirection(const Quantum<Vector<Double> > &dt);
00273     MDirection(const Quantum<Vector<Double> > &dt, 
00274                const MDirection::Ref &rf);
00275     MDirection(const Quantum<Vector<Double> > &dt, 
00276                MDirection::Types rf);
00277     MDirection(const Measure *dt);
00278     MDirection(const MeasValue *dt);
00279     MDirection(const MDirection::Ref &rf);
00280     MDirection(MDirection::Types rf);
00281 // </group>
00282 
00283 //# Destructor
00284     virtual ~MDirection();
00285 
00286 // Make an MDirection object given the name of a moving source (SUN, etc.)
00287 // or of a known standard source (CygA, etc.).
00288     static MDirection makeMDirection(const String& sourceName);
00289 
00290 //# Operators
00291 
00292 //# General Member Functions
00293 // Tell me your type ('Direction')
00294 // <group>
00295     virtual const String &tellMe() const;
00296     static const String &showMe();
00297 // </group>
00298 // Tell me your reference type (as Register())
00299   // N.B. as defined in MDirection.cc, it does NOT return the type of an
00300   // instance, i.e. it just returns Register(static_cast<MDirection *>(0)).
00301     virtual uInt type() const;
00302 // Assert you are a direction
00303     static void assure(const Measure &in);
00304 // Tell me the global type (like GRADEC) for tp (tp like MDirection::J2000)
00305   static MDirection::GlobalTypes globalType(uInt tp);
00306 // Translate reference code tp. The uInt version has a check for valid codes
00307   // (i.e. it is a safe cast).
00308   // <thrown>
00309   //   <li> AipsError in the uInt interface if illegal code given
00310   // </thrown>
00311   // <group>
00312   static MDirection::Types castType(uInt tp);
00313   static const String &showType(MDirection::Types tp);
00314   static const String &showType(uInt tp);
00315   // </group>
00316 // Translate string to reference code
00317 // <group>
00318   static Bool getType(MDirection::Types &tp, const String &in);
00319   Bool giveMe(MDirection::Ref &mr, const String &in);
00320 // </group>
00321   // Set the offset in the reference (False if non-matching Measure)
00322   virtual Bool setOffset(const Measure &in);
00323   // Set the reference type to the specified String. False if illegal
00324   // string, reference set to DEFAULT.
00325   virtual Bool setRefString(const String &in);
00326   // Get the default reference type
00327   virtual const String &getDefaultType() const;
00328   // Get a list of all known reference codes. nall returns the number in list,
00329   // nextra the number of specials (like planets) that should be at 
00330   // end of list). typ returns the list of corresponding types.
00331   // <group>
00332   virtual const String* allTypes(Int &nall, Int &nextra,
00333                                  const uInt *&typ) const;
00334   static const String* allMyTypes(Int &nall, Int &nextra,
00335                                   const uInt *&typ);
00336   // </group>
00337   // Check if all internal tables of types (both enum and String) are 
00338   // complete and correct. This function is called automatically if and when
00339   // necessary.
00340   // <thrown>
00341   //   <li> AipsError if a (programming) error in the types.
00342   // </thrown>
00343   // <group> 
00344   virtual void checkTypes() const;
00345   static void checkMyTypes();
00346   // </group>
00347   // Get the reference type (for records, including codes like R_)
00348   virtual String getRefString() const;
00349   // Get my type (as Register)
00350   // N.B. Being static, it does NOT return the type of an instance, i.e. use it
00351   // as MDirection::myType(), not md.myType().
00352   static uInt myType();
00353   // Tell me if you are a pure model (e.g. a planet)
00354   virtual Bool isModel() const;
00355 
00356   // Get Measure data
00357   // <group>
00358   Quantum<Vector<Double> > getAngle() const;
00359   Quantum<Vector<Double> > getAngle(const Unit &inunit) const;
00360   // </group>
00361   // Shift the direction in longitude (radians if Double) and/or latitude.
00362   // If the trueAngle switch is True, the longitude shift will be in
00363   // angular units perpendicular to the direction to pole, along a great
00364   // circle. See <linkto class=MVDirection>MVDirection</linkto>
00365   // for more details.
00366   // <group>
00367   void shift(const Quantum<Double> &lng,
00368              const Quantum<Double> &lat, Bool trueAngle=False);
00369   void shift(Double lng, Double lat, Bool trueAngle=False);
00370   void shiftLongitude(const Quantity &lng, Bool trueAngle=False);
00371   void shiftLongitude(Double lng, Bool trueAngle=False);
00372   void shiftLatitude(const Quantum<Double> &lat, Bool trueAngle=False);
00373   void shiftLatitude(Double lat, Bool trueAngle=False);
00374   void shift(const MVDirection &shft, Bool trueAngle=False);
00375   // </group>
00376   // Shift over an angle off in the direction pa. pa is measured from North,
00377   // in the direction of increasing longitude.
00378   // See <linkto class=MVDirection>MVDirection</linkto>
00379   // for implementation.
00380   // <group>
00381   void shiftAngle(const Quantum<Double> &off,
00382                   const Quantum<Double> &pa);
00383   void shiftAngle(Double off, Double pa);
00384   // </group>
00385 
00386 // Make a copy
00387 // <group>
00388     virtual Measure *clone() const;
00389 // </group>
00390 
00391 private:
00392 
00393 //# Data
00394 
00395 //# Member functions
00396 
00397 };
00398 
00399 
00400 } //# NAMESPACE CASA - END
00401 
00402 #endif
00403