casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MeasJPL.h
Go to the documentation of this file.
00001 //# MeasJPL.h: Interface to JPL DE tables
00002 //# Copyright (C) 1996,1997,1998,1999,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 //# $Id: MeasJPL.h 21298 2012-12-07 14:53:03Z gervandiepen $
00027 
00028 #ifndef MEASURES_MEASJPL_H
00029 #define MEASURES_MEASJPL_H
00030 
00031 //# Includes
00032 #include <casa/aips.h>
00033 #include <tables/Tables/Table.h>
00034 #include <tables/Tables/TableRow.h>
00035 #include <tables/Tables/TableRecord.h>
00036 #include <tables/Tables/ArrayColumn.h>
00037 #include <casa/Containers/RecordField.h>
00038 #include <casa/OS/Mutex.h>
00039 
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 
00042 //# Forward Declarations
00043 class String;
00044 class MVEpoch;
00045 
00046 // <summary> Interface to JPL DE tables </summary>
00047 
00048 // <use visibility=local>
00049 
00050 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasJPL" demos="">
00051 // </reviewed>
00052 
00053 // <prerequisite>
00054 //   <li> <linkto class=MeasTable>MeasTable</linkto>
00055 // </prerequisite>
00056 //
00057 // <etymology>
00058 // From Measure and JPL
00059 // </etymology>
00060 //
00061 // <synopsis>
00062 // MeasJPL is the interface class to the JPL DE planetary data.
00063 // It has only static memebers.<br>
00064 // Tables are found using the aipsrc 
00065 // (using <src>measures.<table>.directory</src>)
00066 // mechanism. If not provided they are assumed to reside in standard places
00067 // (i.e. in $AIPSROOT/data/ephemerides) Tables are assumed to have the
00068 // VS_VERSION, VS_DATE, VS_CREATE and VS_TYPE keywords, and be of type IERS,
00069 // else an exception will be thrown.<br>
00070 // The <src>get()</src> method will obtain data from the JPL planetary
00071 // tables (i.e. the <src>DE200</src> and
00072 // the <src>DE405</src> tables). The data obtained will be the barycentric
00073 // position (AU) and velocity (AU/d) of planets; the nutation (rad, rad/d)
00074 // or the libration (rad, rad/d; DE405 only). All in the J2000 system.<br>
00075 // The JPL DE Tables have a large set of constants attach to it. Some
00076 // will be available by their own special code, the others their filed name.
00077 // (See the <src>get</src> functions.<br>
00078 // The enumeration code gives the available data and planets. See
00079 // E.M. Standish et al., JPL IOM 314.10 - 127 for further details.
00080 // <br>
00081 // Note that the normal usage of these tables is through the Measures system.
00082 // 
00083 // <note>
00084 //      A message is Logged (once) if a table cannot be found.
00085 //      A message is logged (once) if a date outside the range in
00086 //      the Tables is asked for. 
00087 // </note>
00088 // <thrown>
00089 //     <li> AipsError if table opened has wrong format or otherwise corrupted.
00090 // </thrown>
00091 // </synopsis>
00092 //
00093 // <example>
00094 // <srcblock>
00095 //      #include <casa/aips.h>
00096 //      #include <casa/Quanta/MVEpoch.h>
00097 //      #include <measures/Measures/MeasJPL.h>
00098 //      #include <casa/Arrays/Vector.h>
00099 //      const MVEpoch dat = 51116; // a date (1998/10/30) in TDB
00100 //      Vector<Double> val(6), valE(6);         // results
00101 //      // Get position and velocity of Venus (barycentric)
00102 //      if (!MeasJPL::get(val, MeasJPL::DE200, MeasJPL::VENUS, dat)) {
00103 //              cout << "Some error getting Venus position" << endl;
00104 //      // Get Earth position and velocity (barycentric)
00105 //      } else if (!MeasJPL::get(valE, MeasJPL::DE200, MeasJPL::VENUS, dat)) {
00106 //              cout << "Some error getting Earth position" << endl;
00107 //      } else {
00108 //              cout << "Venus (geocentric): " << (val-valE) << endl;
00109 //      };
00110 // </srcblock>
00111 // </example>
00112 //
00113 // <motivation>
00114 // To use the JPL data for planetary positions and high precision nutation
00115 // </motivation>
00116 //
00117 // <todo asof="1998/08/24">
00118 // </todo>
00119 
00120 class MeasJPL { 
00121 
00122 public:
00123   //# Constants
00124   
00125   //# Enumerations
00126   // Types of known data
00127   enum Types {
00128     // MJD (must be first in list)
00129     MJD,
00130     // Column with data
00131     X,
00132     // Number of columns
00133     N_Columns,
00134     // Planets
00135     MERCURY = 1,
00136     VENUS = 2,
00137     EARTH = 3,
00138     MARS = 4,
00139     JUPITER = 5,
00140     SATURN = 6,
00141     URANUS = 7,
00142     NEPTUNE = 8,
00143     PLUTO = 9,
00144     MOON = 10,
00145     SUN = 11,
00146     // Solar system barycentre
00147     BARYSOLAR = 12,
00148     // Earth-Moon system barycentre
00149     BARYEARTH = 13,
00150     // Nutations
00151     NUTATION = 14,
00152     // Librations
00153     LIBRATION = 15,
00154     // Number of types
00155     N_Types };
00156   
00157   // Types of files
00158   enum Files {
00159     // DE200
00160     DE200,
00161     // DE405
00162     DE405,
00163     // # of known types
00164     N_Files,
00165     // Default
00166     DEFAULT = DE200 };
00167   
00168   // Codes for special constants
00169   enum Codes {
00170     // Light velocity used in AU/d
00171     CAU,
00172     // Solar mass (GM0)/c<sup>2</sup> in AU
00173     GMS,
00174     // AU in km
00175     AU,
00176     // Solar radius in AU
00177     RADS,
00178     // # of codes
00179     N_Codes };
00180   
00181   //# General Member Functions
00182   // Get the values from a DE table, interpolated for date(in MJD(TDB)).
00183   // The file can be DE200 or DE405, the type as given in enum.
00184   static Bool get(Vector<Double> &returnValue,
00185                   MeasJPL::Files file, 
00186                   MeasJPL::Types type,
00187                   const MVEpoch &date);
00188   // Get indicated special constant
00189   static Bool getConst(Double &res, MeasJPL::Files which,
00190                        MeasJPL::Codes what);
00191   // Get filed constant with name nam
00192   static Bool getConst(Double &res, MeasJPL::Files which,
00193                        const String &nam);
00194 
00195   // Close the set of JPL tables only
00196   static void closeMeas();
00197 
00198 private:
00199   
00200   //# Constructors
00201   // Default constructor, NOT defined
00202   MeasJPL();
00203   
00204   // Copy assign, NOT defined
00205   MeasJPL &operator=(const MeasJPL &other);
00206   
00207   //# Destructor
00208   //  Destructor, NOT defined and not declared to stop warning
00209   // ~MeasJPL();
00210   
00211   //# General member functions
00212   // Initialise tables
00213   static Bool initMeas(MeasJPL::Files which);
00214   // Fill Table lines
00215   static Bool fillMeas(Double &intv, MeasJPL::Files which,
00216                        const MVEpoch &utf);
00217   // Interpolate Chebyshev polymomial to res
00218   static void interMeas(Double res[], MeasJPL::Files  which, Double intv, 
00219                         Double ivf, Int ncf, Int ncm, Int na, 
00220                         const Double buf[]);
00221 
00222   //# Data members
00223   // Measured data readable
00224   static volatile Bool measFlag[N_Files];
00225   // Tables present
00226   static Table t[N_Files];
00227   // Row descriptions
00228   static ROTableRow row[N_Files];
00229   // Field pointers
00230   static RORecordFieldPtr<Double> rfp[N_Files][MeasJPL::N_Types];
00231   // First (-1) MJD in list
00232   static Int mjd0[N_Files];
00233   // Last MJD in list
00234   static Int mjdl[N_Files];
00235   // Increment in rows
00236   static Int dmjd[N_Files];
00237   // Message given
00238   static Bool msgDone;
00239   // File names
00240   static const String tp[N_Files];
00241   // Index in record
00242   static Int idx[N_Files][3][13];
00243   // Data column descriptor
00244   static ArrayColumn<Double> acc[N_Files];
00245   // Data in current row
00246   static Vector<Double> dval[N_Files];
00247   // Current row
00248   static Int ldat[N_Files];
00249   // Chebyshev coefficients
00250   // <group>
00251   static Double chc[18];
00252   static Double chcv[18];
00253   // </group>
00254   // Some helper data
00255   // <group>
00256   static Double aufac[N_Files];
00257   static Double emrat[N_Files];
00258   static Double cn[N_Files][N_Codes];
00259   static Int np;
00260   static Int nv;
00261   static Double twot;
00262   static Double vfac;
00263   // </group>
00264   // Mutex for thread-safety.
00265   static Mutex theirMutex;
00266 };
00267 
00268 //# Inline Implementations
00269 
00270 
00271 } //# NAMESPACE CASA - END
00272 
00273 #endif