casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MEpoch.h
Go to the documentation of this file.
00001 //# MEpoch.h: A Measure: instant in time
00002 //# Copyright (C) 1995,1996,1997,1998,1999,2000,2002
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: MEpoch.h 21298 2012-12-07 14:53:03Z gervandiepen $
00028 
00029 #ifndef MEASURES_MEPOCH_H
00030 #define MEASURES_MEPOCH_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/MVEpoch.h>
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 //# Forward Declarations
00041 class MEpoch;
00042 class MCEpoch;
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: instant in time
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 // Measure and Epoch
00064 // </etymology>
00065 //
00066 // <synopsis>
00067 // MEpoch forms derived Measure class for an instant in time.
00068 // </synopsis>
00069 //
00070 // <example>
00071 // Convert (with all steps explicit) a UTC to an IAT time.
00072 // <srcblock>
00073 //      #include <measures/Measures.h>
00074 //      #include <measures/Measures/MEpoch.h>
00075 //      #include <measures/Measures/MCEpoch.h>
00076 //      #include <casa/logging/LogIO.h>
00077 //      
00078 //      cout << "TAI for UTC = MJD(50237.29): " <<
00079 //              MEpoch::Convert(MEpoch(MVEpoch(Quantity(50237.29, "d")),
00080 //                                     MEpoch::Ref(MEpoch::UTC)),
00081 //                              MEpoch::Ref(MEpoch::TAI))() <<
00082 //              endl;
00083 //      LogIO os(LogOrigin("FluxCalc_SS_JPL_Butler", "readEphem"));
00084 //      os << LogIO::DEBUG1 << " at ";
00085 //      os.output() << MEpoch::Convert(MEpoch(MVEpoch(Quantity(50237.29, "d")),
00086 //                                     MEpoch::Ref(MEpoch::UTC)),
00087 //                              MEpoch::Ref(MEpoch::TAI))();
00088 //      os << LogIO::POST;
00089 // </srcblock>
00090 // Results in:
00091 // <srcblock>
00092 //      TAI for UTC = MJD(50237.29): Epoch: 50237::06:58:06.0000 (on stdout)
00093 //       at Epoch: 50237::06:58:06.0000 (in logger)
00094 // </srcblock>
00095 // </example>
00096 //
00097 // <motivation>
00098 // </motivation>
00099 //
00100 // <todo asof="2000/06/15">
00101 //      <li>
00102 // </todo>
00103 
00104 class MEpoch : public MeasBase<MVEpoch, MeasRef<MEpoch> > {
00105 
00106 public:
00107   //# Friends
00108   friend class MeasConvert<MEpoch>;
00109   
00110   //# Enumerations
00111   // Types of known MEpochs
00112   // <note role=caution> The order defines the order in the translation matrix
00113   // in the MCEpoch class. Do not change the order without
00114   // changing the array. Additions should be made before N_types, and
00115   // an additional row and column should be coded in FromTo (MCEpoch), and
00116   // in showType().</note>
00117   enum Types {
00118     // Local Apparent Sidereal Time
00119     LAST,
00120     // Local Mean Sidereal Time
00121     LMST,
00122     // Greenwich Mean ST1
00123     GMST1,
00124     // Greenwich Apparent ST
00125     GAST,
00126     UT1,
00127     UT2,
00128     UTC,
00129     TAI,
00130     TDT,
00131     TCG,
00132     TDB,
00133     TCB,
00134     // Number of types
00135     N_Types,
00136     // Reduce result to integer days
00137     RAZE = 32,
00138     // All extra bits
00139     EXTRA = RAZE,
00140     // Synonyms
00141     IAT=TAI,    
00142     GMST=GMST1,
00143     TT=TDT,
00144     UT=UT1,
00145     ET=TT,
00146     // Default
00147     DEFAULT=UTC
00148   };
00149   
00150   //# Typedefs
00151   // Measure value container for this class (i.e. MEpoch::MVType)
00152   typedef MVEpoch MVType;
00153   // Measure conversion routines for this class (i.e. MEpoch::MCType)
00154   typedef MCEpoch MCType;
00155   // Measure reference (i.e. MEpoch::Ref)
00156   typedef MeasRef<MEpoch> Ref;
00157   // Measure Convert (i.e. MEpoch::Convert)
00158   typedef MeasConvert<MEpoch> Convert;
00159   // Measure table Columns (e.g., MEpoch::ScalarColumn)
00160   typedef ScalarMeasColumn<MEpoch> ScalarColumn;
00161   typedef ArrayMeasColumn<MEpoch> ArrayColumn;
00162   // Reference enum Types (included originally for gcc 2.95)  
00163   typedef WHATEVER_SUN_TYPEDEF(MEpoch) Types Types;
00164     
00165   //# Constructors
00166   // <note role=tip> In the following constructors and other functions, all 
00167   // <em>MeasRef</em> can be replaced with simple <src>Measure::TYPE</src>
00168   // where no offsets or frames are needed in the reference. </note>
00169   // Default constructor; generates an instant at MJD 0 UTC
00170   MEpoch();
00171   // Create from data and reference
00172   // <group>
00173   MEpoch(const MVEpoch &dt);
00174   MEpoch(const MVEpoch &dt, const MEpoch::Ref &rf);
00175   MEpoch(const MVEpoch &dt, MEpoch::Types rf);
00176   MEpoch(const Quantity &dt);
00177   MEpoch(const Quantity &dt, const MEpoch::Ref &rf);
00178   MEpoch(const Quantity &dt, MEpoch::Types rf);
00179   MEpoch(const Measure *dt);
00180   MEpoch(const MeasValue *dt);
00181   // </group>
00182   
00183   //# Destructor
00184   virtual ~MEpoch();
00185   
00186   //# Operators
00187   
00188   //# General Member Functions
00189   // Tell me your type
00190   // <group>
00191   virtual const String &tellMe() const;
00192   static const String &showMe();
00193   virtual uInt type() const;
00194   static void assure(const Measure &in);
00195   // </group>
00196   // Translate reference code. The uInt version has a check for valid codes
00197   // (i.e. it is a safe cast).
00198   // <thrown>
00199   //   <li> AipsError in the uInt interface if illegal code given
00200   // </thrown>
00201   // <group>
00202   static MEpoch::Types castType(uInt tp);
00203   static const String &showType(MEpoch::Types tp);
00204   static const String &showType(uInt tp);
00205   // </group>
00206   // Translate string to reference code
00207   // <group>
00208   static Bool getType(MEpoch::Types &tp, const String &in);
00209   Bool giveMe(MEpoch::Ref &mr, const String &in);
00210   // </group>
00211   // Set the offset in the reference (False if non-matching Measure)
00212   virtual Bool setOffset(const Measure &in);
00213   // Set the reference type to the specified String. False if illegal
00214   // string, reference set to DEFAULT.
00215   virtual Bool setRefString(const String &in);
00216   // Get the default reference type
00217   virtual const String &getDefaultType() const;
00218   // Get a list of all known reference codes. nall returns the number in list,
00219   // nextra the number of specials (like planets) that should be at 
00220   // end of list). typ returns the list of corresponding types.
00221   // <group>
00222   virtual const String* allTypes(Int &nall, Int &nextra,
00223                                  const uInt *&typ) const;
00224   static const String* allMyTypes(Int &nall, Int &nextra,
00225                                   const uInt *&typ);
00226   // </group>
00227   // Check if all internal tables of types (both enum and String) are 
00228   // complete and correct. This function is called automatically if and when
00229   // necessary.
00230   // <thrown>
00231   //   <li> AipsError if a (programming) error in the types.
00232   // </thrown>
00233   // <group> 
00234   virtual void checkTypes() const;
00235   static void checkMyTypes();
00236   // </group>
00237   // Get the reference type (for records, including codes like R_)
00238   virtual String getRefString() const;
00239   // Get my type (as Register)
00240   static uInt myType();
00241 
00242   // Get time in specified units
00243   Quantity get(const Unit &inunit) const;
00244   
00245   // Create copy
00246   // <group>
00247   virtual Measure *clone() const;
00248   // </group>
00249   
00250 private:
00251   //# Enumerations
00252   
00253   //# Data
00254   
00255   //# Member functions
00256   
00257 };
00258 
00259 
00260 } //# NAMESPACE CASA - END
00261 
00262 #endif