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$ 00027 00028 #ifndef MEASURES_MEASJPL_H 00029 #define MEASURES_MEASJPL_H 00030 00031 //# Includes 00032 #include <casacore/casa/aips.h> 00033 #include <casacore/tables/Tables/Table.h> 00034 #include <casacore/tables/Tables/TableRow.h> 00035 #include <casacore/tables/Tables/TableRecord.h> 00036 #include <casacore/tables/Tables/ArrayColumn.h> 00037 #include <casacore/casa/Containers/RecordField.h> 00038 #include <casacore/casa/OS/Mutex.h> 00039 00040 namespace casacore { //# NAMESPACE CASACORE - 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 <casacore/casa/aips.h> 00096 // #include <casacore/casa/Quanta/MVEpoch.h> 00097 // #include <casacore/measures/Measures/MeasJPL.h> 00098 // #include <casacore/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 00182 //# General Member Functions 00183 // Get the values from a DE table, interpolated for date(in MJD(TDB)). 00184 // The file can be DE200 or DE405, the type as given in enum. 00185 static Bool get(Vector<Double> &returnValue, 00186 MeasJPL::Files file, 00187 MeasJPL::Types type, 00188 const MVEpoch &date); 00189 // Get indicated special constant 00190 static Bool getConst(Double &res, MeasJPL::Files which, 00191 MeasJPL::Codes what); 00192 // Get filed constant with name nam 00193 static Bool getConst(Double &res, MeasJPL::Files which, 00194 const String &nam); 00195 00196 // Close the set of JPL tables only 00197 static void closeMeas(); 00198 00199 private: 00200 00201 //# Constructors 00202 // Default constructor, NOT defined 00203 MeasJPL(); 00204 00205 // Copy assign, NOT defined 00206 MeasJPL &operator=(const MeasJPL &other); 00207 00208 //# Destructor 00209 // Destructor, NOT defined and not declared to stop warning 00210 // ~MeasJPL(); 00211 00212 //# General member functions 00213 // Initialise tables 00214 static Bool initMeas(MeasJPL::Files which); 00215 static Bool doInitMeas(MeasJPL::Files which); 00216 // Get a pointer to the data for the given date. It reads the data if needed. 00217 static const Double* fillMeas(Double &intv, MeasJPL::Files which, 00218 const MVEpoch &utf); 00219 // Interpolate Chebyshev polymomial to res 00220 static void interMeas(Double res[], MeasJPL::Files which, Double intv, 00221 Double ivf, Int ncf, Int ncm, Int na, 00222 const Double buf[]); 00223 00224 //# Data members 00225 // Measured data readable 00226 static volatile Bool needInit[N_Files]; 00227 // Tables present 00228 static Table t[N_Files]; 00229 // Data column descriptor 00230 static ArrayColumn<Double> acc[N_Files]; 00231 // First (-1) MJD in list 00232 static Int mjd0[N_Files]; 00233 // Last MJD in list 00234 static Int mjdl[N_Files]; 00235 // Interval in days (i.e., date step between subsequent rows) 00236 static Int dmjd[N_Files]; 00237 // File names 00238 static const String tp[N_Files]; 00239 // Index in record 00240 static Int idx[N_Files][3][13]; 00241 // Dates of the data read in buffer. 00242 static vector<Int> curDate[N_Files]; 00243 // Data read in. 00244 static vector<Vector<Double> > dval[N_Files]; 00245 // Some helper data read from the table keywords 00246 // <group> 00247 static Double aufac[N_Files]; 00248 static Double emrat[N_Files]; 00249 static Double cn[N_Files][N_Codes]; 00250 // </group> 00251 // Mutex for thread-safety. 00252 static Mutex theirMutex; 00253 }; 00254 00255 //# Inline Implementations 00256 00257 00258 } //# NAMESPACE CASACORE - END 00259 00260 #endif